How to use filter_options method in molecule

Best Python code snippet using molecule_python

test_relative_tt_residuals.py

Source:test_relative_tt_residuals.py Github

copy

Full Screen

1#!/usr/bin/env python2from __future__ import absolute_import3# pylint: disable=invalid-name, missing-docstring4import numpy as np5import pytest6from seismic.gps_corrections import relative_tt_residuals_plotter as rttr7def test_global_filtering(df_picks):8 ## Test filter_limit_channels9 channels_broad = rttr.filter_limit_channels(df_picks, rttr.CHANNEL_PREF_NO_SHZ)10 assert len(channels_broad) == 4011 channels_broad_shz = rttr.filter_limit_channels(df_picks, rttr.CHANNEL_PREF_BALANCED)12 assert len(channels_broad_shz) == 40 + 613 channels_all = rttr.filter_limit_channels(df_picks, rttr.CHANNEL_PREF_GREEDY)14 assert len(channels_all) == 40 + 6 + 515 ## Test filter_to_teleseismic16 df_ts = rttr.filter_to_teleseismic(df_picks, 0, 10)17 assert df_ts.empty18 df_ts = rttr.filter_to_teleseismic(df_picks, 0, 180)19 assert len(df_ts) == 5120 assert df_ts['distance'].min() >= 021 assert df_ts['distance'].max() <= 18022 df_ts = rttr.filter_to_teleseismic(df_picks, 0, 20)23 assert len(df_ts) == 1024 assert df_ts['distance'].min() >= 025 assert df_ts['distance'].max() <= 2026 df_ts = rttr.filter_to_teleseismic(df_picks, 20, 35)27 assert len(df_ts) == 3428 assert df_ts['distance'].min() >= 2029 assert df_ts['distance'].max() <= 3530 df_ts = rttr.filter_to_teleseismic(df_picks, 35, 90)31 assert len(df_ts) == 732 assert df_ts['distance'].min() >= 3533 assert df_ts['distance'].max() <= 9034 df_ts = rttr.filter_to_teleseismic(df_picks, 50, 90)35 assert df_ts.empty36def test_get_iris_station_codes(iris_stntxt_file):37 df_au = rttr.get_iris_station_codes(iris_stntxt_file, 'AU')38 assert list(df_au.index) == ['ARMA', 'EIDS', 'KMBL', 'MILA', 'NRFK', 'RABL', 'XMI']39 assert np.allclose(df_au['lat'], [-30.4198, -25.369101, -31.366899, -37.054699, -29.040001, -4.127967, -10.4498],40 rtol=1.0e-6)41 assert np.allclose(df_au['lon'], [151.628006, 151.081696, 121.882103, 149.154999, 167.962997, 152.108765,42 105.688950], rtol=1.0e-6)43 df_ge = rttr.get_iris_station_codes(iris_stntxt_file, 'GE')44 assert list(df_ge.index) == ['BKNI', 'DAG', 'GSI', 'KAAM', 'KWP', 'MARJ', 'MORC', 'TRTE']45 assert np.allclose(df_ge['lat'], [0.3262, 76.771301, 1.3039, 0.49264, 49.630501, 32.522598, 49.83105, 58.378601],46 rtol=1.0e-6)47 assert np.allclose(df_ge['lon'], [101.039597, -18.655001, 97.5755, 72.994858, 22.7078, 20.8776, 17.577573,48 26.720501], rtol=1.0e-6)49def test_apply_event_quality_filtering(df_picks):50 '''51 self.strict_filtering = DEFAULT_STRICT_FILTERING52 self.min_event_snr = DEFAULT_MIN_EVENT_SNR53 self.cwt_cutoff = DEFAULT_CWT_CUTOFF54 self.slope_cutoff = DEFAULT_SLOPE_CUTOFF55 self.nsigma_cutoff = DEFAULT_NSIGMA_CUTOFF56 self.min_event_mag = DEFAULT_MIN_EVENT_MAG57 self.channel_preference = CHANNEL_PREF58 '''59 filter_options = rttr.FilterOptions()60 # Set filter to loosest settings first, then test adjusting one filter variable at a time.61 filter_options.strict_filtering = False62 filter_options.min_event_mag = 5.063 filter_options.min_event_snr = 0.064 filter_options.cwt_cutoff = 0.065 filter_options.slope_cutoff = 0.066 filter_options.nsigma_cutoff = 067 net_sta = {'net': ['AU'], 'sta': ['MEEK']}68 # Test magnitude filter69 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)70 assert len(df_filt) == 5171 filter_options.min_event_mag = 6.072 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)73 assert len(df_filt) == 4974 filter_options.min_event_mag = 7.075 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)76 assert len(df_filt) == 4877 filter_options.min_event_mag = 8.078 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)79 assert len(df_filt) == 4680 filter_options.min_event_mag = 9.081 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)82 assert len(df_filt) == 4483 # Test SNR filter84 filter_options.min_event_mag = 5.085 filter_options.min_event_snr = 5.086 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)87 assert len(df_filt) == 4788 filter_options.min_event_snr = 10.089 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)90 assert len(df_filt) == 3491 filter_options.min_event_snr = 15.092 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)93 assert len(df_filt) == 2394 # This encompasses in AU.MEEK, which gets ignored since filtering is non-strict.95 filter_options.min_event_snr = 20.096 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)97 assert len(df_filt) == 1298 # Turn on strict filtering and check filter criteria is now applied to AU.MEEK.99 filter_options.strict_filtering = True100 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)101 assert len(df_filt) == 11102 filter_options.min_event_snr = 25.0103 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)104 assert len(df_filt) == 7105 filter_options.strict_filtering = False106 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)107 assert len(df_filt) == 8108 # Test CWT cutoff109 filter_options.min_event_snr = 0.0110 filter_options.cwt_cutoff = 5111 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)112 assert len(df_filt) == 39113 # This encompasses in AU.MEEK, which gets ignored since filtering is non-strict.114 filter_options.cwt_cutoff = 10115 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)116 assert len(df_filt) == 30117 # Turn on strict filtering and check filter criteria is now applied to AU.MEEK.118 filter_options.strict_filtering = True119 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)120 assert len(df_filt) == 29121 filter_options.cwt_cutoff = 20122 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)123 assert len(df_filt) == 22124 filter_options.cwt_cutoff = 50125 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)126 assert len(df_filt) == 12127 filter_options.strict_filtering = False128 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)129 assert len(df_filt) == 13130 # Test slope cutoff131 filter_options.cwt_cutoff = 0.0132 filter_options.slope_cutoff = 1.0133 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)134 assert len(df_filt) == 43135 filter_options.slope_cutoff = 2.0136 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)137 assert len(df_filt) == 28138 # This encompasses in AU.MEEK, which gets ignored since filtering is non-strict.139 filter_options.slope_cutoff = 5.0140 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)141 assert len(df_filt) == 16142 # Turn on strict filtering and check filter criteria is now applied to AU.MEEK.143 filter_options.strict_filtering = True144 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)145 assert len(df_filt) == 15146 # Test nSigma cutoff147 filter_options.strict_filtering = False148 filter_options.slope_cutoff = 0.0149 filter_options.nsigma_cutoff = 5150 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)151 assert len(df_filt) == 45152 filter_options.nsigma_cutoff = 6153 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)154 assert len(df_filt) == 43155 filter_options.nsigma_cutoff = 7156 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)157 assert len(df_filt) == 41158 ## Test combined filtering159 filter_options.strict_filtering = True160 filter_options.min_event_mag = 6.0161 filter_options.min_event_snr = 8.0162 filter_options.cwt_cutoff = 2.0163 filter_options.slope_cutoff = 1.2164 filter_options.nsigma_cutoff = 5165 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)166 assert len(df_filt) == 5 + 24 # 5 from the zero quality metrics group + 24 from the rest167 mask_zero_metrics = (df_filt[['snr', 'qualityMeasureCWT', 'qualityMeasureSlope', 'nSigma']] == 0).all(axis=1)168 df_zero_mets = df_filt[mask_zero_metrics]169 df_other = df_filt[~mask_zero_metrics]170 assert np.all(df_zero_mets['mag'] >= filter_options.min_event_mag)171 assert np.all((df_other['snr'] >= filter_options.min_event_snr) &172 (df_other['qualityMeasureCWT'] >= filter_options.cwt_cutoff) &173 (df_other['qualityMeasureSlope'] >= filter_options.slope_cutoff) &174 (df_other['nSigma'] >= filter_options.nsigma_cutoff))175 filter_options.slope_cutoff = 3.0176 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)177 assert len(df_filt) == 18 # 5 from the zero quality metrics group + 13 from the rest178 # Not applying filtering to AU.MEEK179 filter_options.strict_filtering = False180 df_filt = rttr.apply_event_quality_filtering(df_picks, net_sta, filter_options)181 assert len(df_filt) == 19182 # Test passing more than one target station183 net_sta['net'].append('GE')184 net_sta['sta'].append('WSI')185 pytest.raises(ValueError, rttr.apply_event_quality_filtering, df_picks, net_sta, filter_options)186def test_broadcast_ref_residual_per_event(df_picks):187 filter_options = rttr.FilterOptions()188 df_ref = rttr.broadcast_ref_residual_per_event(df_picks, 'AU', 'MEEK', filter_options)189 # AU.MEEK is only there in event4, so only that event will have a non-Nan reference residual.190 expected_residual = 1.029852191 assert np.all(df_ref.loc[df_ref['#eventID'] == 'event4', 'ttResidualRef'] == expected_residual)192 assert np.all(df_ref.loc[df_ref['#eventID'] != 'event4', 'ttResidualRef'].isnull())193 # Repeat with a station that appears in multiple events194 df_ref = rttr.broadcast_ref_residual_per_event(df_picks, 'AU', 'KNA', filter_options)195 expected_event0_residual = -0.134955196 expected_event4_residual = 1.192448197 assert np.allclose(df_ref.loc[df_ref['#eventID'] == 'event0', 'ttResidualRef'], expected_event0_residual)198 assert np.allclose(df_ref.loc[df_ref['#eventID'] == 'event4', 'ttResidualRef'], expected_event4_residual)199 assert np.all(df_ref.loc[(df_ref['#eventID'] != 'event0') & (df_ref['#eventID'] != 'event4'),200 'ttResidualRef'].isnull())201 # Repeat with NWAO which is common to event1 and event4202 df_ref = rttr.broadcast_ref_residual_per_event(df_picks, 'IR', 'NWAO', filter_options)203 expected_event1_residual = -1.786222204 expected_event4_residual = -0.692545205 assert np.allclose(df_ref.loc[df_ref['#eventID'] == 'event1', 'ttResidualRef'], expected_event1_residual)206 assert np.allclose(df_ref.loc[df_ref['#eventID'] == 'event4', 'ttResidualRef'], expected_event4_residual)207 assert np.all(df_ref.loc[(df_ref['#eventID'] != 'event1') & (df_ref['#eventID'] != 'event4'),208 'ttResidualRef'].isnull())209def test_analyze_target_relative_to_ref(df_picks):210 filter_options = rttr.FilterOptions()211 # Set filter params to include the events on AU.KNA212 filter_options.min_event_snr = 5.0213 filter_options.cwt_cutoff = 5.0214 filter_options.slope_cutoff = 2.0215 target_net_sta = {'net': ['AU'], 'sta': ['KNA']}216 # Analyze AU.MEEK relative to all the GE stations217 ref_net_sta = {'net': ['GE']*15,218 'sta': ['WSI', 'ARMA', 'MEEK', 'CNB', 'CHN', 'FUQ', 'NZJ', 'NGO1', 'NAH1', 'SSE',219 'NJ2', 'TIA', 'KAPI', 'KMBL', 'MEEK']220 }221 df_plottable = rttr.analyze_target_relative_to_ref(df_picks, target_net_sta, ref_net_sta, filter_options)222 assert 'ttResidualRef' in df_plottable223 assert list(df_plottable['#eventID'].unique()) == ['event0', 'event4']224 assert list(df_plottable['ttResidualRef'].unique()) == [-0.134955, 1.192448]225 # For event0, only GE.WSI and GE.ARMA are present, and both pass the filtering criteria.226 assert np.all(np.all(df_plottable.loc[df_plottable['#eventID'] == 'event0', ['net', 'sta']].values ==227 np.array([['AU', 'KNA'], ['GE', 'WSI'], ['GE', 'ARMA']]), axis=1))228 # For event4, GE.KAPI, GE.KMBL and GE.MEEK are present, but GE.KMBL does not pass the filtering criteria229 # due to slope metric.230 assert np.all(np.all(df_plottable.loc[df_plottable['#eventID'] == 'event4', ['net', 'sta']].values ==231 np.array([['AU', 'KNA'], ['GE', 'KAPI'], ['GE', 'MEEK']]), axis=1))232 # Exercise the code path for plotting to detect some regressions.233 batch_options = rttr.BatchOptions()234 batch_options.batch_label = '_strict'235 display_options = rttr.DisplayOptions()236 display_options.events = rttr.generate_large_events_catalog(df_picks, 8.0)237 display_options.deployments = rttr._get_known_temporary_deployments() # pylint: disable=protected-access238 rttr._plot_network_relative_to_ref_station(df_plottable, target_net_sta, ref_net_sta, # pylint: disable=protected-access239 batch_options, filter_options, display_options)240if __name__ == "__main__":241 # Select explicit test to run.242 # import conftest243 # picks = conftest._read_picks()244 # test_analyze_target_relative_to_ref(picks)...

