diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4ab01b0b..7ab2dbd8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,10 +26,10 @@ repos: rev: 7.1.1 hooks: - id: flake8 - # additional_dependencies: + additional_dependencies: # - flake8-bugbear - # - flake8-comprehensions - # - flake8-simplify + - flake8-comprehensions + - flake8-simplify exclude: ^docs/source/pyplots/guides/.*$ - repo: https://github.com/asottile/pyupgrade diff --git a/deltametrics/io.py b/deltametrics/io.py index 1e393802..769f401c 100644 --- a/deltametrics/io.py +++ b/deltametrics/io.py @@ -330,7 +330,7 @@ def __getitem__(self, var): @property def keys(self): """Variable names in file.""" - return [var for var in self.dataset.variables] + return list(self.dataset.variables) class DictionaryIO(BaseIO): @@ -364,7 +364,7 @@ def get_known_variables(self): These variables are pulled from the loaded dataset. """ _vars = self.dataset.keys() - self.known_variables = [item for item in _vars] + self.known_variables = list(_vars) def get_known_coords(self, dimensions): """List known coordinates. @@ -462,4 +462,4 @@ def __getitem__(self, var): @property def keys(self): """Variable names in file.""" - return [var for var in self.dataset.variables] + return list(self.dataset.variables) diff --git a/deltametrics/mask.py b/deltametrics/mask.py index 78c68f85..63531ad4 100644 --- a/deltametrics/mask.py +++ b/deltametrics/mask.py @@ -1594,12 +1594,10 @@ def grab_contour(self, arr, shoremap): # breakpoint() # convert contour to the shoreline mask itself - flat_inds = list( - map( - lambda x: np.ravel_multi_index(x, shoremap.shape), - np.round(C).astype(int), - ) - ) + flat_inds = [ + np.ravel_multi_index(x, shoremap.shape) + for x in np.round(C).astype(int) + ] shoremap.flat[flat_inds] = 1 self._contour = C diff --git a/deltametrics/utils.py b/deltametrics/utils.py index f7681aed..0426fbff 100644 --- a/deltametrics/utils.py +++ b/deltametrics/utils.py @@ -117,7 +117,7 @@ def _attribute_checker(self, checklist): else: att_dict[check] = True - log_list = [value for value in att_dict.values()] + log_list = list(att_dict.values()) log_form = [value for string, value in zip(log_list, att_dict.keys()) if not string] if not all(log_list): diff --git a/tests/test_mask.py b/tests/test_mask.py index a79d4323..c85f655c 100644 --- a/tests/test_mask.py +++ b/tests/test_mask.py @@ -1707,7 +1707,7 @@ def test_circular_default(self): gmsk.circular(1) assert gmsk._mask[0, 2] == 0 - gmsk2 = GeometricMask(arr, circular=dict(rad1=1)) + gmsk2 = GeometricMask(arr, circular={"rad1": 1}) assert np.all(gmsk2.mask == gmsk.mask) def test_circular_2radii(self): @@ -1720,7 +1720,7 @@ def test_circular_2radii(self): assert np.all(gmsk._mask[:, 0] == 0) assert np.all(gmsk._mask[-1, :] == 0) - gmsk2 = GeometricMask(arr, circular=dict(rad1=1, rad2=2)) + gmsk2 = GeometricMask(arr, circular={"rad1": 1, "rad2": 2}) assert np.all(gmsk2.mask == gmsk.mask) def test_circular_custom_origin(self): @@ -1750,7 +1750,7 @@ def test_circular_custom_origin(self): assert gmsk.xc == 0 assert gmsk.yc == 3 - gmsk2 = GeometricMask(arr, circular=dict(rad1=1, rad2=2, origin=(3, 3))) + gmsk2 = GeometricMask(arr, circular={"rad1": 1, "rad2": 2, "origin": (3, 3)}) assert np.all(gmsk2.mask == gmsk.mask) def test_strike_one(self): @@ -1761,7 +1761,7 @@ def test_strike_one(self): assert np.all(gmsk._mask[:2, :] == 0) assert np.all(gmsk._mask[2:, :] == 1) - gmsk2 = GeometricMask(arr, strike=dict(ind1=2)) + gmsk2 = GeometricMask(arr, strike={"ind1": 2}) assert np.all(gmsk2.mask == gmsk.mask) def test_strike_two(self): @@ -1773,7 +1773,7 @@ def test_strike_two(self): assert np.all(gmsk._mask[2:4, :] == 1) assert np.all(gmsk._mask[4:, :] == 0) - gmsk2 = GeometricMask(arr, strike=dict(ind1=2, ind2=4)) + gmsk2 = GeometricMask(arr, strike={"ind1": 2, "ind2": 4}) assert np.all(gmsk2.mask == gmsk.mask) def test_dip_one(self): @@ -1785,7 +1785,7 @@ def test_dip_one(self): assert np.all(gmsk._mask[:, 0] == 0) assert np.all(gmsk._mask[:, -1] == 0) - gmsk2 = GeometricMask(arr, dip=dict(ind1=5)) + gmsk2 = GeometricMask(arr, dip={"ind1": 5}) assert np.all(gmsk2.mask == gmsk.mask) def test_dip_two(self): @@ -1797,7 +1797,7 @@ def test_dip_two(self): assert np.all(gmsk._mask[:, 2:4] == 1) assert np.all(gmsk._mask[:, 4:] == 0) - gmsk2 = GeometricMask(arr, dip=dict(ind1=2, ind2=4)) + gmsk2 = GeometricMask(arr, dip={"ind1": 2, "ind2": 4}) assert np.all(gmsk2.mask == gmsk.mask) def test_angular_half(self): @@ -1811,7 +1811,7 @@ def test_angular_half(self): assert np.all(gmsk._mask[:, :101] == 1) assert np.all(gmsk._mask[:, 101:] == 0) - gmsk2 = GeometricMask(arr, angular=dict(theta1=theta1, theta2=theta2)) + gmsk2 = GeometricMask(arr, angular={"theta1": theta1, "theta2": theta2}) assert np.all(gmsk2.mask == gmsk.mask) def test_angular_bad_dims(self):