Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numpy2 #170

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: ['3.9', '3.10', '3.11']
python-version: ['3.10', '3.11']
os: [ubuntu-latest, macos-latest, windows-latest]

runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:

- uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: '3.10'

- name: Install dependencies and build
run: |
Expand Down
8 changes: 3 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,19 @@ 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.12"
requires-python = ">=3.10,<3.12"
dependencies = [
'easyscience @ git+https://github.com/EasyScience/EasyScience.git@develop',
"scipp>=23.12.0",
"refnx>=0.1.15",
"refl1d>=0.8.14",
"orsopy>=0.0.4",
"pint==0.23" # Only to ensure that unit is reported as dimensionless rather than empty string
"pint==0.24" # Only to ensure that unit is reported as dimensionless rather than empty string
]

[project.optional-dependencies]
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/easyreflectometry/experiment/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
'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': {
'description': 'Linear background to include in reflectometry data',
'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': {
Expand Down
4 changes: 2 additions & 2 deletions src/easyreflectometry/sample/elements/layers/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
'value': 10.0,
'unit': 'angstrom',
'min': 0.0,
'max': np.Inf,
'max': np.inf,
'fixed': True,
},
'roughness': {
Expand All @@ -27,7 +27,7 @@
'value': 3.3,
'unit': 'angstrom',
'min': 0.0,
'max': np.Inf,
'max': np.inf,
'fixed': True,
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@
'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': {
'description': 'The real scattering length for a molecule formula in angstrom.',
'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,
},
}
Expand Down
8 changes: 4 additions & 4 deletions src/easyreflectometry/sample/elements/materials/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
'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': {
'description': 'The imaginary scattering length density for a material in e-6 per squared angstrom.',
'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,
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
'value': 2.33,
'unit': 'gram / centimeter ** 3',
'min': 0,
'max': np.Inf,
'max': np.inf,
'fixed': True,
},
'molecular_weight': {
'description': 'The molecular weight of a material.',
'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,
},
}
Expand Down
8 changes: 4 additions & 4 deletions tests/experiment/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions tests/sample/elements/layers/test_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand Down
24 changes: 12 additions & 12 deletions tests/sample/elements/materials/test_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,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):
Expand All @@ -41,23 +41,23 @@ 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):
p = Material(sld=10)
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):
Expand All @@ -72,8 +72,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):
Expand Down
2 changes: 1 addition & 1 deletion tests/sample/elements/materials/test_material_density.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_parameter_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
'url': 'https://veryrealwebsite.com',
'value': 1.0,
'min': 0,
'max': np.Inf,
'max': np.inf,
'fixed': True,
},
'test_parameter_10': {
Expand All @@ -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')

Expand Down Expand Up @@ -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,
}
}
Expand Down
Loading