From a0617578447fdaa85af8d6804a470219e8a4ce45 Mon Sep 17 00:00:00 2001 From: henrikjacobsenfys Date: Wed, 8 Jan 2025 13:56:08 +0100 Subject: [PATCH 1/9] update np.Inf to match Numpy2 --- src/easyreflectometry/model/model.py | 4 ++-- .../sample/elements/layers/layer.py | 4 ++-- .../layers/layer_area_per_molecule.py | 8 +++---- .../sample/elements/materials/material.py | 8 +++---- .../elements/materials/material_density.py | 6 ++--- tests/model/test_model.py | 8 +++---- tests/sample/elements/layers/test_layer.py | 12 +++++----- .../elements/materials/test_material.py | 24 +++++++++---------- .../materials/test_material_density.py | 2 +- tests/test_parameter_utils.py | 6 ++--- 10 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/easyreflectometry/model/model.py b/src/easyreflectometry/model/model.py index c990e117..6d29f471 100644 --- a/src/easyreflectometry/model/model.py +++ b/src/easyreflectometry/model/model.py @@ -26,7 +26,7 @@ 'url': 'https://github.com/reflectivity/edu_outreach/blob/master/refl_maths/paper.tex', 'value': 1.0, 'min': 0, - 'max': np.Inf, + 'max': np.inf, 'fixed': True, }, 'background': { @@ -34,7 +34,7 @@ 'url': 'https://github.com/reflectivity/edu_outreach/blob/master/refl_maths/paper.tex', 'value': 1e-8, 'min': 0.0, - 'max': np.Inf, + 'max': np.inf, 'fixed': True, }, 'resolution': { diff --git a/src/easyreflectometry/sample/elements/layers/layer.py b/src/easyreflectometry/sample/elements/layers/layer.py index 00d6672b..80dd9bdb 100644 --- a/src/easyreflectometry/sample/elements/layers/layer.py +++ b/src/easyreflectometry/sample/elements/layers/layer.py @@ -18,7 +18,7 @@ 'value': 10.0, 'unit': 'angstrom', 'min': 0.0, - 'max': np.Inf, + 'max': np.inf, 'fixed': True, }, 'roughness': { @@ -27,7 +27,7 @@ 'value': 3.3, 'unit': 'angstrom', 'min': 0.0, - 'max': np.Inf, + 'max': np.inf, 'fixed': True, }, } diff --git a/src/easyreflectometry/sample/elements/layers/layer_area_per_molecule.py b/src/easyreflectometry/sample/elements/layers/layer_area_per_molecule.py index fea67833..08e43d1a 100644 --- a/src/easyreflectometry/sample/elements/layers/layer_area_per_molecule.py +++ b/src/easyreflectometry/sample/elements/layers/layer_area_per_molecule.py @@ -31,8 +31,8 @@ 'url': 'https://www.ncnr.nist.gov/resources/activation/', 'value': 4.186, 'unit': 'angstrom', - 'min': -np.Inf, - 'max': np.Inf, + 'min': -np.inf, + 'max': np.inf, 'fixed': True, }, 'isl': { @@ -40,8 +40,8 @@ 'url': 'https://www.ncnr.nist.gov/resources/activation/', 'value': 0.0, 'unit': 'angstrom', - 'min': -np.Inf, - 'max': np.Inf, + 'min': -np.inf, + 'max': np.inf, 'fixed': True, }, } diff --git a/src/easyreflectometry/sample/elements/materials/material.py b/src/easyreflectometry/sample/elements/materials/material.py index 1973426c..32942cc5 100644 --- a/src/easyreflectometry/sample/elements/materials/material.py +++ b/src/easyreflectometry/sample/elements/materials/material.py @@ -17,8 +17,8 @@ 'url': 'https://www.ncnr.nist.gov/resources/activation/', 'value': 4.186, 'unit': '1 / angstrom^2', - 'min': -np.Inf, - 'max': np.Inf, + 'min': -np.inf, + 'max': np.inf, 'fixed': True, }, 'isld': { @@ -26,8 +26,8 @@ 'url': 'https://www.ncnr.nist.gov/resources/activation/', 'value': 0.0, 'unit': '1 / angstrom^2', - 'min': -np.Inf, - 'max': np.Inf, + 'min': -np.inf, + 'max': np.inf, 'fixed': True, }, } diff --git a/src/easyreflectometry/sample/elements/materials/material_density.py b/src/easyreflectometry/sample/elements/materials/material_density.py index 388f6e84..57ed751e 100644 --- a/src/easyreflectometry/sample/elements/materials/material_density.py +++ b/src/easyreflectometry/sample/elements/materials/material_density.py @@ -22,7 +22,7 @@ 'value': 2.33, 'unit': 'gram / centimeter ** 3', 'min': 0, - 'max': np.Inf, + 'max': np.inf, 'fixed': True, }, 'molecular_weight': { @@ -30,8 +30,8 @@ 'url': 'https://en.wikipedia.org/wiki/Molecular_mass', 'value': 28.02, 'unit': 'g / mole', - 'min': -np.Inf, - 'max': np.Inf, + 'min': -np.inf, + 'max': np.inf, 'fixed': True, }, } diff --git a/tests/model/test_model.py b/tests/model/test_model.py index 0524a30e..45755e25 100644 --- a/tests/model/test_model.py +++ b/tests/model/test_model.py @@ -37,13 +37,13 @@ def test_default(self): assert_equal(str(p.scale.unit), 'dimensionless') assert_equal(p.scale.value, 1.0) assert_equal(p.scale.min, 0.0) - assert_equal(p.scale.max, np.Inf) + assert_equal(p.scale.max, np.inf) assert_equal(p.scale.fixed, True) assert_equal(p.background.display_name, 'background') assert_equal(str(p.background.unit), 'dimensionless') assert_equal(p.background.value, 1.0e-8) assert_equal(p.background.min, 0.0) - assert_equal(p.background.max, np.Inf) + assert_equal(p.background.max, np.inf) assert_equal(p.background.fixed, True) assert p._resolution_function.smearing([1]) == 5.0 assert p._resolution_function.smearing([100]) == 5.0 @@ -73,13 +73,13 @@ def test_from_pars(self): assert_equal(str(mod.scale.unit), 'dimensionless') assert_equal(mod.scale.value, 2.0) assert_equal(mod.scale.min, 0.0) - assert_equal(mod.scale.max, np.Inf) + assert_equal(mod.scale.max, np.inf) assert_equal(mod.scale.fixed, True) assert_equal(mod.background.display_name, 'background') assert_equal(str(mod.background.unit), 'dimensionless') assert_equal(mod.background.value, 1.0e-5) assert_equal(mod.background.min, 0.0) - assert_equal(mod.background.max, np.Inf) + assert_equal(mod.background.max, np.inf) assert_equal(mod.background.fixed, True) assert mod._resolution_function.smearing([1]) == 2.0 assert mod._resolution_function.smearing([100]) == 2.0 diff --git a/tests/sample/elements/layers/test_layer.py b/tests/sample/elements/layers/test_layer.py index 7d6cb6bd..1d66c19d 100644 --- a/tests/sample/elements/layers/test_layer.py +++ b/tests/sample/elements/layers/test_layer.py @@ -29,13 +29,13 @@ def test_no_arguments(self): assert_equal(str(p.thickness.unit), 'Å') assert_equal(p.thickness.value, 10.0) assert_equal(p.thickness.min, 0.0) - assert_equal(p.thickness.max, np.Inf) + assert_equal(p.thickness.max, np.inf) assert_equal(p.thickness.fixed, True) assert_equal(p.roughness.display_name, 'roughness') assert_equal(str(p.roughness.unit), 'Å') assert_equal(p.roughness.value, 3.3) assert_equal(p.roughness.min, 0.0) - assert_equal(p.roughness.max, np.Inf) + assert_equal(p.roughness.max, np.inf) assert_equal(p.roughness.fixed, True) def test_shuffled_arguments(self): @@ -48,13 +48,13 @@ def test_shuffled_arguments(self): assert_equal(str(p.thickness.unit), 'Å') assert_equal(p.thickness.value, 5.0) assert_equal(p.thickness.min, 0.0) - assert_equal(p.thickness.max, np.Inf) + assert_equal(p.thickness.max, np.inf) assert_equal(p.thickness.fixed, True) assert_equal(p.roughness.display_name, 'roughness') assert_equal(str(p.roughness.unit), 'Å') assert_equal(p.roughness.value, 2.0) assert_equal(p.roughness.min, 0.0) - assert_equal(p.roughness.max, np.Inf) + assert_equal(p.roughness.max, np.inf) assert_equal(p.roughness.fixed, True) def test_only_roughness_key(self): @@ -63,7 +63,7 @@ def test_only_roughness_key(self): assert_equal(str(p.roughness.unit), 'Å') assert_equal(p.roughness.value, 10.0) assert_equal(p.roughness.min, 0.0) - assert_equal(p.roughness.max, np.Inf) + assert_equal(p.roughness.max, np.inf) assert_equal(p.roughness.fixed, True) def test_only_roughness_key_paramter(self): @@ -79,7 +79,7 @@ def test_only_thickness_key(self): assert_equal(str(p.thickness.unit), 'Å') assert_equal(p.thickness.value, 10.0) assert_equal(p.thickness.min, 0.0) - assert_equal(p.thickness.max, np.Inf) + assert_equal(p.thickness.max, np.inf) assert_equal(p.thickness.fixed, True) def test_only_thickness_key_paramter(self): diff --git a/tests/sample/elements/materials/test_material.py b/tests/sample/elements/materials/test_material.py index 8ef9b9d0..0885c6a1 100644 --- a/tests/sample/elements/materials/test_material.py +++ b/tests/sample/elements/materials/test_material.py @@ -21,14 +21,14 @@ def test_no_arguments(self): assert p.sld.display_name == 'sld' assert str(p.sld.unit) == '1/Å^2' assert p.sld.value == 4.186 - assert p.sld.min == -np.Inf - assert p.sld.max == np.Inf + assert p.sld.min == -np.inf + assert p.sld.max == np.inf assert p.sld.fixed is True assert p.isld.display_name == 'isld' assert str(p.isld.unit) == '1/Å^2' assert p.isld.value == 0.0 - assert p.isld.min == -np.Inf - assert p.isld.max == np.Inf + assert p.isld.min == -np.inf + assert p.isld.max == np.inf assert p.isld.fixed is True def test_shuffled_arguments(self): @@ -38,14 +38,14 @@ def test_shuffled_arguments(self): assert p.sld.display_name == 'sld' assert str(p.sld.unit) == '1/Å^2' assert p.sld.value == 6.908 - assert p.sld.min == -np.Inf - assert p.sld.max == np.Inf + assert p.sld.min == -np.inf + assert p.sld.max == np.inf assert p.sld.fixed is True assert p.isld.display_name == 'isld' assert str(p.isld.unit) == '1/Å^2' assert p.isld.value == -0.278 - assert p.isld.min == -np.Inf - assert p.isld.max == np.Inf + assert p.isld.min == -np.inf + assert p.isld.max == np.inf assert p.isld.fixed is True def test_only_sld_key(self): @@ -53,8 +53,8 @@ def test_only_sld_key(self): assert p.sld.display_name == 'sld' assert str(p.sld.unit) == '1/Å^2' assert p.sld.value == 10 - assert p.sld.min == -np.Inf - assert p.sld.max == np.Inf + assert p.sld.min == -np.inf + assert p.sld.max == np.inf assert p.sld.fixed is True def test_only_sld_key_parameter(self): @@ -69,8 +69,8 @@ def test_only_isld_key(self): assert p.isld.display_name == 'isld' assert str(p.isld.unit) == '1/Å^2' assert p.isld.value == 10 - assert p.isld.min == -np.Inf - assert p.isld.max == np.Inf + assert p.isld.min == -np.inf + assert p.isld.max == np.inf assert p.isld.fixed is True def test_only_isld_key_parameter(self): diff --git a/tests/sample/elements/materials/test_material_density.py b/tests/sample/elements/materials/test_material_density.py index cc8b932c..315dab10 100644 --- a/tests/sample/elements/materials/test_material_density.py +++ b/tests/sample/elements/materials/test_material_density.py @@ -16,7 +16,7 @@ def test_default(self): assert str(p.density.unit) == 'kg/L' assert p.density.value == 2.33 assert p.density.min == 0 - assert p.density.max == np.Inf + assert p.density.max == np.inf assert p.density.fixed is True def test_default_constraint(self): diff --git a/tests/test_parameter_utils.py b/tests/test_parameter_utils.py index 8438031d..d8d2ce97 100644 --- a/tests/test_parameter_utils.py +++ b/tests/test_parameter_utils.py @@ -10,7 +10,7 @@ 'url': 'https://veryrealwebsite.com', 'value': 1.0, 'min': 0, - 'max': np.Inf, + 'max': np.inf, 'fixed': True, }, 'test_parameter_10': { @@ -36,7 +36,7 @@ def test_get_as_parameter(): assert_equal(str(test_parameter.unit), 'dimensionless') assert_equal(test_parameter.value, 1.0) assert_equal(test_parameter.min, 0.0) - assert_equal(test_parameter.max, np.Inf) + assert_equal(test_parameter.max, np.inf) assert_equal(test_parameter.fixed, True) assert_equal(test_parameter.description, 'Test parameter') @@ -96,7 +96,7 @@ def test_dict_remains_unchanged(): 'url': 'https://veryrealwebsite.com', 'value': 1.0, 'min': 0, - 'max': np.Inf, + 'max': np.inf, 'fixed': True, } } From 830bc03802cc00ddbd01614ee3a661f77075771c Mon Sep 17 00:00:00 2001 From: henrikjacobsenfys Date: Thu, 9 Jan 2025 16:05:49 +0100 Subject: [PATCH 2/9] update to new parameter --- pyproject.toml | 5 ++--- src/easyreflectometry/model/model.py | 2 +- src/easyreflectometry/project.py | 2 +- .../sample/assemblies/repeating_multilayer.py | 2 +- src/easyreflectometry/sample/assemblies/surfactant_layer.py | 2 +- src/easyreflectometry/sample/elements/layers/layer.py | 2 +- .../sample/elements/layers/layer_area_per_molecule.py | 2 +- src/easyreflectometry/sample/elements/materials/material.py | 2 +- .../sample/elements/materials/material_density.py | 2 +- .../sample/elements/materials/material_mixture.py | 2 +- .../sample/elements/materials/material_solvated.py | 2 +- src/easyreflectometry/utils.py | 2 +- tests/sample/elements/materials/test_material_solvated.py | 2 +- tests/test_project.py | 2 +- 14 files changed, 15 insertions(+), 16 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 76662a2b..c76fa49b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,12 +29,11 @@ classifiers = [ ] requires-python = ">=3.9,<3.13" dependencies = [ - "easyscience>=1.2.0", + "easyscience @git+https://github.com/EasyScience/EasyScience@remove_old_parameter", "scipp>=23.12.0", "refnx>=0.1.15", - "refl1d", + "refl1d[webview]==1.0.0a12", "orsopy>=0.0.4", - "pint==0.23", # Only to ensure that unit is reported as dimensionless rather than empty string "xhtml2pdf>=0.2.16" ] diff --git a/src/easyreflectometry/model/model.py b/src/easyreflectometry/model/model.py index 6d29f471..67f61507 100644 --- a/src/easyreflectometry/model/model.py +++ b/src/easyreflectometry/model/model.py @@ -9,7 +9,7 @@ import numpy as np from easyscience import global_object -from easyscience.Objects.new_variable import Parameter +from easyscience.Objects.variable import Parameter from easyscience.Objects.ObjectClasses import BaseObj from easyreflectometry.sample import BaseAssembly diff --git a/src/easyreflectometry/project.py b/src/easyreflectometry/project.py index 1270e617..de769ab8 100644 --- a/src/easyreflectometry/project.py +++ b/src/easyreflectometry/project.py @@ -11,7 +11,7 @@ from easyscience import global_object from easyscience.fitting import AvailableMinimizers from easyscience.fitting.fitter import DEFAULT_MINIMIZER -from easyscience.Objects.new_variable import Parameter +from easyscience.Objects.variable import Parameter from scipp import DataGroup from easyreflectometry.calculators import CalculatorFactory diff --git a/src/easyreflectometry/sample/assemblies/repeating_multilayer.py b/src/easyreflectometry/sample/assemblies/repeating_multilayer.py index e904c34c..f022d960 100644 --- a/src/easyreflectometry/sample/assemblies/repeating_multilayer.py +++ b/src/easyreflectometry/sample/assemblies/repeating_multilayer.py @@ -2,7 +2,7 @@ from typing import Union from easyscience import global_object -from easyscience.Objects.new_variable import Parameter +from easyscience.Objects.variable import Parameter from easyreflectometry.utils import get_as_parameter diff --git a/src/easyreflectometry/sample/assemblies/surfactant_layer.py b/src/easyreflectometry/sample/assemblies/surfactant_layer.py index b104d1e4..a7dbe1e3 100644 --- a/src/easyreflectometry/sample/assemblies/surfactant_layer.py +++ b/src/easyreflectometry/sample/assemblies/surfactant_layer.py @@ -4,7 +4,7 @@ from easyscience import global_object from easyscience.Constraints import ObjConstraint -from easyscience.Objects.new_variable import Parameter +from easyscience.Objects.variable import Parameter from ..collections.layer_collection import LayerCollection from ..elements.layers.layer_area_per_molecule import LayerAreaPerMolecule diff --git a/src/easyreflectometry/sample/elements/layers/layer.py b/src/easyreflectometry/sample/elements/layers/layer.py index 80dd9bdb..49d858a2 100644 --- a/src/easyreflectometry/sample/elements/layers/layer.py +++ b/src/easyreflectometry/sample/elements/layers/layer.py @@ -4,7 +4,7 @@ import numpy as np from easyscience import global_object -from easyscience.Objects.new_variable import Parameter +from easyscience.Objects.variable import Parameter from easyreflectometry.utils import get_as_parameter diff --git a/src/easyreflectometry/sample/elements/layers/layer_area_per_molecule.py b/src/easyreflectometry/sample/elements/layers/layer_area_per_molecule.py index 08e43d1a..dd010ec0 100644 --- a/src/easyreflectometry/sample/elements/layers/layer_area_per_molecule.py +++ b/src/easyreflectometry/sample/elements/layers/layer_area_per_molecule.py @@ -4,7 +4,7 @@ import numpy as np from easyscience import global_object from easyscience.Constraints import FunctionalConstraint -from easyscience.Objects.new_variable import Parameter +from easyscience.Objects.variable import Parameter from easyreflectometry.special.calculations import area_per_molecule_to_scattering_length_density from easyreflectometry.special.calculations import neutron_scattering_length diff --git a/src/easyreflectometry/sample/elements/materials/material.py b/src/easyreflectometry/sample/elements/materials/material.py index 32942cc5..9c9220e4 100644 --- a/src/easyreflectometry/sample/elements/materials/material.py +++ b/src/easyreflectometry/sample/elements/materials/material.py @@ -5,7 +5,7 @@ import numpy as np from easyscience import global_object -from easyscience.Objects.new_variable import Parameter +from easyscience.Objects.variable import Parameter from easyreflectometry.utils import get_as_parameter diff --git a/src/easyreflectometry/sample/elements/materials/material_density.py b/src/easyreflectometry/sample/elements/materials/material_density.py index 57ed751e..1f7890b7 100644 --- a/src/easyreflectometry/sample/elements/materials/material_density.py +++ b/src/easyreflectometry/sample/elements/materials/material_density.py @@ -4,7 +4,7 @@ import numpy as np from easyscience import global_object from easyscience.Constraints import FunctionalConstraint -from easyscience.Objects.new_variable import Parameter +from easyscience.Objects.variable import Parameter from easyreflectometry.special.calculations import density_to_sld from easyreflectometry.special.calculations import molecular_weight diff --git a/src/easyreflectometry/sample/elements/materials/material_mixture.py b/src/easyreflectometry/sample/elements/materials/material_mixture.py index f3f558d9..cee47a9f 100644 --- a/src/easyreflectometry/sample/elements/materials/material_mixture.py +++ b/src/easyreflectometry/sample/elements/materials/material_mixture.py @@ -3,7 +3,7 @@ from easyscience import global_object from easyscience.Constraints import FunctionalConstraint -from easyscience.Objects.new_variable import Parameter +from easyscience.Objects.variable import Parameter from easyreflectometry.special.calculations import weighted_average from easyreflectometry.utils import get_as_parameter diff --git a/src/easyreflectometry/sample/elements/materials/material_solvated.py b/src/easyreflectometry/sample/elements/materials/material_solvated.py index db68a0f9..74f6ab31 100644 --- a/src/easyreflectometry/sample/elements/materials/material_solvated.py +++ b/src/easyreflectometry/sample/elements/materials/material_solvated.py @@ -2,7 +2,7 @@ from typing import Union from easyscience import global_object -from easyscience.Objects.new_variable import Parameter +from easyscience.Objects.variable import Parameter from easyreflectometry.utils import get_as_parameter diff --git a/src/easyreflectometry/utils.py b/src/easyreflectometry/utils.py index 00138804..176afe6e 100644 --- a/src/easyreflectometry/utils.py +++ b/src/easyreflectometry/utils.py @@ -5,7 +5,7 @@ import yaml from easyscience import global_object -from easyscience.Objects.new_variable import Parameter +from easyscience.Objects.variable import Parameter def get_as_parameter( diff --git a/tests/sample/elements/materials/test_material_solvated.py b/tests/sample/elements/materials/test_material_solvated.py index 4fe90cd7..abce4c1c 100644 --- a/tests/sample/elements/materials/test_material_solvated.py +++ b/tests/sample/elements/materials/test_material_solvated.py @@ -2,7 +2,7 @@ import pytest from easyscience import global_object -from easyscience.Objects.new_variable import Parameter +from easyscience.Objects.variable import Parameter import easyreflectometry.sample.elements.materials.material_mixture import easyreflectometry.sample.elements.materials.material_solvated diff --git a/tests/test_project.py b/tests/test_project.py index 66b92041..523138c3 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -6,7 +6,7 @@ import numpy as np from easyscience import global_object from easyscience.fitting import AvailableMinimizers -from easyscience.Objects.new_variable import Parameter +from easyscience.Objects.variable import Parameter from numpy.testing import assert_allclose import easyreflectometry From 2fd388b406a99014d5e50579f3360ab49a6fa798 Mon Sep 17 00:00:00 2001 From: henrikjacobsenfys Date: Thu, 9 Jan 2025 17:03:54 +0100 Subject: [PATCH 3/9] Update imports from Refl1d --- .../calculators/refl1d/wrapper.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/easyreflectometry/calculators/refl1d/wrapper.py b/src/easyreflectometry/calculators/refl1d/wrapper.py index d3a2a809..ca2a66a8 100644 --- a/src/easyreflectometry/calculators/refl1d/wrapper.py +++ b/src/easyreflectometry/calculators/refl1d/wrapper.py @@ -3,8 +3,9 @@ from typing import Tuple import numpy as np -from refl1d import model +# from refl1d import model from refl1d import names +from refl1d.sample.layers import Repeat from easyreflectometry.model import PercentageFwhm @@ -34,7 +35,7 @@ def create_layer(self, name: str): magnetism = names.Magnetism(rhoM=0.0, thetaM=0.0) else: magnetism = None - self.storage['layer'][name] = model.Slab(name=str(name), magnetism=magnetism) + self.storage['layer'][name] = names.Slab(name=str(name), magnetism=magnetism) def create_item(self, name: str): """ @@ -42,8 +43,8 @@ def create_item(self, name: str): :param name: The name of the item """ - self.storage['item'][name] = model.Repeat( - model.Stack(model.Slab(names.SLD(), thickness=0, interface=0)), name=str(name) + self.storage['item'][name] = Repeat( + names.Stack(names.Slab(names.SLD(), thickness=0, interface=0)), name=str(name) ) del self.storage['item'][name].stack[0] @@ -267,8 +268,8 @@ def _get_polarized_probe( return names.PolarizedQProbe(xs=four_probes, name='polarized') -def _build_sample(storage: dict, model_name: str) -> model.Stack: - sample = model.Stack() +def _build_sample(storage: dict, model_name: str) -> names.Stack: + sample = names.Stack() # -1 to reverse the order for i in storage['model'][model_name]['items'][::-1]: if i.repeat.value == 1: @@ -276,9 +277,9 @@ def _build_sample(storage: dict, model_name: str) -> model.Stack: for j in range(len(i.stack))[::-1]: sample |= i.stack[j] else: - stack = model.Stack() + stack = names.Stack() # -1 to reverse the order for j in range(len(i.stack))[::-1]: stack |= i.stack[j] - sample |= model.Repeat(stack, repeat=i.repeat.value) + sample |= Repeat(stack, repeat=i.repeat.value) return sample From e66ec1ac09afb6d526277848cc7276a5afd70cda Mon Sep 17 00:00:00 2001 From: henrikjacobsenfys Date: Thu, 9 Jan 2025 17:17:48 +0100 Subject: [PATCH 4/9] Update imports --- src/easyreflectometry/calculators/refl1d/wrapper.py | 2 +- tests/calculators/refl1d/test_refl1d_wrapper.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/easyreflectometry/calculators/refl1d/wrapper.py b/src/easyreflectometry/calculators/refl1d/wrapper.py index ca2a66a8..7a75afe8 100644 --- a/src/easyreflectometry/calculators/refl1d/wrapper.py +++ b/src/easyreflectometry/calculators/refl1d/wrapper.py @@ -67,7 +67,7 @@ def get_layer_value(self, name: str, key: str) -> float: :param key: The given value keys """ if key in ['magnetism_rhoM', 'magnetism_thetaM']: - return getattr(self.storage['layer'][name].magnetism, key.split('_')[-1]) + return getattr(self.storage['layer'][name].magnetism, key.split('_')[-1]).value #TODO: check if we want to return the raw value or the full Parameter # noqa: E501 return super().get_layer_value(name, key) def create_model(self, name: str): diff --git a/tests/calculators/refl1d/test_refl1d_wrapper.py b/tests/calculators/refl1d/test_refl1d_wrapper.py index 6753a439..a78d61b1 100644 --- a/tests/calculators/refl1d/test_refl1d_wrapper.py +++ b/tests/calculators/refl1d/test_refl1d_wrapper.py @@ -425,8 +425,8 @@ def test_get_polarized_probe_polarization(): assert len(probe.xs[3].calc_Qo) == len(q) -@patch('easyreflectometry.calculators.refl1d.wrapper.model.Stack') -@patch('easyreflectometry.calculators.refl1d.wrapper.model.Repeat') +@patch('easyreflectometry.calculators.refl1d.wrapper.names.Stack') +@patch('easyreflectometry.calculators.refl1d.wrapper.Repeat') def test_build_sample(mock_repeat, mock_stack): # When mock_item_1 = MagicMock() From 76bd3b397caad1301753a5a9f58785ad876cecb5 Mon Sep 17 00:00:00 2001 From: henrikjacobsenfys Date: Thu, 9 Jan 2025 17:22:00 +0100 Subject: [PATCH 5/9] make ruff happy --- src/easyreflectometry/calculators/refl1d/wrapper.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/easyreflectometry/calculators/refl1d/wrapper.py b/src/easyreflectometry/calculators/refl1d/wrapper.py index 7a75afe8..b211d1d4 100644 --- a/src/easyreflectometry/calculators/refl1d/wrapper.py +++ b/src/easyreflectometry/calculators/refl1d/wrapper.py @@ -3,7 +3,6 @@ from typing import Tuple import numpy as np -# from refl1d import model from refl1d import names from refl1d.sample.layers import Repeat From 470219f8c36fc2ae1672106075ab191aa6459ee9 Mon Sep 17 00:00:00 2001 From: henrikjacobsenfys Date: Thu, 9 Jan 2025 17:26:24 +0100 Subject: [PATCH 6/9] make ruff happy --- src/easyreflectometry/model/model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/easyreflectometry/model/model.py b/src/easyreflectometry/model/model.py index 67f61507..969c955a 100644 --- a/src/easyreflectometry/model/model.py +++ b/src/easyreflectometry/model/model.py @@ -9,8 +9,8 @@ import numpy as np from easyscience import global_object -from easyscience.Objects.variable import Parameter from easyscience.Objects.ObjectClasses import BaseObj +from easyscience.Objects.variable import Parameter from easyreflectometry.sample import BaseAssembly from easyreflectometry.sample import Sample From 6ddf1b89ad0a9af37222766cb8fc74bc8f565d0c Mon Sep 17 00:00:00 2001 From: henrikjacobsenfys Date: Fri, 10 Jan 2025 09:04:03 +0100 Subject: [PATCH 7/9] Removed Python 3.9 --- .github/workflows/python-ci.yml | 2 +- .github/workflows/python-package.yml | 2 +- .github/workflows/python-publish.yml | 2 +- CONTRIBUTING.rst | 2 +- pyproject.toml | 6 ++---- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml index 1eed04bb..956c4793 100644 --- a/.github/workflows/python-ci.yml +++ b/.github/workflows/python-ci.yml @@ -30,7 +30,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: ['3.9', '3.10', '3.11', '3.12'] + python-version: ['3.10', '3.11', '3.12'] os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 9b42c1de..e2fc15df 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.9', '3.10', '3.11'] + python-version: ['3.10', '3.11','3.12'] if: "!contains(github.event.head_commit.message, '[ci skip]')" steps: diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 0da371b7..bc12d4e9 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -27,7 +27,7 @@ jobs: - uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: 3.10 - name: Install dependencies and build run: | diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index d7f8646e..13df4c78 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -102,7 +102,7 @@ Before you submit a pull request, check that it meets these guidelines: 2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.md. -3. The pull request should work for Python 3.9, 3.10, and 3.11, and for PyPy. Check +3. The pull request should work for Python, 3.10, 3.11 and 3.12, and for PyPy. Check https://travis-ci.com/easyScience/EasyReflectometryLib/pull_requests and make sure that the tests pass for all supported Python versions. diff --git a/pyproject.toml b/pyproject.toml index c76fa49b..71611b9c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,13 +21,12 @@ classifiers = [ "Topic :: Scientific/Engineering", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Development Status :: 3 - Alpha" ] -requires-python = ">=3.9,<3.13" +requires-python = ">=3.10,<3.13" dependencies = [ "easyscience @git+https://github.com/EasyScience/EasyScience@remove_old_parameter", "scipp>=23.12.0", @@ -130,10 +129,9 @@ force-single-line = true legacy_tox_ini = """ [tox] isolated_build = True -envlist = py{3.9,3.10,3.11,3.12} +envlist = py{3.10,3.11,3.12} [gh-actions] python = - 3.9: py39 3.10: py310 3.11: py311 3.12: py312 From de4e6c79c61850e97e062e6c1d5e5a1fd0498a80 Mon Sep 17 00:00:00 2001 From: henrikjacobsenfys Date: Fri, 10 Jan 2025 09:10:34 +0100 Subject: [PATCH 8/9] Update ci --- .github/workflows/documentation-build.yml | 2 +- .github/workflows/python-ci.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/documentation-build.yml b/.github/workflows/documentation-build.yml index 30f49425..d628da20 100644 --- a/.github/workflows/documentation-build.yml +++ b/.github/workflows/documentation-build.yml @@ -34,7 +34,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: 3.11 - name: Install Pandoc, repo and dependencies run: | sudo apt install pandoc diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml index 956c4793..837ad854 100644 --- a/.github/workflows/python-ci.yml +++ b/.github/workflows/python-ci.yml @@ -74,7 +74,7 @@ jobs: - uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: 3.11 - name: Install dependencies and build run: | From fa301b825f87b6c9f542f41b814f2f3812fdb1c5 Mon Sep 17 00:00:00 2001 From: henrikjacobsenfys Date: Mon, 20 Jan 2025 14:29:55 +0100 Subject: [PATCH 9/9] change dependency --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 71611b9c..67addb4d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,7 @@ classifiers = [ ] requires-python = ">=3.10,<3.13" dependencies = [ - "easyscience @git+https://github.com/EasyScience/EasyScience@remove_old_parameter", + "easyscience @git+https://github.com/EasyScience/EasyScience@develop", "scipp>=23.12.0", "refnx>=0.1.15", "refl1d[webview]==1.0.0a12",