Skip to content

Commit

Permalink
chore(deps): cleanup dev deps (#209)
Browse files Browse the repository at this point in the history
* chore(deps): cleanup dev deps

* fix(ci): run clippy on stable toolchain

* fix(tests): update

* fix(tests): atol on macOS

* chore(deps): relax constraint on Equinox (and JAX)
  • Loading branch information
jeertmans authored Feb 11, 2025
1 parent 235be1c commit 9fdbc7e
Show file tree
Hide file tree
Showing 13 changed files with 1,688 additions and 2,399 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,15 @@ jobs:
with:
enable-cache: true

- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
components: clippy

- name: Install Rust nightly
uses: dtolnay/rust-toolchain@nightly
with:
components: clippy,rustfmt
components: rustfmt

- name: Install dependencies
run: uv sync
Expand Down
2 changes: 1 addition & 1 deletion differt-core/src/geometry/triangle_mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ impl TriangleMesh {
}),
);
},
name => log::info!("Unexpeced element: {name}, skipping."),
name => log::info!("Unexpected element: {name}, skipping."),
}
}

Expand Down
8 changes: 4 additions & 4 deletions differt/src/differt/em/_antenna.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,8 @@ def directivity(
:meth:`directive_gain`
"""
u, du = jnp.linspace(0, 2 * jnp.pi, num_points * 2, retstep=True)
v, dv = jnp.linspace(0, jnp.pi, num_points, retstep=True)
u, _du = jnp.linspace(0, 2 * jnp.pi, num_points * 2, retstep=True)
v, _dv = jnp.linspace(0, jnp.pi, num_points, retstep=True)
x = jnp.outer(jnp.cos(u), jnp.sin(v))
y = jnp.outer(jnp.sin(u), jnp.sin(v))
z = jnp.outer(jnp.ones_like(u), jnp.cos(v))
Expand Down Expand Up @@ -637,11 +637,11 @@ def polarization_vectors(
cos_theta = dot(r_hat, self.direction)
sin_theta = jnp.sqrt(1 - cos_theta**2)

d = 1.640922376984585 # Directive gain: 4 / Cin(2*pi)
_d = 1.640922376984585 # Directive gain: 4 / Cin(2*pi)

cos_theta = dot() # type: ignore
sin_theta = jnp.sin() # type: ignore
d = safe_divide(jnp.cos(0.5 * jnp.pi * cos_theta), sin_theta)
_d = safe_divide(jnp.cos(0.5 * jnp.pi * cos_theta), sin_theta)


class ShortDipolePattern(RadiationPattern):
Expand Down
22 changes: 11 additions & 11 deletions differt/src/differt/geometry/_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,23 +370,23 @@ def group_by_objects(self) -> Int[Array, " *batch"]:
>>> vertices = jax.random.uniform(key_v, (*batch, path_length, 3))
>>> objects = jax.random.randint(key_o, (*batch, path_length), 0, 2)
>>> objects
Array([[[1, 0, 0],
[1, 0, 0],
[0, 1, 1],
Array([[[1, 1, 0],
[0, 0, 1],
[1, 0, 1],
[0, 1, 0],
[0, 1, 1]],
[[1, 0, 1],
[0, 0, 0],
[0, 0, 0],
[1, 0, 0],
[1, 1, 1],
[1, 1, 1]],
[[1, 0, 0],
[1, 1, 1],
[0, 0, 1],
[1, 1, 0],
[0, 0, 1],
[0, 1, 1]]], dtype=int32)
[1, 0, 0]]], dtype=int32)
>>> paths = Paths(vertices, objects)
>>> groups = paths.group_by_objects()
>>> groups
Array([[ 0, 0, 2, 3, 4, 2],
[ 3, 7, 7, 9, 10, 2]], dtype=int32)
Array([[0, 1, 2, 3, 4, 4],
[3, 4, 1, 0, 1, 3]], dtype=int32)
"""
*batch, path_length = self.objects.shape

Expand Down
28 changes: 14 additions & 14 deletions differt/src/differt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ def sorted_array2(array: Shaped[Array, "m n"]) -> Shaped[Array, "m n"]:
... ) = jax.random.split(key, 2)
>>> arr = jax.random.permutation(key1, arr)
>>> arr
Array([[4, 5],
[8, 9],
Array([[6, 7],
[0, 1],
[2, 3],
[6, 7]], dtype=int32)
[8, 9],
[4, 5],
[2, 3]], dtype=int32)
>>>
>>> sorted_array2(arr)
Array([[0, 1],
Expand All @@ -108,18 +108,18 @@ def sorted_array2(array: Shaped[Array, "m n"]) -> Shaped[Array, "m n"]:
... 2,
... )
>>> arr
Array([[1, 1, 1, 0, 1],
[1, 0, 1, 1, 1],
[1, 0, 0, 1, 1],
[1, 0, 0, 0, 0],
[1, 1, 0, 1, 0]], dtype=int32)
Array([[1, 1, 0, 0, 0],
[1, 1, 0, 1, 1],
[0, 0, 1, 1, 1],
[1, 1, 1, 1, 0],
[0, 1, 1, 1, 0]], dtype=int32)
>>>
>>> sorted_array2(arr)
Array([[1, 0, 0, 0, 0],
[1, 0, 0, 1, 1],
[1, 0, 1, 1, 1],
[1, 1, 0, 1, 0],
[1, 1, 1, 0, 1]], dtype=int32)
Array([[0, 0, 1, 1, 1],
[0, 1, 1, 1, 0],
[1, 1, 0, 0, 0],
[1, 1, 0, 1, 1],
[1, 1, 1, 1, 0]], dtype=int32)
"""
if array.size == 0:
return array
Expand Down
9 changes: 5 additions & 4 deletions differt/tests/em/test_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
)
def test_constants(constant_name: str, value: float | None) -> None:
got = getattr(_constants, constant_name)
if value:
assert abs(got - value) < 1e-6
else:
assert got == getattr(scipy.constants, constant_name)
expected: float = (
value if value is not None else getattr(scipy.constants, constant_name)
)

assert abs(got - expected) < 1e-6
4 changes: 1 addition & 3 deletions differt/tests/geometry/test_triangle_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,7 @@ def test_plot(self, sphere_mesh: TriangleMesh) -> None:
def test_sample(self, two_buildings_mesh: TriangleMesh, key: PRNGKeyArray) -> None:
assert two_buildings_mesh.sample(10, key=key).num_triangles == 10

with pytest.raises(
ValueError, match="Cannot take a larger sample than population"
):
with pytest.raises(ValueError, match="Cannot take a larger sample"):
assert two_buildings_mesh.sample(30, key=key)

assert two_buildings_mesh.sample(30, replace=True, key=key).num_triangles == 30
Expand Down
2 changes: 1 addition & 1 deletion differt/tests/geometry/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def test_cartesian_to_spherial_roundtrip(key: PRNGKeyArray) -> None:
sph = cartesian_to_spherical(xyz)
got = spherical_to_cartesian(sph)

chex.assert_trees_all_close(got, xyz, atol=1e-5)
chex.assert_trees_all_close(got, xyz, atol=2e-5)

key_r, key_polar, key_azim = jax.random.split(key_sph, 3)

Expand Down
12 changes: 10 additions & 2 deletions differt/tests/plotting/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ def test_draw_contour(
if (backend == "vispy" and (fill or isinstance(levels, int))) or (
backend == "plotly" and isinstance(levels, np.ndarray)
):
expectation = pytest.warns(UserWarning)
expectation = pytest.warns(
UserWarning,
match=f"{'VisPy' if backend == 'vispy' else 'Plotly'} does not support",
)
else:
expectation = does_not_raise()

Expand Down Expand Up @@ -162,7 +165,12 @@ def test_draw_surface(
Z = X * Y # noqa: N806

if backend in {"vispy", "matplotlib"} and pass_colors:
expectation = pytest.warns(UserWarning)
expectation = pytest.warns(
UserWarning,
match="VisPy does not currently support coloring like we would like"
if backend == "vispy"
else "Matplotlib requires 'colors' to be RGB or RGBA values",
)
else:
expectation = does_not_raise()

Expand Down
6 changes: 3 additions & 3 deletions differt/tests/rt/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ def test_rays_intersect_any_triangle(
@pytest.mark.parametrize(
("vertex", "expected_number"),
[
(jnp.array([4.0, 0.0, 0.0]), 2), # Sees one face of the cude
(jnp.array([4.0, 4.0, 0.0]), 4), # Sees two faces
(jnp.array([4.0, 4.0, 4.0]), 6), # Sees three faces
(jnp.array([2.0, 0.0, 0.0]), 2), # Sees one face of the cude
(jnp.array([2.0, 2.0, 0.0]), 4), # Sees two faces
(jnp.array([2.0, 2.0, 2.0]), 6), # Sees three faces
],
)
@pytest.mark.parametrize(
Expand Down
5 changes: 0 additions & 5 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,3 @@ test-python *ARGS:
[group('test')]
test-rust *ARGS:
cargo test {{ ARGS }}

# Run jupyter-lab with a server that supports reconnecting to running sessions
[group('dev')]
remote-jupyter *ARGS:
uv run --extra remote-jupyter jupyverse --set kernels.require_yjs=true --set jupyterlab.server_side_execution=true --set auth.mode=noauth {{ ARGS }}
20 changes: 13 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version = "1.0.0"

[project.optional-dependencies]
cuda = [
"jax[cuda]>=0.4.32",
"jax[cuda]>=0.5.0",
]
docs = [
"differt[all]",
Expand All @@ -32,15 +32,11 @@ icmlcn2025 = [
prof = [
"line-profiler[ipython]>=4.1.3",
]
remote-jupyter = [
# This makes sure cell outputs and widgets are kept, see https://github.com/jupyterlab/jupyter-collaboration/pull/279
"jupyterlab>=4.2",
"jupyverse[auth,jupyterlab]>=0.4.2",
]
tests = [
"differt[all]",
"beartype>=0.19.0",
"chex>=0.1.84",
"jax>=0.5.0", # Random number output has changed between 0.4 and 0.5
"pytest>=7.4.3",
"pytest-benchmark>=4.0.0",
"pytest-codspeed>=2.2.0",
Expand Down Expand Up @@ -243,12 +239,22 @@ extend-ignore-names = ["T"]
convention = "google"

[tool.uv]
conflicts = [
[
{extra = "cuda"},
{extra = "tests-extended"},
],
]
dev-dependencies = [
"differt_dev[docs,tests]",
"differt-dev[docs,tests]",
"bump-my-version>=0.20.3",
"maturin-import-hook>=0.2.0",
"pre-commit>=3.5.0",
]
override-dependencies = [
"tensorflow>=2.18,<2.19", # To support NumPy 2
]
required-version = ">=0.5.26" # See: https://github.com/astral-sh/uv/pull/11075

[tool.uv.sources]
differt = {workspace = true}
Expand Down
Loading

0 comments on commit 9fdbc7e

Please sign in to comment.