Skip to content

Commit 5dc99b5

Browse files
Remove deprecated force_consts_to_hdf5 parameter (#642)
1 parent 4e5557d commit 5dc99b5

File tree

4 files changed

+1
-100
lines changed

4 files changed

+1
-100
lines changed

janus_core/calculations/phonons.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from collections.abc import Sequence
66
from typing import Any, get_args
7-
from warnings import warn
87

98
from ase import Atoms
109
from numpy import ndarray
@@ -108,8 +107,6 @@ class Phonons(BaseCalculation):
108107
End temperature for thermal properties calculations, in K. Default is 1000.0.
109108
temp_step
110109
Temperature step for thermal properties calculations, in K. Default is 50.0.
111-
force_consts_to_hdf5
112-
Deprecated. Please use `hdf5`.
113110
hdf5
114111
Whether to write force constants and bands in hdf5 or not. Default is True.
115112
hdf5_compression
@@ -164,7 +161,6 @@ def __init__(
164161
temp_min: float = 0.0,
165162
temp_max: float = 1000.0,
166163
temp_step: float = 50.0,
167-
force_consts_to_hdf5: bool | None = None,
168164
hdf5: bool = True,
169165
hdf5_compression: str | None = None,
170166
plot_to_file: bool = False,
@@ -244,8 +240,6 @@ def __init__(
244240
End temperature for thermal calculations, in K. Default is 1000.0.
245241
temp_step
246242
Temperature step for thermal calculations, in K. Default is 50.0.
247-
force_consts_to_hdf5
248-
Deprecated. Please use `hdf5`.
249243
hdf5
250244
Whether to write force constants and bands in hdf5 or not. Default is True.
251245
hdf5_compression
@@ -295,21 +289,6 @@ def __init__(
295289
self.write_full = write_full
296290
self.enable_progress_bar = enable_progress_bar
297291

298-
# Handle deprecation
299-
if force_consts_to_hdf5 is not None:
300-
if hdf5 is False:
301-
raise ValueError(
302-
"""`force_consts_to_hdf5`: has replaced `hdf5`.
303-
Please only use `hdf5`"""
304-
)
305-
self.hdf5 = force_consts_to_hdf5
306-
warn(
307-
"""`force_consts_to_hdf5` has been deprecated.
308-
Please use `hdf5`.""",
309-
FutureWarning,
310-
stacklevel=2,
311-
)
312-
313292
# Ensure supercell is a valid list
314293
self.supercell = [supercell] * 3 if isinstance(supercell, int) else supercell
315294
if len(self.supercell) not in [3, 9]:

janus_core/cli/phonons.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
Summary,
2727
Tracker,
2828
)
29-
from janus_core.cli.utils import deprecated_option, yaml_converter_callback
29+
from janus_core.cli.utils import yaml_converter_callback
3030

3131
app = Typer()
3232

@@ -110,15 +110,6 @@ def phonons(
110110
),
111111
] = 0.1,
112112
minimize_kwargs: MinimizeKwargs = None,
113-
force_consts_to_hdf5: Annotated[
114-
bool,
115-
Option(
116-
help="Whether to save force constants in hdf5.",
117-
rich_help_panel="Calculation",
118-
callback=deprecated_option,
119-
hidden=True,
120-
),
121-
] = None,
122113
hdf5: Annotated[
123114
bool,
124115
Option(
@@ -244,8 +235,6 @@ def phonons(
244235
Default is 0.1.
245236
minimize_kwargs
246237
Other keyword arguments to pass to geometry optimizer. Default is {}.
247-
force_consts_to_hdf5
248-
Deprecated. Please use `hdf5`.
249238
hdf5
250239
Whether to save force constants and bands in hdf5 format.
251240
Default is True.

tests/test_phonons.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,6 @@ def test_calc_phonons():
4141
assert "phonon" in phonons.results
4242

4343

44-
def test_force_consts_to_hdf5_deprecation():
45-
"""Test deprecation of force-consts-to-hdf5."""
46-
struct = read(DATA_PATH / "NaCl.cif")
47-
struct.calc = choose_calculator(arch="mace_mp", model=MODEL_PATH)
48-
with pytest.warns(
49-
FutureWarning, match="`force_consts_to_hdf5` has been deprecated."
50-
):
51-
phonons = Phonons(
52-
struct=struct,
53-
force_consts_to_hdf5=True,
54-
)
55-
56-
phonons.calc_force_constants(write_force_consts=True)
57-
assert "phonon" in phonons.results
58-
59-
6044
def test_force_consts_compression(tmp_path):
6145
"""Test compression of force constants."""
6246
log_file = tmp_path / "phonons.log"

tests/test_phonons_cli.py

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -218,57 +218,6 @@ def test_hdf5(tmp_path, compression):
218218
assert h5f["force_constants"].compression == compression
219219

220220

221-
def test_force_consts_to_hdf5_deprecated(tmp_path):
222-
"""Test saving force constants to HDF5 deprecated."""
223-
file_prefix = tmp_path / "test" / "NaCl"
224-
phonon_results = tmp_path / "test" / "NaCl-phonopy.yml"
225-
hdf5_results = tmp_path / "test" / "NaCl-force_constants.hdf5"
226-
bands_results = tmp_path / "test" / "NaCl-auto_bands.hdf5"
227-
summary_path = tmp_path / "test" / "NaCl-phonons-summary.yml"
228-
log_path = tmp_path / "test" / "NaCl-phonons-log.yml"
229-
230-
result = runner.invoke(
231-
app,
232-
[
233-
"phonons",
234-
"--struct",
235-
DATA_PATH / "NaCl.cif",
236-
"--arch",
237-
"mace_mp",
238-
"--bands",
239-
"--file-prefix",
240-
file_prefix,
241-
"--force-consts-to-hdf5",
242-
],
243-
)
244-
245-
assert result.exit_code == 0
246-
assert phonon_results.exists()
247-
assert hdf5_results.exists()
248-
assert bands_results.exists()
249-
250-
# Read phonons summary file
251-
with open(summary_path, encoding="utf8") as file:
252-
phonon_summary = yaml.safe_load(file)
253-
254-
output_files = {
255-
"params": phonon_results,
256-
"force_constants": hdf5_results,
257-
"bands": bands_results,
258-
"bands_plot": None,
259-
"dos": None,
260-
"dos_plot": None,
261-
"band_dos_plot": None,
262-
"pdos": None,
263-
"pdos_plot": None,
264-
"thermal": None,
265-
"minimized_initial_structure": None,
266-
"log": log_path,
267-
"summary": summary_path,
268-
}
269-
check_output_files(summary=phonon_summary, output_files=output_files)
270-
271-
272221
def test_thermal_props(tmp_path):
273222
"""Test calculating thermal properties."""
274223
file_prefix = tmp_path / "test" / "NaCl"

0 commit comments

Comments
 (0)