From 8b8930a559e085b9fb23b1bbcaee4d918cdd4921 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Jan=C3=9Fen?= Date: Tue, 9 Jan 2024 07:34:02 +0100 Subject: [PATCH 1/2] Output: Call get() function with parameter names --- atomistics/calculators/ase.py | 8 ++++---- atomistics/calculators/lammps/calculator.py | 2 +- atomistics/calculators/lammps/helpers.py | 2 +- atomistics/calculators/qe.py | 2 +- atomistics/shared/output.py | 4 ++-- atomistics/shared/thermal_expansion.py | 4 ++-- atomistics/workflows/elastic/workflow.py | 2 +- atomistics/workflows/evcurve/debye.py | 4 ++-- atomistics/workflows/evcurve/workflow.py | 4 ++-- atomistics/workflows/phonons/workflow.py | 6 +++--- atomistics/workflows/quasiharmonic.py | 4 ++-- 11 files changed, 21 insertions(+), 21 deletions(-) diff --git a/atomistics/calculators/ase.py b/atomistics/calculators/ase.py index 37485977..9d86850c 100644 --- a/atomistics/calculators/ase.py +++ b/atomistics/calculators/ase.py @@ -110,8 +110,8 @@ def calc_static_with_ase( return OutputStatic( **{k: getattr(ASEExecutor, k) for k in OutputStatic.keys()} ).get( - ASEExecutor(ase_structure=structure, ase_calculator=ase_calculator), - *output_keys, + engine=ASEExecutor(ase_structure=structure, ase_calculator=ase_calculator), + output_keys=output_keys, ) @@ -127,8 +127,8 @@ def _calc_md_step_with_ase( for i in range(int(run / thermo)): dyn.run(thermo) calc_dict = ASEOutputMolecularDynamics.get( - ASEExecutor(ase_structure=structure, ase_calculator=ase_calculator), - *output_keys, + engine=ASEExecutor(ase_structure=structure, ase_calculator=ase_calculator), + output_keys=output_keys, ) for k, v in calc_dict.items(): cache[k].append(v) diff --git a/atomistics/calculators/lammps/calculator.py b/atomistics/calculators/lammps/calculator.py index 5ac82f0a..2e20346d 100644 --- a/atomistics/calculators/lammps/calculator.py +++ b/atomistics/calculators/lammps/calculator.py @@ -137,7 +137,7 @@ def calc_static_with_lammps( energy=LammpsASELibrary.interactive_energy_pot_getter, stress=LammpsASELibrary.interactive_pressures_getter, volume=LammpsASELibrary.interactive_volume_getter, - ).get(lmp_instance, *output_keys) + ).get(engine=lmp_instance, output_keys=output_keys) lammps_shutdown(lmp_instance=lmp_instance, close_instance=lmp is None) return result_dict diff --git a/atomistics/calculators/lammps/helpers.py b/atomistics/calculators/lammps/helpers.py index 0dfe5f89..99b8ba12 100644 --- a/atomistics/calculators/lammps/helpers.py +++ b/atomistics/calculators/lammps/helpers.py @@ -57,7 +57,7 @@ def lammps_calc_md_step( pressure=LammpsASELibrary.interactive_pressures_getter, velocities=LammpsASELibrary.interactive_velocities_getter, volume=LammpsASELibrary.interactive_volume_getter, - ).get(lmp_instance, *output_keys) + ).get(engine=lmp_instance, output_keys=output_keys) def lammps_calc_md( diff --git a/atomistics/calculators/qe.py b/atomistics/calculators/qe.py index 3048cf3d..d8d647ac 100644 --- a/atomistics/calculators/qe.py +++ b/atomistics/calculators/qe.py @@ -209,7 +209,7 @@ def calc_static_with_qe( ) return OutputStatic( **{k: getattr(QEStaticParser, k) for k in OutputStatic.keys()} - ).get(QEStaticParser(filename=output_file_name), *output_keys) + ).get(engine=QEStaticParser(filename=output_file_name), output_keys=output_keys) @as_task_dict_evaluator diff --git a/atomistics/shared/output.py b/atomistics/shared/output.py index f8a64fbb..143ef42a 100644 --- a/atomistics/shared/output.py +++ b/atomistics/shared/output.py @@ -7,8 +7,8 @@ class Output: def keys(cls): return tuple(field.name for field in dataclasses.fields(cls)) - def get(self, engine, *output: str) -> dict: - return {q: getattr(self, q)(engine) for q in output} + def get(self, engine, output_keys: str) -> dict: + return {q: getattr(self, q)(engine) for q in output_keys} @dataclasses.dataclass diff --git a/atomistics/shared/thermal_expansion.py b/atomistics/shared/thermal_expansion.py index d8da1616..46f8e42c 100644 --- a/atomistics/shared/thermal_expansion.py +++ b/atomistics/shared/thermal_expansion.py @@ -20,8 +20,8 @@ def get_thermal_expansion_output(temperatures_lst, volumes_lst, output_keys): for k in OutputThermalExpansion.keys() } ).get( - ThermalExpansionProperties( + engine=ThermalExpansionProperties( temperatures_lst=temperatures_lst, volumes_lst=volumes_lst ), - *output_keys, + output_keys=output_keys, ) diff --git a/atomistics/workflows/elastic/workflow.py b/atomistics/workflows/elastic/workflow.py index 5fbbba01..ddd22513 100644 --- a/atomistics/workflows/elastic/workflow.py +++ b/atomistics/workflows/elastic/workflow.py @@ -63,4 +63,4 @@ def analyse_structures(self, output_dict, output_keys=OutputElastic.keys()): self._data["A2"] = A2 return OutputElastic( **{k: getattr(ElasticProperties, k) for k in OutputElastic.keys()} - ).get(ElasticProperties(elastic_matrix=elastic_matrix), *output_keys) + ).get(engine=ElasticProperties(elastic_matrix=elastic_matrix), output_keys=output_keys) diff --git a/atomistics/workflows/evcurve/debye.py b/atomistics/workflows/evcurve/debye.py index 50a79bdb..caba068b 100644 --- a/atomistics/workflows/evcurve/debye.py +++ b/atomistics/workflows/evcurve/debye.py @@ -232,7 +232,7 @@ def get_thermal_properties( return OutputThermodynamic( **{k: getattr(DebyeThermalProperties, k) for k in OutputThermodynamic.keys()} ).get( - DebyeThermalProperties( + engine=DebyeThermalProperties( fit_dict=fit_dict, masses=masses, t_min=t_min, @@ -242,5 +242,5 @@ def get_thermal_properties( constant_volume=constant_volume, num_steps=num_steps, ), - *output_keys, + output_keys=output_keys, ) diff --git a/atomistics/workflows/evcurve/workflow.py b/atomistics/workflows/evcurve/workflow.py index d081868e..df2bdfe9 100644 --- a/atomistics/workflows/evcurve/workflow.py +++ b/atomistics/workflows/evcurve/workflow.py @@ -181,7 +181,7 @@ def analyse_structures( for k in OutputEnergyVolumeCurve.keys() } ).get( - EnergyVolumeCurveProperties( + engine=EnergyVolumeCurveProperties( fit_module=fit_ev_curve_internal( volume_lst=get_volume_lst(structure_dict=self._structure_dict), energy_lst=get_energy_lst( @@ -191,7 +191,7 @@ def analyse_structures( fit_order=self.fit_order, ) ), - *output_keys, + output_keys=output_keys, ) return self.fit_dict diff --git a/atomistics/workflows/phonons/workflow.py b/atomistics/workflows/phonons/workflow.py index dc47ebd5..d9f63c0f 100644 --- a/atomistics/workflows/phonons/workflow.py +++ b/atomistics/workflows/phonons/workflow.py @@ -236,7 +236,7 @@ def analyse_structures(self, output_dict, output_keys=OutputPhonons.keys()): self._phonopy_dict = OutputPhonons( **{k: getattr(PhonopyProperties, k) for k in OutputPhonons.keys()} ).get( - PhonopyProperties( + engine=PhonopyProperties( phonopy_instance=self.phonopy, dos_mesh=self._dos_mesh, shift=None, @@ -253,7 +253,7 @@ def analyse_structures(self, output_dict, output_keys=OutputPhonons.keys()): use_tetrahedron_method=True, npoints=101, ), - *output_keys, + output_keys=output_keys, ) return self._phonopy_dict @@ -298,7 +298,7 @@ def get_thermal_properties( k: getattr(PhonopyThermalProperties, k) for k in OutputThermodynamic.keys() } - ).get(PhonopyThermalProperties(phonopy_instance=self.phonopy), *output_keys) + ).get(engine=PhonopyThermalProperties(phonopy_instance=self.phonopy), output_keys=output_keys) def get_dynamical_matrix(self, npoints=101): """ diff --git a/atomistics/workflows/quasiharmonic.py b/atomistics/workflows/quasiharmonic.py index 3cd6bc5b..8da46375 100644 --- a/atomistics/workflows/quasiharmonic.py +++ b/atomistics/workflows/quasiharmonic.py @@ -118,14 +118,14 @@ def get_thermal_properties( for k in OutputThermodynamic.keys() } ).get( - QuasiHarmonicThermalProperties( + engine=QuasiHarmonicThermalProperties( temperatures=temperatures, thermal_properties_dict=tp_collect_dict, strain_lst=strain_lst, volumes_lst=volume_lst, volumes_selected_lst=vol_lst, ), - *output_keys, + output_keys=output_keys, ) From 94bf490619fefc30756e30c2b96ad6306bc8ccf8 Mon Sep 17 00:00:00 2001 From: pyiron-runner Date: Tue, 9 Jan 2024 06:35:31 +0000 Subject: [PATCH 2/2] Format black --- atomistics/workflows/elastic/workflow.py | 5 ++++- atomistics/workflows/phonons/workflow.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/atomistics/workflows/elastic/workflow.py b/atomistics/workflows/elastic/workflow.py index ddd22513..f88dbad2 100644 --- a/atomistics/workflows/elastic/workflow.py +++ b/atomistics/workflows/elastic/workflow.py @@ -63,4 +63,7 @@ def analyse_structures(self, output_dict, output_keys=OutputElastic.keys()): self._data["A2"] = A2 return OutputElastic( **{k: getattr(ElasticProperties, k) for k in OutputElastic.keys()} - ).get(engine=ElasticProperties(elastic_matrix=elastic_matrix), output_keys=output_keys) + ).get( + engine=ElasticProperties(elastic_matrix=elastic_matrix), + output_keys=output_keys, + ) diff --git a/atomistics/workflows/phonons/workflow.py b/atomistics/workflows/phonons/workflow.py index d9f63c0f..767cdf5a 100644 --- a/atomistics/workflows/phonons/workflow.py +++ b/atomistics/workflows/phonons/workflow.py @@ -298,7 +298,10 @@ def get_thermal_properties( k: getattr(PhonopyThermalProperties, k) for k in OutputThermodynamic.keys() } - ).get(engine=PhonopyThermalProperties(phonopy_instance=self.phonopy), output_keys=output_keys) + ).get( + engine=PhonopyThermalProperties(phonopy_instance=self.phonopy), + output_keys=output_keys, + ) def get_dynamical_matrix(self, npoints=101): """