From aeebf5d2b798c30fa345d2b0be6008bc361bde8c Mon Sep 17 00:00:00 2001 From: henrikjacobsenfys Date: Tue, 7 Jan 2025 13:56:20 +0100 Subject: [PATCH] Update tests to match new ref1d --- pyproject.toml | 2 +- tests/sample/assemblies/test_surfactant_layer.py | 5 +++-- .../layers/test_layer_area_per_molecule.py | 16 ++++++++-------- .../elements/materials/test_material_density.py | 10 +++++----- tests/special/test_calculations.py | 2 +- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4c95bda3..76662a2b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ dependencies = [ "easyscience>=1.2.0", "scipp>=23.12.0", "refnx>=0.1.15", - "refl1d>=0.8.14", + "refl1d", "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/tests/sample/assemblies/test_surfactant_layer.py b/tests/sample/assemblies/test_surfactant_layer.py index 85672708..b6b25243 100644 --- a/tests/sample/assemblies/test_surfactant_layer.py +++ b/tests/sample/assemblies/test_surfactant_layer.py @@ -101,6 +101,7 @@ def test_constain_solvent_roughness(self): def test_dict_repr(self): p = SurfactantLayer() + assert p._dict_repr == { 'EasySurfactantLayer': { 'head_layer': { @@ -125,9 +126,9 @@ def test_dict_repr(self): 'material': { 'C32D64 in Air': { 'solvent_fraction': '0.000 dimensionless', - 'sld': '8.297e-6 1/Å^2', + 'sld': '8.292e-6 1/Å^2', 'isld': '0.000e-6 1/Å^2', - 'material': {'C32D64': {'sld': '8.297e-6 1/Å^2', 'isld': '0.000e-6 1/Å^2'}}, + 'material': {'C32D64': {'sld': '8.292e-6 1/Å^2', 'isld': '0.000e-6 1/Å^2'}}, 'solvent': {'Air': {'sld': '0.000e-6 1/Å^2', 'isld': '0.000e-6 1/Å^2'}}, } }, diff --git a/tests/sample/elements/layers/test_layer_area_per_molecule.py b/tests/sample/elements/layers/test_layer_area_per_molecule.py index acfabd9f..97011261 100644 --- a/tests/sample/elements/layers/test_layer_area_per_molecule.py +++ b/tests/sample/elements/layers/test_layer_area_per_molecule.py @@ -24,7 +24,7 @@ def test_default(self): assert p.roughness.value == 3.3 assert str(p.roughness.unit) == 'Å' assert p.roughness.fixed is True - assert_almost_equal(p.material.sld, 2.2691419) + assert_almost_equal(p.material.sld, 2.268770124481328) assert_almost_equal(p.material.isld, 0) assert p.material.name == 'C10H18NO8P in D2O' assert p.solvent.sld.value == 6.36 @@ -66,7 +66,7 @@ def test_from_pars_constraint(self): ) assert p.molecular_formula == 'C8O10H12P' assert p.area_per_molecule == 50 - assert_almost_equal(p.material.sld, 0.31513666667) + assert_almost_equal(p.material.sld, 0.31494833333333333) assert p.thickness.value == 12 assert p.roughness.value == 2 assert p.solvent.sld.value == -0.561 @@ -74,10 +74,10 @@ def test_from_pars_constraint(self): assert p.solvent_fraction == 0.5 p.area_per_molecule = 30 assert p.area_per_molecule == 30 - assert_almost_equal(p.material.sld, 0.712227778) + assert_almost_equal(p.material.sld, 0.7119138888888887) p.thickness.value = 10 assert p.thickness.value == 10 - assert_almost_equal(p.material.sld, 0.910773333) + assert_almost_equal(p.material.sld, 0.9103966666666665) def test_solvent_change(self): h2o = Material(-0.561, 0, 'H2O') @@ -93,7 +93,7 @@ def test_solvent_change(self): assert p.molecular_formula == 'C8O10H12P' assert p.area_per_molecule == 50 print(p.material) - assert_almost_equal(p.material.sld, 0.31513666667) + assert_almost_equal(p.material.sld, 0.31494833333333333) assert p.thickness.value == 12 assert p.roughness.value == 2 assert p.solvent.sld.value == -0.561 @@ -103,7 +103,7 @@ def test_solvent_change(self): p.solvent = d2o assert p.molecular_formula == 'C8O10H12P' assert p.area_per_molecule == 50 - assert_almost_equal(p.material.sld, 3.7631366667) + assert_almost_equal(p.material.sld, 3.762948333333333) assert p.thickness.value == 12 assert p.roughness.value == 2 assert p.solvent.sld.value == 6.335 @@ -123,7 +123,7 @@ def test_molecular_formula_change(self): ) assert p.molecular_formula == 'C8O10H12P' assert p.area_per_molecule == 50 - assert_almost_equal(p.material.sld, 0.31513666667) + assert_almost_equal(p.material.sld, 0.31494833333333333) assert p.thickness.value == 12 assert p.roughness.value == 2 @@ -134,7 +134,7 @@ def test_molecular_formula_change(self): p.molecular_formula = 'C8O10D12P' assert p.molecular_formula == 'C8O10D12P' assert p.area_per_molecule == 50 - assert_almost_equal(p.material.sld, 1.3566266666666666) + assert_almost_equal(p.material.sld, 1.3558483333333333) assert p.thickness.value == 12 assert p.roughness.value == 2 assert p.solvent.sld.value == -0.561 diff --git a/tests/sample/elements/materials/test_material_density.py b/tests/sample/elements/materials/test_material_density.py index cde67369..cc8b932c 100644 --- a/tests/sample/elements/materials/test_material_density.py +++ b/tests/sample/elements/materials/test_material_density.py @@ -22,25 +22,25 @@ def test_default(self): def test_default_constraint(self): p = MaterialDensity() assert p.density.value == 2.33 - assert_almost_equal(p.sld.value, 2.073705382) + assert_almost_equal(p.sld.value, 2.0737423003838087) p.density.value = 2 - assert_almost_equal(p.sld.value, 1.780004619) + assert_almost_equal(p.sld.value, 1.7800363093423253) def test_from_pars(self): p = MaterialDensity('Co', 8.9, 'Cobalt') assert p.density.value == 8.9 - assert_almost_equal(p.sld.value, 2.2645412328256) + assert_almost_equal(p.sld.value,2.264541463379026) assert p.chemical_structure == 'Co' def test_chemical_structure_change(self): p = MaterialDensity('Co', 8.9, 'Cobolt') assert p.density.value == 8.9 - assert_almost_equal(p.sld.value, 2.2645412328256) + assert_almost_equal(p.sld.value, 2.264541463379026) assert_almost_equal(p.isld.value, 0.0) assert p.chemical_structure == 'Co' p.chemical_structure = 'B' assert p.density.value == 8.9 - assert_almost_equal(p.sld.value, 4.820107844970) + assert_almost_equal(p.sld.value, 4.82010833570636) assert_almost_equal(p.isld.value, -0.19098540517806603) assert p.chemical_structure == 'B' diff --git a/tests/special/test_calculations.py b/tests/special/test_calculations.py index 3e3211a2..e7f1f89f 100644 --- a/tests/special/test_calculations.py +++ b/tests/special/test_calculations.py @@ -27,7 +27,7 @@ def test_neutron_scattering_length_B(self) -> None: def test_molecular_weight(self) -> None: a = molecular_weight('H2O') - assert_almost_equal(a, 18.01528) + assert_almost_equal(a, 18.015) def test_area_per_molecule_to_sld(self) -> None: a = area_per_molecule_to_scattering_length_density(2, 1, 0.5)