diff --git a/src/pydrex/io.py b/src/pydrex/io.py index 244ad5aa..6f7b133b 100644 --- a/src/pydrex/io.py +++ b/src/pydrex/io.py @@ -425,7 +425,7 @@ def save_scsv(file, schema, data, **kwargs): f"invalid data for column '{names[i]}'." + f" Cannot parse {d} as type '{t.__qualname__}'." ) from None - if t == bool: + if isinstance(t, bool): row.append(d) elif t in (float, complex): if np.isnan(d) and np.isnan(t(f)): @@ -747,7 +747,7 @@ def _parse_scsv_cell(func, data, missingstr=None, fillval=None): if fillval == "NaN": return func(np.nan) return func(fillval) - elif func == bool: + elif func.__qualname__ == "bool": return _parse_scsv_bool(data) return func(data.strip()) diff --git a/src/pydrex/mesh.py b/src/pydrex/mesh.py index 9fca15dd..60a54abe 100644 --- a/src/pydrex/mesh.py +++ b/src/pydrex/mesh.py @@ -259,7 +259,7 @@ def rectangle( custom_constraints = kwargs.pop("custom_constraints", None) if custom_constraints is not None: - dummy_index = ({0, 1, 2} - set([h, v])).pop() + dummy_index = ({0, 1, 2} - {h, v}).pop() indices, constraints = custom_constraints point_constraints = np.insert( point_constraints, diff --git a/tests/conftest.py b/tests/conftest.py index cd3f0de9..479a23fc 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -159,7 +159,7 @@ def named_tempfile_kwargs(request): if sys.platform == "win32": return {"delete": False} else: - return dict() + return {} @pytest.fixture(scope="session") diff --git a/tests/test_doctests.py b/tests/test_doctests.py index 21c0c45c..04c9353f 100644 --- a/tests/test_doctests.py +++ b/tests/test_doctests.py @@ -57,12 +57,12 @@ def test_doctests(module, capsys, verbose): else: lineno = f":{e.test.lineno + 1 + e.example.lineno}" err_type, err, _ = e.exc_info - if err_type == NameError: # Raised on missing optional functions. + if err_type is NameError: # Raised on missing optional functions. # Issue warning but let the test suite pass. _log.warning( "skipping doctest of missing optional symbol in %s", module ) - elif err_type == np.core._exceptions._ArrayMemoryError: + elif err_type is np.core._exceptions._ArrayMemoryError: # Faiures to allocate should not be fatal to the doctest test suite. _log.warning( "skipping doctests for module %s due to insufficient memory", module diff --git a/tests/test_simple_shear_2d.py b/tests/test_simple_shear_2d.py index f2763e44..7abc8bb1 100644 --- a/tests/test_simple_shear_2d.py +++ b/tests/test_simple_shear_2d.py @@ -2,7 +2,6 @@ import contextlib as cl import functools as ft -import sys from time import process_time import numpy as np diff --git a/tests/test_simple_shear_3d.py b/tests/test_simple_shear_3d.py index ddd32f67..5be8d304 100644 --- a/tests/test_simple_shear_3d.py +++ b/tests/test_simple_shear_3d.py @@ -19,9 +19,9 @@ Pool, HAS_RAY = _utils.import_proc_pool() if HAS_RAY: - import ray + import ray # noqa: F401 - from pydrex import distributed as _dstr + from pydrex import distributed as _dstr # noqa: F401 # Subdirectory of `outdir` used to store outputs from these tests. SUBDIR = "3d_simple_shear" @@ -192,7 +192,10 @@ def test_direction_change( ] ) olA_downsampled, _ = _stats.resample_orientations( - olivine.orientations, olivine.fractions, seed=_seeds[s], n_samples=1000 + olivine.orientations, + olivine.fractions, + seed=_seeds[s], + n_samples=1000, ) olA_strength[s, :] = _diagnostics.misorientation_indices( olA_downsampled, _geo.LatticeSystem.orthorhombic, pool=pool @@ -223,7 +226,10 @@ def test_direction_change( ] ) ens_downsampled, _ = _stats.resample_orientations( - enstatite.orientations, enstatite.fractions, seed=_seeds[s], n_samples=1000 + enstatite.orientations, + enstatite.fractions, + seed=_seeds[s], + n_samples=1000, ) ens_strength[s, :] = _diagnostics.misorientation_indices( ens_downsampled, _geo.LatticeSystem.orthorhombic, pool=pool