From fa2b92447a6934996aa3300b05fe3a5f3b4696e8 Mon Sep 17 00:00:00 2001 From: alin m elena Date: Fri, 1 May 2026 06:04:32 +0100 Subject: [PATCH] fix linting --- mace/calculators/mace_torchsim.py | 2 -- mace/tools/finetuning_utils.py | 15 ++++++++++++--- mace/tools/model_script_utils.py | 8 ++++++-- tests/test_calculator.py | 4 +--- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/mace/calculators/mace_torchsim.py b/mace/calculators/mace_torchsim.py index ee178202a..03239ef45 100644 --- a/mace/calculators/mace_torchsim.py +++ b/mace/calculators/mace_torchsim.py @@ -195,8 +195,6 @@ def _resolve_head(head: Optional[Union[str, int]], available_heads: list) -> int return 0 def _setup_compile(self, compile_mode: str) -> None: - import torch._dynamo as dynamo - from mace.tools.compile import configure_autograd_for_compile, simplify if self._enable_oeq: diff --git a/mace/tools/finetuning_utils.py b/mace/tools/finetuning_utils.py index d4c805b45..0ec5c6e2e 100644 --- a/mace/tools/finetuning_utils.py +++ b/mace/tools/finetuning_utils.py @@ -236,7 +236,10 @@ def load_foundations_elements( readout.linear_1.weight = torch.nn.Parameter( model_readouts_one_linear_1_weight ) - if readout.linear_1.bias is not None and readout.linear_1.bias.numel() > 0: + if ( + readout.linear_1.bias is not None + and readout.linear_1.bias.numel() > 0 + ): model_readouts_one_linear_1_bias = ( model_foundations.readouts[i] .linear_1.bias.view(-1) @@ -259,7 +262,10 @@ def load_foundations_elements( / ((shape_input_1) / (shape_output_1)) ** 0.5 ) # if it has biases transfer them too - if readout.linear_mid.bias is not None and readout.linear_mid.bias.numel() > 0: + if ( + readout.linear_mid.bias is not None + and readout.linear_mid.bias.numel() > 0 + ): readout.linear_mid.bias = torch.nn.Parameter( model_foundations.readouts[i] .linear_mid.bias.repeat(len(model_heads)) @@ -277,7 +283,10 @@ def load_foundations_elements( readout.linear_2.weight = torch.nn.Parameter( model_readouts_one_linear_2_weight ) - if readout.linear_2.bias is not None and readout.linear_2.bias.numel() > 0: + if ( + readout.linear_2.bias is not None + and readout.linear_2.bias.numel() > 0 + ): model_readouts_one_linear_2_bias = ( model_foundations.readouts[i] .linear_2.bias.view(-1) diff --git a/mace/tools/model_script_utils.py b/mace/tools/model_script_utils.py index 4f2cf148c..0f1bd7819 100644 --- a/mace/tools/model_script_utils.py +++ b/mace/tools/model_script_utils.py @@ -32,8 +32,12 @@ def configure_model( args.compute_stress = True if compute_virials or compute_stress: - if args.error_table in ['PerAtomRMSE','PerAtomMAE','TotalRMSE', 'TotalMAE']: - args.error_table = "PerAtomRMSEstressvirials" if 'RMSE' in args.error_table else 'PerAtomMAEstressvirials' + if args.error_table in ["PerAtomRMSE", "PerAtomMAE", "TotalRMSE", "TotalMAE"]: + args.error_table = ( + "PerAtomRMSEstressvirials" + if "RMSE" in args.error_table + else "PerAtomMAEstressvirials" + ) output_args = { "energy": args.compute_energy, diff --git a/tests/test_calculator.py b/tests/test_calculator.py index 9390261a4..f7e33509d 100644 --- a/tests/test_calculator.py +++ b/tests/test_calculator.py @@ -856,9 +856,7 @@ def __init__(self, model_paths, device, default_dtype, **kwargs): self.kwargs = kwargs monkeypatch.setattr(foundations_models, "get_cache_dir", lambda: str(tmp_path)) - monkeypatch.setattr( - foundations_models, "_urlretrieve_with_timeout", fake_download - ) + monkeypatch.setattr(foundations_models, "_urlretrieve_with_timeout", fake_download) monkeypatch.setattr(foundations_models, "MACECalculator", DummyCalculator) kwargs = {"device": "cpu"}