Full Screen

Full Screen

storage.py

Source:storage.py Github

copy

Full Screen

1import json2from abc import abstractmethod3from argparse import ArgumentTypeError4from functools import reduce5import pymongo6class Collection(object):7 pass8class Storage(object):9 def __init__(self, config):10 self.config = config11 @abstractmethod12 def get_field(self, collection_name, key, **filter_options):13 pass14 @abstractmethod15 def set_field(self, collection_name, key, new_value, multi=False, **filter_options):16 pass17 # work with entire objects from collection18 # TODO: add deprecations19 @abstractmethod20 def get_object(self, collection_name, filter_options, multi=False):21 pass22 @abstractmethod23 def set_object(self, collection_name, new_object, filter_options, multi=False):24 pass25 @abstractmethod26 def remove_object(self, collection_name, filter_options, multi=False):27 pass28 def collection(self, collection_name):29 coll = Collection()30 def decorated_get_field(key, **filter_options):31 return self.get_field(collection_name, key, **filter_options)32 def decorated_set_field(key, new_value, multi=False, **filter_options):33 return self.set_field(collection_name, key, new_value, multi=multi, **filter_options)34 def decorated_get_object(filter_options, multi=False):35 return self.get_object(collection_name, filter_options, multi)36 def decorated_set_object(new_object, filter_options, multi=False):37 return self.set_object(collection_name, new_object, filter_options, multi)38 def decorated_remove_object(filter_options, multi=False):39 return self.remove_object(collection_name, filter_options, multi)40 decorated_get_field.__name__ = 'get_field'41 decorated_set_field.__name__ = 'set_field'42 decorated_get_object.__name__ = 'get_object'43 decorated_set_object.__name__ = 'set_object'44 decorated_remove_object.__name__ = 'remove_object'45 setattr(coll, decorated_get_field.__name__, decorated_get_field)46 setattr(coll, decorated_set_field.__name__, decorated_set_field)47 setattr(coll, decorated_get_object.__name__, decorated_get_object)48 setattr(coll, decorated_set_object.__name__, decorated_set_object)49 setattr(coll, decorated_remove_object.__name__, decorated_remove_object)50 return coll51class InMemoryStorage(Storage):52 def __init__(self, config):53 super().__init__(config)54 self.store = {}55 @staticmethod56 def _find_conforming_objects(collection, filter_options):57 conforming_objects = []58 for obj in collection:59 conforms = True60 for filter_key in filter_options.keys():61 if obj.get(filter_key) != filter_options[filter_key]:62 conforms = False63 break64 if conforms:65 # object fully conforms66 conforming_objects.append(obj)67 return conforming_objects68 def get_field(self, collection_name, key, **filter_options):69 arr = self.store.get(collection_name, [])70 if len(arr) < 1:71 return []72 reduce_filter_func = lambda dict_key, elem, res: \73 res and (elem.get(dict_key) == filter_options.get(dict_key))74 arr_elem_meets_filter = lambda elem: reduce(lambda res, dict_key: reduce_filter_func(dict_key, elem, res), filter_options.keys(), True)75 filtered_arr = tuple(filter(lambda elem: arr_elem_meets_filter(elem), arr))76 if len(filtered_arr) < 1:77 return []78 resulting_arr = list(filter(lambda elem: elem is not None, map(lambda elem: elem.get(key, None), filtered_arr)))79 return resulting_arr80 def set_field(self, collection_name, key, new_value, multi=False, **filter_options):81 collection = self.store.get(collection_name, [])82 def create_new_obj(filter_options, key, new_value):83 obj = dict(filter_options)84 obj[key] = new_value85 return obj86 if len(collection) < 1:87 self.store[collection_name] = collection88 collection.append(create_new_obj(filter_options, key, new_value))89 return True90 def find_conforming_obj(collection, filter_options):91 for obj in collection:92 conforms = True93 for filter_key in filter_options.keys():94 if obj.get(filter_key) != filter_options[filter_key]:95 conforms = False96 break97 if conforms:98 return obj99 return None100 found_obj = find_conforming_obj(collection, filter_options)101 if found_obj is None:102 collection.append(create_new_obj(filter_options, key, new_value))103 else:104 found_obj[key] = new_value105 return True106 def get_object(self, collection_name, filter_options, multi=False):107 if filter_options is None or not isinstance(filter_options, dict) or len(filter_options.keys()) < 1:108 raise ArgumentTypeError('filter_options must be a non-empty dict!')109 arr = self.store.get(collection_name, [])110 if len(arr) < 1:111 if multi:112 return []113 return None114 reduce_filter_func = lambda dict_key, elem, res: \115 res and (elem.get(dict_key) == filter_options.get(dict_key))116 arr_elem_meets_filter = lambda elem: reduce(lambda res, dict_key: reduce_filter_func(dict_key, elem, res),117 filter_options.keys(), True)118 filtered_arr = list(filter(lambda elem: arr_elem_meets_filter(elem), arr))119 if len(filtered_arr) < 1:120 if multi:121 return []122 else:123 return None124 if multi:125 return filtered_arr126 else:127 return filtered_arr[0]128 def set_object(self, collection_name, new_object, filter_options, multi=False):129 if filter_options is None or not isinstance(filter_options, dict) or len(filter_options.keys()) < 1:130 raise ArgumentTypeError('filter_options must be a non-empty dict!')131 collection = self.store.get(collection_name, [])132 if len(collection) < 1:133 self.store[collection_name] = collection134 collection.append(new_object)135 return True136 found_objects = self._find_conforming_objects(collection, filter_options)137 if len(found_objects) > 0:138 for found_object in found_objects:139 collection.remove(found_object)140 if not multi:141 # we've already removed one142 break143 collection.append(new_object)144 return True145 def remove_object(self, collection_name, filter_options, multi=False):146 if filter_options is None or not isinstance(filter_options, dict) or len(filter_options.keys()) < 1:147 raise ArgumentTypeError('filter_options must be a non-empty dict!')148 collection = self.store.get(collection_name, [])149 if len(collection) < 1:150 return False151 found_objects = self._find_conforming_objects(collection, filter_options)152 if len(found_objects) > 0:153 for found_object in found_objects:154 collection.remove(found_object)155 if not multi:156 # we've already removed one157 break158 else:159 return False160 return True161class DiskStorage(InMemoryStorage):162 def __init__(self, config):163 super().__init__(config)164 self.storage_file_path = config['file_path']165 try:166 self.store = json.load(open(self.storage_file_path, 'r'))167 except (json.JSONDecodeError, FileNotFoundError) as e:168 self.store = {}169 def set_field(self, collection_name, key, new_value, multi=False, **filter_options):170 result = super().set_field(collection_name, key, new_value, multi, **filter_options)171 json.dump(self.store, open(self.storage_file_path, 'w'))172 return result173 def get_field(self, collection_name, key, **filter_options):174 result = super().get_field(collection_name, key, **filter_options)175 return result176 def set_object(self, collection_name, new_object, filter_options, multi=False):177 result = super().set_object(collection_name, new_object, filter_options, multi)178 json.dump(self.store, open(self.storage_file_path, 'w'))179 return result180 def get_object(self, collection_name, filter_options, multi=False):181 result = super().get_object(collection_name, filter_options, multi)182 return result183 def remove_object(self, collection_name, filter_options, multi=False):184 result = super().remove_object(collection_name, filter_options, multi)185 json.dump(self.store, open(self.storage_file_path, 'w'))186 return result187class MongoStorage(Storage):188 def __init__(self, config):189 super().__init__(config)190 mongo_client = pymongo.MongoClient(config['host'], config['port'])191 self.db = mongo_client[config['database']]192 def set_field(self, collection_name, key, new_value, multi=False, **filter_options):193 return self.db[collection_name].update(filter_options, {'$set': {key: new_value}}, upsert=True, multi=multi)194 def get_field(self, collection_name, key, **filter_options):195 return self.db[collection_name].distinct(key, filter_options)196 def get_object(self, collection_name, filter_options, multi=False):197 if multi:198 return self.db[collection_name].find(filter_options)199 else:200 return self.db[collection_name].find_one(filter_options)201 def set_object(self, collection_name, new_object, filter_options, multi=False):202 return self.db[collection_name].update(filter_options, new_object, upsert=True, multi=multi)203 def remove_object(self, collection_name, filter_options, multi=False):204 if multi:205 return self.db[collection_name].delete_many(filter_options)206 else:...

