Skip to content

Commit 3527606

Browse files
Remove deprecated filter_func parameter (#641)
1 parent b67959e commit 3527606

File tree

4 files changed

+2
-109
lines changed

4 files changed

+2
-109
lines changed

janus_core/calculations/geom_opt.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ class GeomOpt(BaseCalculation):
7676
filter_class
7777
Filter class, or name of class from ase.filters to wrap around atoms.
7878
Default is `FrechetCellFilter`.
79-
filter_func
80-
Deprecated. Please use `filter_class`.
8179
filter_kwargs
8280
Keyword arguments to pass to filter_class. Default is {}.
8381
optimizer
@@ -117,7 +115,6 @@ def __init__(
117115
symmetry_tolerance: float = 0.001,
118116
angle_tolerance: float = -1.0,
119117
filter_class: Callable | str | None = FrechetCellFilter,
120-
filter_func: Callable | str | None = None,
121118
filter_kwargs: dict[str, Any] | None = None,
122119
optimizer: Callable | str = LBFGS,
123120
opt_kwargs: ASEOptArgs | None = None,
@@ -173,8 +170,6 @@ def __init__(
173170
filter_class
174171
Filter class, or name of class from ase.filters to wrap around atoms.
175172
Default is `FrechetCellFilter`.
176-
filter_func
177-
Deprecated. Please use `filter_class`.
178173
filter_kwargs
179174
Keyword arguments to pass to filter_class. Default is {}.
180175
optimizer
@@ -200,10 +195,6 @@ def __init__(
200195
)
201196
)
202197

203-
# Handle deprecated filter_func, but warn later after logging is set up
204-
if filter_func:
205-
filter_class = filter_func
206-
207198
self.fmax = fmax
208199
self.steps = steps
209200
self.symmetrize = symmetrize
@@ -242,15 +233,6 @@ def __init__(
242233
if not self.struct.calc:
243234
raise ValueError("Please attach a calculator to `struct`.")
244235

245-
# Warn for deprecated filter_func now that logging is set up
246-
if filter_func:
247-
warnings.warn(
248-
"`filter_func` has been deprecated, but currently overrides "
249-
"`filter_class`. Please only set `filter_class`.",
250-
FutureWarning,
251-
stacklevel=2,
252-
)
253-
254236
# Set output files
255237
self.write_kwargs["filename"] = self._build_filename(
256238
"opt.extxyz", filename=self.write_kwargs.get("filename")

janus_core/cli/geomopt.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
Tracker,
2424
WriteKwargs,
2525
)
26-
from janus_core.cli.utils import deprecated_option, yaml_converter_callback
26+
from janus_core.cli.utils import yaml_converter_callback
2727

2828
app = Typer()
2929

@@ -125,15 +125,6 @@ def geomopt(
125125
rich_help_panel="Calculation",
126126
),
127127
] = None,
128-
filter_func: Annotated[
129-
str | None,
130-
Option(
131-
help="Deprecated. Please use --filter",
132-
rich_help_panel="Calculation",
133-
callback=deprecated_option,
134-
hidden=True,
135-
),
136-
] = None,
137128
pressure: Annotated[
138129
float,
139130
Option(
@@ -216,8 +207,6 @@ def geomopt(
216207
filter_class
217208
Name of filter from ase.filters to wrap around atoms. If using
218209
--opt-cell-lengths or --opt-cell-fully, defaults to `FrechetCellFilter`.
219-
filter_func
220-
Deprecated. Please use `filter_class`.
221210
pressure
222211
Scalar pressure when optimizing cell geometry, in GPa. Passed to the filter
223212
function if either `opt_cell_lengths` or `opt_cell_fully` is True. Default is
@@ -303,19 +292,14 @@ def geomopt(
303292

304293
_set_minimize_kwargs(minimize_kwargs, opt_cell_lengths, pressure)
305294

306-
if filter_func and filter_class:
307-
raise ValueError("--filter-func is deprecated, please only use --filter")
308-
309295
if opt_cell_fully or opt_cell_lengths:
310296
# Use default filter unless filter explicitly passed
311297
if filter_class:
312298
opt_cell_fully_dict = {"filter_class": filter_class}
313-
elif filter_func:
314-
opt_cell_fully_dict = {"filter_func": filter_func, "filter_class": None}
315299
else:
316300
opt_cell_fully_dict = {}
317301
else:
318-
if filter_class or filter_func:
302+
if filter_class:
319303
raise ValueError(
320304
"--opt-cell-lengths or --opt-cell-fully must be set to use a filter"
321305
)

tests/test_geom_opt.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -416,16 +416,3 @@ def test_traj_kwargs_new_dir(tmp_path):
416416
assert traj_path.exists()
417417
traj = read(traj_path, index=":")
418418
assert len(traj) == 3
419-
420-
421-
def test_deprecation_filter_func(tmp_path):
422-
"""Test FutureWarning raised for model in calc_kwargs."""
423-
with pytest.warns(FutureWarning, match="`filter_func` has been deprecated"):
424-
geom_opt = GeomOpt(
425-
struct=DATA_PATH / "NaCl.cif",
426-
arch="mace_mp",
427-
model=MODEL_PATH,
428-
fmax=0.001,
429-
filter_func="UnitCellFilter",
430-
)
431-
assert isinstance(geom_opt.filtered_struct, UnitCellFilter)

tests/test_geomopt_cli.py

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -999,63 +999,3 @@ def test_info(tmp_path):
999999
assert atoms.info["system_name"] == "NaCl"
10001000
assert "config_type" in atoms.info
10011001
assert atoms.info["config_type"] == "geom_opt"
1002-
1003-
1004-
def test_filter_func_deprecated(tmp_path):
1005-
"""Test filter_func sets filter."""
1006-
file_prefix = tmp_path / "NaCl"
1007-
log_path = tmp_path / "test.log"
1008-
1009-
result = runner.invoke(
1010-
app,
1011-
[
1012-
"geomopt",
1013-
"--struct",
1014-
DATA_PATH / "NaCl.cif",
1015-
"--arch",
1016-
"mace_mp",
1017-
"--model",
1018-
MACE_PATH,
1019-
"--opt-cell-fully",
1020-
"--filter-func",
1021-
"UnitCellFilter",
1022-
"--log",
1023-
log_path,
1024-
"--file-prefix",
1025-
file_prefix,
1026-
"--no-tracker",
1027-
],
1028-
)
1029-
assert result.exit_code == 0
1030-
assert_log_contains(
1031-
log_path,
1032-
includes=["Starting geometry optimization", "Using filter: UnitCellFilter"],
1033-
)
1034-
1035-
1036-
def test_filter_func_error(tmp_path):
1037-
"""Test setting filter_func without --opt-cell-fully or --opt-cell-lengths."""
1038-
results_path = tmp_path / "NaCl-opt.extxyz"
1039-
log_path = tmp_path / "test.log"
1040-
summary_path = tmp_path / "summary.yml"
1041-
1042-
result = runner.invoke(
1043-
app,
1044-
[
1045-
"geomopt",
1046-
"--struct",
1047-
DATA_PATH / "NaCl-deformed.cif",
1048-
"--arch",
1049-
"mace_mp",
1050-
"--out",
1051-
results_path,
1052-
"--filter-func",
1053-
"UnitCellFilter",
1054-
"--log",
1055-
log_path,
1056-
"--summary",
1057-
summary_path,
1058-
],
1059-
)
1060-
assert result.exit_code == 1
1061-
assert isinstance(result.exception, ValueError)

0 commit comments

Comments
 (0)