Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure pre-commit hooks pass #205

Merged
merged 2 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/pydrex/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down Expand Up @@ -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())

Expand Down
2 changes: 1 addition & 1 deletion src/pydrex/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def named_tempfile_kwargs(request):
if sys.platform == "win32":
return {"delete": False}
else:
return dict()
return {}


@pytest.fixture(scope="session")
Expand Down
4 changes: 2 additions & 2 deletions tests/test_doctests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion tests/test_simple_shear_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import contextlib as cl
import functools as ft
import sys
from time import process_time

import numpy as np
Expand Down
14 changes: 10 additions & 4 deletions tests/test_simple_shear_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down