From b6443ab5720489268b0eff5f71994eb922aa1abc Mon Sep 17 00:00:00 2001 From: Mike Taves Date: Wed, 20 Nov 2019 23:11:17 +1300 Subject: [PATCH] fix(flake8 code F632): use '==' instead of 'is' * With MfList, check 'len(recs) == 0' instead of 'recs is 0' --- flopy/mf6/utils/binaryfile_utils.py | 4 ++-- flopy/mf6/utils/mfobservation.py | 10 +++++----- flopy/utils/gridintersect.py | 2 +- flopy/utils/util_array.py | 2 +- flopy/utils/util_list.py | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/flopy/mf6/utils/binaryfile_utils.py b/flopy/mf6/utils/binaryfile_utils.py index 538a5ad21b..32c0ffcedc 100644 --- a/flopy/mf6/utils/binaryfile_utils.py +++ b/flopy/mf6/utils/binaryfile_utils.py @@ -357,10 +357,10 @@ def _reshape_binary_data(data, dtype=None): data = np.array(data) if dtype is None: return data - elif dtype is 'V': + elif dtype == 'V': nodes = len(data[0][0][0]) data.shape = (time, -1, nodes) - elif dtype is 'U': + elif dtype == 'U': data.shape = (time, -1) else: err = "Invalid dtype flag supplied, valid are dtype='U', dtype='V'" diff --git a/flopy/mf6/utils/mfobservation.py b/flopy/mf6/utils/mfobservation.py index 73c75989da..8c81232cb4 100644 --- a/flopy/mf6/utils/mfobservation.py +++ b/flopy/mf6/utils/mfobservation.py @@ -304,16 +304,16 @@ def _get_datetime(self, times, start_dt, unit): # create list of datetimes t0 = dt.datetime(year, month, day, hour, minute, second) - if unit is 'Y': + if unit == 'Y': dtlist = [dt.datetime(int(year + time), month, day, hour, minute, second) for time in times] - elif unit is 'D': + elif unit == 'D': dtlist = [t0+dt.timedelta(days=time) for time in times] - elif unit is 'H': + elif unit == 'H': dtlist = [t0+dt.timedelta(hours=time) for time in times] - elif unit is 'M': + elif unit == 'M': dtlist = [t0+dt.timedelta(minutes=time) for time in times] - elif unit is 'S': + elif unit == 'S': dtlist = [t0+dt.timedelta(seconds=time) for time in times] else: raise TypeError('invalid time unit supplied') diff --git a/flopy/utils/gridintersect.py b/flopy/utils/gridintersect.py index 56670c1373..047fd74798 100644 --- a/flopy/utils/gridintersect.py +++ b/flopy/utils/gridintersect.py @@ -567,7 +567,7 @@ def _intersect_linestring_structured(self, shp, keepzerolengths=False): return np.recarray(0, names=["cellids", "vertices", "lengths", "ixshapes"], formats=["O", "O", "f8", "O"]) - if lineclip.geom_type is 'MultiLineString': # there are multiple lines + if lineclip.geom_type == 'MultiLineString': # there are multiple lines nodelist, lengths, vertices = [], [], [] ixshapes = [] for ls in lineclip: diff --git a/flopy/utils/util_array.py b/flopy/utils/util_array.py index aafa4f7f9c..eaf7612006 100644 --- a/flopy/utils/util_array.py +++ b/flopy/utils/util_array.py @@ -2081,7 +2081,7 @@ def _get_fixed_cr(self, locat, value=None): locat = -1 * np.abs(locat) if locat is None: locat = 0 - if locat is 0: + if locat == 0: fformat = '' if self.dtype == np.int32: cr = '{0:>10.0f}{1:>10.0f}{2:>19s}{3:>10.0f} #{4}\n' \ diff --git a/flopy/utils/util_list.py b/flopy/utils/util_list.py index 3caec93c33..9c73a4b750 100644 --- a/flopy/utils/util_list.py +++ b/flopy/utils/util_list.py @@ -453,9 +453,9 @@ def get_dataframe(self, squeeze=True): dfs = [] for per in self.data.keys(): recs = self.data[per] - if recs is None or recs is 0: + if recs is None or len(recs) == 0: # add an empty dataframe if a stress period is - # set to 0 (e.g. no pumping during a predevelopment + # empty (e.g. no pumping during a predevelopment # period) columns = names + list(['{}{}'.format(c, per) for c in varnames])