Full Screen

Full Screen

_filter.py

Source:_filter.py Github

copy

Full Screen

1from _print import print_list2from _options_values import filter_values, filter_options3def massive_filter(wk_list, enable=False):4 """5 According to the selected filter options returns a filtered list of image files.6 :param list wk_list: List from _build_list().build_new_list7 :param enable: Enable/disable function8 :return: New filtered list or exit9 """10 if not enable:11 return 'filter not enabled'12 if not filter_options['size_on'] and \13 not filter_options['resolution_on'] and \14 not filter_options['len_on'] and \15 not filter_options['orient_on'] and \16 not filter_options['side_difference_on'] and \17 not filter_options['format_on'] and \18 not filter_options['mpx_on'] and \19 not filter_options['path_on'] and \20 not filter_options['search_word']:21 print_list(wk_list, 'All filters are OFF')22 return wk_list23 chk_sum = 0 # variable for sum of TURN ON filtres24 chk_count = 0 # variable for matching filters25 new_list = []26 for item in wk_list:27 if filter_options['size_on']:28 # if on, chk_sum are 1, and if filter matching, then chk_count 129 chk_sum += 130 if filter_values['size'][0] <= item['im_size'] <= filter_values['size'][1]:31 chk_count += 132 if filter_options['resolution_on']:33 chk_sum += 134 if (35 filter_values['width'][0] <= item['im_width'] <= filter_values['width'][1]36 ) and (37 filter_values['height'][0] <= item['im_height'] <= filter_values['height'][1]38 ):39 chk_count += 140 if filter_options['len_on']:41 chk_sum += 142 if item['im_name_len'] >= filter_values['name_min_len']:43 chk_count += 144 if filter_options['orient_on']:45 chk_sum += 146 if item['im_orient'] == filter_values['orientation']:47 chk_count += 148 if filter_options['side_difference_on']:49 chk_sum += 150 if filter_values['side_difference'][0] <= item['im_side_diff'] <= filter_values['side_difference'][1]:51 chk_count += 152 if filter_options['format_on']:53 chk_sum += 154 if item['im_format'].upper() == filter_values['format'].upper():55 chk_count += 156 if filter_options['mpx_on']:57 chk_sum += 158 if filter_values['mpx'][0] <= item['im_mpx'] <= filter_values['mpx'][1]:59 chk_count += 160 if filter_options['path_on']:61 chk_sum += 162 if filter_values['srch_path'] == item['im_path']:63 chk_count += 164 if filter_options['search_word']:65 chk_sum += 166 if filter_values['srch_word'].lower() in item['im_name'].lower():67 chk_count += 168 if chk_sum == chk_count:69 # if all enabled filtres == matching filtres, then add into list70 new_list.append(item)71 chk_sum, chk_count = 0, 0 # to null72 # str contains what enabled in filter for output73 what_enabled = "{:}{:}{:}{:}{:}{:}{:}{:}{:}".format(74 'Size,' * filter_options['size_on'],75 'Resolution,' * filter_options['resolution_on'],76 'Lenght,' * filter_options['len_on'],77 'Orientation,' * filter_options['orient_on'],78 'Side Difference,' * filter_options['side_difference_on'],79 'Format,' * filter_options['format_on'],80 'Mpx,' * filter_options['mpx_on'],81 'Path,' * filter_options['path_on'],82 'Word,' * filter_options['search_word']83 )84 print_list(new_list, 'Filtered List', 'FILTERS: ' + what_enabled[:-1])...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run molecule automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful