From b22d04db47c547270df9686154f60a39ac1a6d79 Mon Sep 17 00:00:00 2001 From: Marcel Date: Mon, 16 Jul 2018 13:52:28 +0200 Subject: [PATCH] [cleanup] replace equality by "is" --- autoPyLoT.py | 4 ++-- pylot/core/analysis/magnitude.py | 2 +- pylot/core/io/data.py | 4 ++-- pylot/core/io/phases.py | 2 +- pylot/core/pick/autopick.py | 2 +- pylot/core/pick/picker.py | 8 ++++---- pylot/core/util/dataprocessing.py | 4 ++-- pylot/core/util/utils.py | 2 +- pylot/core/util/widgets.py | 6 +++--- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/autoPyLoT.py b/autoPyLoT.py index f253d420..2e07efe4 100755 --- a/autoPyLoT.py +++ b/autoPyLoT.py @@ -369,7 +369,7 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even net_ml = local_mag.net_magnitude(magscaling) if net_ml: print("Network local magnitude: %4.1f" % net_ml.mag) - if magscaling == None: + if magscaling is None: scaling = False elif magscaling[0] != 0 and magscaling[1] != 0: scaling = False @@ -454,7 +454,7 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even net_ml = local_mag.net_magnitude(magscaling) if net_ml: print("Network local magnitude: %4.1f" % net_ml.mag) - if magscaling == None: + if magscaling is None: scaling = False elif magscaling[0] != 0 and magscaling[1] != 0: scaling = False diff --git a/pylot/core/analysis/magnitude.py b/pylot/core/analysis/magnitude.py index cd1fe257..0a7e74ed 100644 --- a/pylot/core/analysis/magnitude.py +++ b/pylot/core/analysis/magnitude.py @@ -122,7 +122,7 @@ class Magnitude(object): def net_magnitude(self, magscaling=None): if self: - if magscaling == None: + if magscaling is None: scaling = False elif magscaling[0] != 0 and magscaling[1] != 0: scaling = False diff --git a/pylot/core/io/data.py b/pylot/core/io/data.py index 176f76ac..c6d99354 100644 --- a/pylot/core/io/data.py +++ b/pylot/core/io/data.py @@ -299,7 +299,7 @@ class Data(object): for i in range(len(picks_copy)): if picks_copy[i].phase_hint[0] == 'P': if (picks_copy[i].time_errors['upper_uncertainty'] >= upperErrors[0]) or \ - (picks_copy[i].time_errors['uncertainty'] == None): + (picks_copy[i].time_errors['uncertainty'] is None): print("Uncertainty exceeds or equal adjusted upper time error!") print("Adjusted uncertainty: {}".format(upperErrors[0])) print("Pick uncertainty: {}".format(picks_copy[i].time_errors['uncertainty'])) @@ -311,7 +311,7 @@ class Data(object): break if picks_copy[i].phase_hint[0] == 'S': if (picks_copy[i].time_errors['upper_uncertainty'] >= upperErrors[1]) or \ - (picks_copy[i].time_errors['uncertainty'] == None): + (picks_copy[i].time_errors['uncertainty'] is None): print("Uncertainty exceeds or equal adjusted upper time error!") print("Adjusted uncertainty: {}".format(upperErrors[1])) print("Pick uncertainty: {}".format(picks_copy[i].time_errors['uncertainty'])) diff --git a/pylot/core/io/phases.py b/pylot/core/io/phases.py index fa0e7587..ea14f548 100644 --- a/pylot/core/io/phases.py +++ b/pylot/core/io/phases.py @@ -499,7 +499,7 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None): except KeyError as e: print(e) fm = None - if fm == None: + if fm is None: fm = '?' onset = arrivals[key]['P']['mpp'] year = onset.year diff --git a/pylot/core/pick/autopick.py b/pylot/core/pick/autopick.py index 7f48b6bc..d7bc487d 100644 --- a/pylot/core/pick/autopick.py +++ b/pylot/core/pick/autopick.py @@ -90,7 +90,7 @@ def autopickevent(data, param, iplot=0, fig_dict=None, fig_dict_wadatijack=None, if type(result) == dict: all_onsets[station] = result else: - if result == None: + if result is None: result = 'Picker exited unexpectedly.' print('Could not pick a station: {}\nReason: {}'.format(station, result)) diff --git a/pylot/core/pick/picker.py b/pylot/core/pick/picker.py index 952c47db..0ef817a2 100644 --- a/pylot/core/pick/picker.py +++ b/pylot/core/pick/picker.py @@ -291,7 +291,7 @@ class AICPicker(AutoPicker): print("AICPicker: Maximum for slope determination right at the beginning of the window!") print("Choose longer slope determination window!") if self.iplot > 1: - if self.fig == None or self.fig == 'None': + if self.fig is None or self.fig == 'None': fig = plt.figure() plt_flag = iplot else: @@ -337,7 +337,7 @@ class AICPicker(AutoPicker): self.slope = None if iplot > 1: - if self.fig == None or self.fig == 'None': + if self.fig is None or self.fig == 'None': fig = plt.figure() # self.iplot) plt_flag = iplot else: @@ -392,7 +392,7 @@ class AICPicker(AutoPicker): netstlc = '{}.{}.{}'.format(stats.network, stats.station, stats.location) fig.savefig('aicfig_{}_{}.png'.format(netstlc, stats.channel)) - if self.Pick == None: + if self.Pick is None: print('AICPicker: Could not find minimum, picking window too short?') return @@ -509,7 +509,7 @@ class PragPicker(AutoPicker): pickflag = 0 if iplot > 1: - if self.fig == None or self.fig == 'None': + if self.fig is None or self.fig == 'None': fig = plt.figure() # self.getiplot()) plt_flag = 1 else: diff --git a/pylot/core/util/dataprocessing.py b/pylot/core/util/dataprocessing.py index 491cfa37..a002bc75 100644 --- a/pylot/core/util/dataprocessing.py +++ b/pylot/core/util/dataprocessing.py @@ -148,7 +148,7 @@ class Metadata(object): try: invtype, robj = self._read_metadata_file(inv_fname) - if robj == None: + if robj is None: return except Exception as e: print('Could not read file {}'.format(inv_fname)) @@ -545,7 +545,7 @@ def restitute_trace(input_tuple): else: finv = invlist[0] inventory = read_inventory(finv, format='STATIONXML') - elif invtype == None: + elif invtype is None: return no_metadata(tr, seed_id) else: remove_trace = True diff --git a/pylot/core/util/utils.py b/pylot/core/util/utils.py index 80ef5d84..9dc73fcb 100644 --- a/pylot/core/util/utils.py +++ b/pylot/core/util/utils.py @@ -1110,7 +1110,7 @@ def loopIdentifyPhase(phase): """ from pylot.core.util.defaults import ALTSUFFIX - if phase == None: + if phase is None: raise NameError('Can not identify phase that is None') phase_copy = phase diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index 44506cb1..fbcb8b4c 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -2421,7 +2421,7 @@ class PickDlg(QDialog): if not x: return allpicks, pick_rel, phase, picktype = self.identify_selected_picks(x) - if pick_rel == None: + if pick_rel is None: return pick = allpicks[picktype][phase] message = '{} {}-pick'.format(picktype, phase) @@ -2442,7 +2442,7 @@ class PickDlg(QDialog): return x = event.mouseevent.xdata allpicks, pick_rel, phase, picktype = self.identify_selected_picks(x) - if pick_rel == None: + if pick_rel is None: return pick = allpicks[picktype][phase] message = '{} {}-pick'.format(picktype, phase) @@ -2499,7 +2499,7 @@ class PickDlg(QDialog): if not self.picks and not self.autopicks: return allpicks, pick_rel, phase, picktype = self.identify_selected_picks(x) - if pick_rel == None: + if pick_rel is None: return # delete the value from corresponding dictionary allpicks[picktype].pop(phase)