Skip to content

Commit

Permalink
bump ruff pre-commit to 0.3.0 + auto-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh committed Mar 6, 2024
1 parent c9dc8ee commit 71a5edc
Show file tree
Hide file tree
Showing 40 changed files with 9 additions and 45 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ default_install_hook_types: [pre-commit, commit-msg]

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.2
rev: v0.3.0
hooks:
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/janosh/format-ipy-cells
rev: v0.1.10
rev: v0.1.11
hooks:
- id: format-ipy-cells

Expand Down Expand Up @@ -80,7 +80,7 @@ repos:
- id: check-github-actions

- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.351
rev: v1.1.352
hooks:
- id: pyright
args: [--level, error]
1 change: 0 additions & 1 deletion data/mp/build_phase_diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
DFT-ground truth convex hull energies.
"""


# %%
import gzip
import json
Expand Down
1 change: 0 additions & 1 deletion data/mp/eda_mp_trj.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""MPtrj exploratory data analysis (EDA)."""


# %%
import io
import os
Expand Down
1 change: 0 additions & 1 deletion data/mp/get_mp_traj.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
all 1.6M task docs.
"""


# %%
import os
import subprocess
Expand Down
1 change: 0 additions & 1 deletion data/wbm/compile_wbm_test_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
https://nature.com/articles/s41524-020-00481-6
"""


