Skip to content

Commit

Permalink
Change ruff version so lint test can pass
Browse files Browse the repository at this point in the history
  • Loading branch information
han-ol committed Feb 13, 2025
1 parent dac7e9b commit 50e01b1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.4.9
rev: v0.9.6
hooks:
# Run the linter.
- id: ruff
Expand All @@ -28,7 +28,7 @@ repos:
# - id: nbqa-ruff
# args: [--ignore=E402] # E402: module level import not at top of file
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
# A bunch of other pre-defined hooks.
- id: check-yaml
Expand Down
6 changes: 3 additions & 3 deletions bayesflow/links/ordered.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def get_config(self):
def build(self, input_shape):
super().build(input_shape)

assert (
self.anchor_index % input_shape[self.axis] != 0 and self.anchor_index != -1
), "anchor should not be first or last index."
assert self.anchor_index % input_shape[self.axis] != 0 and self.anchor_index != -1, (
"anchor should not be first or last index."
)
self.group_indeces = dict(
below=list(range(0, self.anchor_index)),
above=list(range(self.anchor_index + 1, input_shape[self.axis])),
Expand Down
12 changes: 6 additions & 6 deletions tests/test_links/test_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ def check_ordering(output, axis):
assert np.all(np.diff(output, axis=axis) > 0), f"is not ordered along specified axis: {axis}."
for i in range(output.ndim):
if i != axis % output.ndim:
assert not np.all(
np.diff(output, axis=i) > 0
), f"is ordered along axis which is not meant to be ordered: {i}."
assert not np.all(np.diff(output, axis=i) > 0), (
f"is ordered along axis which is not meant to be ordered: {i}."
)


@pytest.mark.parametrize("axis", [0, 1, 2])
Expand Down Expand Up @@ -66,6 +66,6 @@ def test_positive_semi_definite(random_matrix_batch):

eigenvalues = np.linalg.eig(output).eigenvalues

assert np.all(eigenvalues.real > 0) and np.all(
np.isclose(eigenvalues.imag, 0)
), f"output is not positive semi-definite: real={eigenvalues.real}, imag={eigenvalues.imag}"
assert np.all(eigenvalues.real > 0) and np.all(np.isclose(eigenvalues.imag, 0)), (
f"output is not positive semi-definite: real={eigenvalues.real}, imag={eigenvalues.imag}"
)
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ def test_save_and_load(tmp_path, point_inference_network, random_samples, random

for key_outer in out1.keys():
for key_inner in out1[key_outer].keys():
assert keras.ops.all(
keras.ops.isclose(out1[key_outer][key_inner], out2[key_outer][key_inner])
), "Output of original and loaded model differs significantly."
assert keras.ops.all(keras.ops.isclose(out1[key_outer][key_inner], out2[key_outer][key_inner])), (
"Output of original and loaded model differs significantly."
)


def test_copy_unequal(point_inference_network, random_samples, random_conditions):
Expand Down

0 comments on commit 50e01b1

Please sign in to comment.