Skip to content

Commit

Permalink
Merge pull request #72 from jet-net/pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
chore: update pre-commit hooks
  • Loading branch information
rkansal47 authored Sep 3, 2024
2 parents 637bcbe + a78c869 commit 0440334
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 21 deletions.
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ exclude: ".*key"

repos:
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.3.0
rev: 24.8.0
hooks:
- id: black-jupyter
language_version: python3
args: [--line-length=100]

- repo: https://github.com/adamchainz/blacken-docs
rev: "1.16.0"
rev: "1.18.0"
hooks:
- id: blacken-docs
additional_dependencies: [black==23.*]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.5.0"
rev: "v4.6.0"
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand Down Expand Up @@ -50,7 +50,7 @@ repos:
args: [--prose-wrap=preserve]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.3.5"
rev: "v0.6.3"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
Expand All @@ -65,7 +65,7 @@ repos:
# - pytest

- repo: https://github.com/codespell-project/codespell
rev: "v2.2.6"
rev: "v2.3.0"
hooks:
- id: codespell
types_or: [python, rst, markdown]
Expand All @@ -76,12 +76,12 @@ repos:
- id: shellcheck

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.16
rev: v0.19
hooks:
- id: validate-pyproject

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.28.1
rev: 0.29.2
hooks:
- id: check-dependabot
- id: check-github-workflows
Expand Down
5 changes: 3 additions & 2 deletions jetnet/evaluation/gen_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ def _calculate_frechet_distance(mu1, sigma1, mu2, sigma2, eps=1e-6):
covmean, _ = linalg.sqrtm(sigma1.dot(sigma2), disp=False)
if not np.isfinite(covmean).all():
msg = (
"fid calculation produces singular product; " "adding %s to diagonal of cov estimates"
) % eps
"fid calculation produces singular product; "
f"adding {eps} to diagonal of cov estimates"
)
logger.debug(msg)
offset = np.eye(sigma1.shape[0]) * eps
covmean = linalg.sqrtm((sigma1 + offset).dot(sigma2 + offset))
Expand Down
6 changes: 3 additions & 3 deletions tests/datasets/test_qgjets.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
num_particles = 153


@pytest.mark.slow()
@pytest.mark.slow
@pytest.mark.parametrize(
("jet_types", "split", "expected_length", "class_id"),
[
Expand Down Expand Up @@ -63,7 +63,7 @@ def test_getData(jet_types, split, expected_length, class_id, file_list):
assert np.all(jf[:, 0] == class_id)


@pytest.mark.slow()
@pytest.mark.slow
@pytest.mark.parametrize("file_list", [test_file_list_withbc, test_file_list_withoutbc])
def test_getDataFeatures(file_list):
pf, jf = DataClass.getData(data_dir=data_dir, jet_features=None, file_list=file_list)
Expand All @@ -82,7 +82,7 @@ def test_getDataFeatures(file_list):
assert np.max(pf[:, :, 1]) == approx(550, rel=0.2)


@pytest.mark.slow()
@pytest.mark.slow
def test_getDataErrors():
with pytest.raises(AssertionError):
DataClass.getData(jet_type="f")
Expand Down
8 changes: 4 additions & 4 deletions tests/datasets/test_toptagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
split = "valid" # for faster testing


@pytest.mark.slow()
@pytest.mark.slow
@pytest.mark.parametrize(
("jet_types", "split", "expected_length", "class_id"),
[
Expand Down Expand Up @@ -61,7 +61,7 @@ def test_getData(jet_types, split, expected_length, class_id):
assert np.all(jf[:, 0] == class_id)


@pytest.mark.slow()
@pytest.mark.slow
def test_getDataFeatures():
pf, jf = DataClass.getData(data_dir=data_dir, jet_features=["E", "type"], split=split)
assert pf.shape == (valid_length, num_particles, 4)
Expand All @@ -82,7 +82,7 @@ def test_getDataFeatures():
assert np.max(pf[:, :, 1]) == approx(2000, rel=0.2)


@pytest.mark.slow()
@pytest.mark.slow
def test_DataClassNormalisation():
X = DataClass(
data_dir=data_dir,
Expand All @@ -99,7 +99,7 @@ def test_DataClassNormalisation():
assert np.max(X.jet_data[:, 0]) == 1


@pytest.mark.slow()
@pytest.mark.slow
def test_getDataErrors():
with pytest.raises(AssertionError):
DataClass.getData(jet_type="f", split=split)
Expand Down
2 changes: 1 addition & 1 deletion tests/datasets/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
test_data_3d = rng.random((5, 4, 3))


@pytest.fixture()
@pytest.fixture
def features_order():
return ["eta", "phi", "pt"]

Expand Down
9 changes: 5 additions & 4 deletions tutorials/pyhep-data-access.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@
}
],
"source": [
"from __future__ import annotations\n",
"\n",
"from jetnet.datasets import JetNet\n",
"\n",
"print(f\"Particle features: {JetNet.ALL_PARTICLE_FEATURES}\")\n",
Expand Down Expand Up @@ -175,8 +177,8 @@
}
],
"source": [
"from jetnet.utils import to_image\n",
"import matplotlib.pyplot as plt\n",
"from jetnet.utils import to_image\n",
"\n",
"num_images = 5\n",
"num_types = len(data_args[\"jet_type\"])\n",
Expand Down Expand Up @@ -254,8 +256,8 @@
}
],
"source": [
"from jetnet.utils import jet_features\n",
"import numpy as np\n",
"from jetnet.utils import jet_features\n",
"\n",
"fig = plt.figure(figsize=(12, 12))\n",
"plt.ticklabel_format(axis=\"y\", scilimits=(0, 0), useMathText=True)\n",
Expand Down Expand Up @@ -291,10 +293,9 @@
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"from jetnet.datasets import JetNet\n",
"from jetnet.datasets.normalisations import FeaturewiseLinear\n",
"\n",
"import numpy as np\n",
"from sklearn.preprocessing import OneHotEncoder\n",
"\n",
"\n",
Expand Down

0 comments on commit 0440334

Please sign in to comment.