# %% links to google drive files received via email from 1st author Hai-Chen Wang
# on 2021-06-15 containing initial and relaxed structures
google_drive_ids = {
Expand Down
1 change: 0 additions & 1 deletion models/chgnet/analyze_chgnet.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Compare CHGNet long vs short relaxations."""


# %%
import os

Expand Down
1 change: 0 additions & 1 deletion models/chgnet/join_chgnet_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
into single file.
"""


# %%
from __future__ import annotations

Expand Down
1 change: 0 additions & 1 deletion models/chgnet/test_chgnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
pip install -e ./chgnet.
"""


# %%
from __future__ import annotations

Expand Down
1 change: 0 additions & 1 deletion models/m3gnet/join_m3gnet_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
into single file.
"""


# %%
from __future__ import annotations

Expand Down
1 change: 0 additions & 1 deletion models/m3gnet/pre_vs_post_m3gnet_relaxation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Compare M3GNet-relaxed vs DFT-relaxed WBM lattice volumes and angles."""


# %%
import os

Expand Down
1 change: 0 additions & 1 deletion models/m3gnet/test_m3gnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
https://github.com/materialsvirtuallab/m3gnet.
"""


# %%
from __future__ import annotations

Expand Down
1 change: 0 additions & 1 deletion models/mace/analyze_mace.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Investigate MACE energy underpredictions."""


# %%
import os

Expand Down
1 change: 0 additions & 1 deletion models/mace/join_mace_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
into single file.
"""


# %%
from __future__ import annotations

Expand Down
1 change: 0 additions & 1 deletion models/megnet/test_megnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
See https://github.com/materialsvirtuallab/megnet.
"""


# %%
from __future__ import annotations

Expand Down
1 change: 0 additions & 1 deletion models/voronoi_rf/join_voronoi_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
into single file.
"""


# %%
from __future__ import annotations

Expand Down
1 change: 0 additions & 1 deletion models/voronoi_rf/train_test_voronoi_rf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Train and test a Voronoi RandomForestRegressor model."""


# %%
import os
import sys
Expand Down
1 change: 0 additions & 1 deletion models/voronoi_rf/voronoi_featurize_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Voronoi tessellation structure-based features.
"""


# %%
import os
import sys
Expand Down
1 change: 0 additions & 1 deletion models/wrenformer/analyze_wrenformer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Compare CHGNet long vs short relaxations."""


# %%
import numpy as np
import pandas as pd
Expand Down
1 change: 0 additions & 1 deletion models/wrenformer/test_wrenformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
saves predictions to CSV.
"""


# %%
from __future__ import annotations

Expand Down
1 change: 0 additions & 1 deletion models/wrenformer/train_wrenformer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Train a Wrenformer ensemble on target_col of data_path."""


# %%
import os
from importlib.metadata import version
Expand Down
1 change: 0 additions & 1 deletion scripts/analyze_model_failure_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Might point to deficiencies in the data or models architecture.
"""


# %%
import itertools

Expand Down
1 change: 0 additions & 1 deletion scripts/compute_struct_fingerprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Might point to deficiencies in the data or models architecture.
"""


# %%
import os
from glob import glob
Expand Down
1 change: 0 additions & 1 deletion scripts/hist_classified_stable_vs_hull_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
See fig. S1 in https://science.org/doi/10.1126/sciadv.abn4117.
"""


# %%
from typing import Final

Expand Down
1 change: 0 additions & 1 deletion scripts/hist_classified_stable_vs_hull_dist_batches.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
See fig. S1 in https://science.org/doi/10.1126/sciadv.abn4117.
"""


# %%
from typing import Final

Expand Down
1 change: 0 additions & 1 deletion scripts/model_figs/analyze_model_disagreement.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
models can pinpoint DFT calculation gone wrong.
"""


# %%
import sys

Expand Down
1 change: 0 additions & 1 deletion scripts/model_figs/compile_model_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pandas-styled HTML table and a plotly figure.
"""


# %%
from __future__ import annotations

Expand Down
1 change: 0 additions & 1 deletion scripts/model_figs/cumulative_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
will provide the best hit rate for the given budget.
"""


# %%
import pandas as pd
from pymatviz.io import save_fig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
histogram stacks true/false positives/negatives with different colors.
"""


# %%
import math
from typing import Final
Expand Down
1 change: 0 additions & 1 deletion scripts/model_figs/metrics_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pandas-styled HTML table and a plotly figure.
"""


# %%
from __future__ import annotations

Expand Down
1 change: 0 additions & 1 deletion scripts/model_figs/parity_energy_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Last plot is split into 2x3 subplots, one for each model.
"""


# %%
import math
from typing import Literal
Expand Down
1 change: 0 additions & 1 deletion scripts/model_figs/per_element_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Might point to deficiencies in the data or models architecture.
"""


# %%
import pandas as pd
import plotly.express as px
Expand Down
3 changes: 1 addition & 2 deletions scripts/model_figs/roc_prc_curves_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Plot ROC and PR (precision-recall) curves for each model."""


# %%
import math

Expand Down Expand Up @@ -44,7 +43,7 @@
fpr, tpr, thresholds = roc_curve(y_true, y_pred, pos_label=0)
AUC = auc(fpr, tpr)
title = f"{model} · {AUC=:.2f}"
thresholds = [f"{t:.3} eV/atom" for t in thresholds]
thresholds = [f"{thresh:.3} eV/atom" for thresh in thresholds]
df_tmp = pd.DataFrame(
{"FPR": fpr, "TPR": tpr, color_col: thresholds, "AUC": AUC, facet_col: title}
).round(3)
Expand Down
1 change: 0 additions & 1 deletion scripts/model_figs/rolling_mae_vs_hull_dist_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Plot rolling MAE as a function of hull distance for all models."""


# %%
from typing import Final

Expand Down
1 change: 0 additions & 1 deletion scripts/model_figs/rolling_mae_vs_hull_dist_wbm_batches.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
batch in a single plot.
"""


# %%
from pymatviz.io import save_fig

Expand Down
1 change: 0 additions & 1 deletion scripts/model_figs/run_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
model-comparison figure.
"""


# %%
import os
import runpy
Expand Down
1 change: 0 additions & 1 deletion scripts/project_compositions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Compute t-SNE or UMAP projections of WBM and MP compositions."""


# %%
import os
from datetime import datetime
Expand Down
1 change: 0 additions & 1 deletion scripts/rolling_mae_vs_hull_dist.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Plot rolling MAE as a function of hull distance for a single model."""


# %%
from pymatviz.io import save_fig

Expand Down
1 change: 0 additions & 1 deletion scripts/update_wandb_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
https://wandb.ai/janosh/matbench-discovery.
"""


# %%
import pandas as pd
import wandb
Expand Down
1 change: 0 additions & 1 deletion scripts/wbm_umap_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
https://www.nature.com/articles/s41524-023-01012-9
"""


# %%
from __future__ import annotations

Expand Down
8 changes: 5 additions & 3 deletions tests/test_slurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ def test_slurm_submit(
assert stderr == stderr == ""

# check slurm_submit() prints cmd and calls subprocess.run() in submit mode
with pytest.raises(SystemExit), patch("sys.argv", ["slurm-submit"]), patch(
"matbench_discovery.slurm.subprocess.run"
) as mock_subprocess_run:
with (
pytest.raises(SystemExit),
patch("sys.argv", ["slurm-submit"]),
patch("matbench_discovery.slurm.subprocess.run") as mock_subprocess_run,
):
func_call()

assert mock_subprocess_run.call_count == 1
Expand Down

0 comments on commit 71a5edc

Please sign in to comment.