Skip to content

Commit

Permalink
Removed pyupgrade since it is contained in ruff (#72)
Browse files Browse the repository at this point in the history
Fixed some minor issues
  • Loading branch information
david-zwicker authored Nov 26, 2024
1 parent 4d94664 commit 787c822
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion droplets/emulsions.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def data(self) -> np.ndarray:
if len(classes) > 1:
raise TypeError(
"Emulsion data cannot be stored contiguously if it contains a "
f"multiple of droplet classes: "
"multiple of droplet classes: "
+ ", ".join(c.__name__ for c in classes)
)
result = np.array([d.data for d in self])
Expand Down
4 changes: 2 additions & 2 deletions droplets/tools/spherical.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def make_volume_from_radius_nd_compiled() -> Callable[[TNumArr, int], TNumArr]:
"""

@register_jitable
def volume_from_radius(radius: TNumArr, dim: int) -> TNumArr:
def volume_from_radius_impl(radius: TNumArr, dim: int) -> TNumArr:
if dim == 1:
return 2 * radius
elif dim == 2:
Expand All @@ -208,7 +208,7 @@ def volume_from_radius(radius: TNumArr, dim: int) -> TNumArr:
return 4 * π / 3 * radius**3
raise NotImplementedError

return volume_from_radius # type: ignore
return volume_from_radius_impl # type: ignore


def surface_from_radius(radius: TNumArr, dim: int) -> TNumArr:
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ select = [
"I", # isort
"A", # flake8-builtins
"B", # flake8-bugbear
"F", # pyflakes
"C4", # flake8-comprehensions
"FA", # flake8-future-annotations
"ISC", # flake8-implicit-str-concat
Expand All @@ -86,7 +87,7 @@ select = [
"SIM", # flake8-simplify
"PTH", # flake8-use-pathlib
]
ignore = ["B007", "B027", "B028", "SIM108", "ISC001", "PT006", "PT011", "RET504", "RET505", "RET506"]
ignore = ["B007", "B027", "B028", "F401", "F403", "SIM108", "ISC001", "PT006", "PT011", "RET504", "RET505", "RET506"]

[tool.ruff.lint.isort]
section-order = ["future", "standard-library", "third-party", "first-party", "my-modules", "self", "local-folder"]
Expand Down
11 changes: 3 additions & 8 deletions scripts/format_code.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
#!/usr/bin/env bash
# This script formats the code of this package

echo "Upgrading python syntax..."
pushd .. > /dev/null
find . -name '*.py' -exec pyupgrade --py39-plus {} +
popd > /dev/null

echo "Formating import statements..."
echo "Formatting import statements..."
ruff check --fix --config=../pyproject.toml ..

echo "Formating docstrings..."
echo "Formatting docstrings..."
docformatter --in-place --black --recursive ..

echo "Formating source code..."
echo "Formatting source code..."
ruff format --config=../pyproject.toml ..
1 change: 0 additions & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
-r ../requirements.txt
docformatter>=1.7
pyupgrade>=3
pytest>=5.4
pytest-cov>=2.8
pytest-xdist>=1.30
Expand Down
4 changes: 2 additions & 2 deletions tests/test_image_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def test_localization_perturbed_2d(periodic, rng):
assert len(emulsion) == 1
d2 = emulsion[0]

msg = "size=%d, periodic=%s, %s != %s" % (size, periodic, d1, d2)
msg = f"{size=}, {periodic=}, {d1} != {d2}"
np.testing.assert_almost_equal(d1.position, d2.position, decimal=1, err_msg=msg)
assert d1.radius == pytest.approx(d2.radius, rel=1e-5)
assert d1.interface_width == pytest.approx(d2.interface_width, rel=1e-3)
Expand Down Expand Up @@ -129,7 +129,7 @@ def test_localization_perturbed_3d(periodic, rng):
assert len(emulsion) == 1
d2 = emulsion[0]

msg = "size=%d, periodic=%s, %s != %s" % (size, periodic, d1, d2)
msg = f"{size=}, {periodic=}, {d1} != {d2}"
np.testing.assert_almost_equal(d1.position, d2.position, decimal=1, err_msg=msg)
assert d1.radius == pytest.approx(d2.radius, rel=1e-4)
assert d1.interface_width == pytest.approx(d2.interface_width, rel=1e-3)
Expand Down

0 comments on commit 787c822

Please sign in to comment.