Skip to content

Commit b1ca245

Browse files
New parameter and Numpy2 (#209)
* update np.Inf to match Numpy2 * update to new parameter * Update imports from Refl1d * Update imports * make ruff happy * make ruff happy * Removed Python 3.9 * Update ci * change dependency * Update dependency on EasyScience * Pin dependencies
1 parent f9fc7ef commit b1ca245

26 files changed

+103
-103
lines changed

.github/workflows/documentation-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- name: Set up Python
3535
uses: actions/setup-python@v5
3636
with:
37-
python-version: 3.9
37+
python-version: 3.11
3838
- name: Install Pandoc, repo and dependencies
3939
run: |
4040
sudo apt install pandoc

.github/workflows/python-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
strategy:
3131
max-parallel: 4
3232
matrix:
33-
python-version: ['3.9', '3.10', '3.11', '3.12']
33+
python-version: ['3.10', '3.11', '3.12']
3434
os: [ubuntu-latest, macos-latest, windows-latest]
3535

3636
runs-on: ${{ matrix.os }}
@@ -74,7 +74,7 @@ jobs:
7474

7575
- uses: actions/setup-python@v5
7676
with:
77-
python-version: 3.9
77+
python-version: 3.11
7878

7979
- name: Install dependencies and build
8080
run: |

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ubuntu-latest
1919
strategy:
2020
matrix:
21-
python-version: ['3.9', '3.10', '3.11']
21+
python-version: ['3.10', '3.11','3.12']
2222
if: "!contains(github.event.head_commit.message, '[ci skip]')"
2323

2424
steps:

.github/workflows/python-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727

2828
- uses: actions/setup-python@v5
2929
with:
30-
python-version: 3.9
30+
python-version: 3.10
3131

3232
- name: Install dependencies and build
3333
run: |

CONTRIBUTING.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Before you submit a pull request, check that it meets these guidelines:
102102
2. If the pull request adds functionality, the docs should be updated. Put
103103
your new functionality into a function with a docstring, and add the
104104
feature to the list in README.md.
105-
3. The pull request should work for Python 3.9, 3.10, and 3.11, and for PyPy. Check
105+
3. The pull request should work for Python, 3.10, 3.11 and 3.12, and for PyPy. Check
106106
https://travis-ci.com/easyScience/EasyReflectometryLib/pull_requests
107107
and make sure that the tests pass for all supported Python versions.
108108

pyproject.toml

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,48 +21,49 @@ classifiers = [
2121
"Topic :: Scientific/Engineering",
2222
"Programming Language :: Python :: 3",
2323
"Programming Language :: Python :: 3 :: Only",
24-
"Programming Language :: Python :: 3.9",
2524
"Programming Language :: Python :: 3.10",
2625
"Programming Language :: Python :: 3.11",
2726
"Programming Language :: Python :: 3.12",
2827
"Development Status :: 3 - Alpha"
2928
]
30-
requires-python = ">=3.9,<3.13"
29+
30+
requires-python = ">=3.10,<3.13"
31+
3132
dependencies = [
32-
"easyscience>=1.2.0",
33-
"scipp>=23.12.0",
34-
"refnx>=0.1.15",
35-
"refl1d",
36-
"orsopy>=0.0.4",
37-
"pint==0.23", # Only to ensure that unit is reported as dimensionless rather than empty string
38-
"xhtml2pdf>=0.2.16"
33+
"easyscience==1.3.0",
34+
"scipp==25.2.0",
35+
"refnx==0.1.52",
36+
"refl1d[webview]==1.0.0a12",
37+
"orsopy==1.2.1",
38+
"xhtml2pdf==0.2.17",
3939
]
4040

4141
[project.optional-dependencies]
4242
dev = [
43-
"build",
44-
"codecov>=2.1.11",
45-
"coverage",
46-
"coveralls",
47-
"flake8>=6.0.0",
48-
"ipykernel",
49-
"jupyter>=1.0.0",
50-
"jupyterlab",
51-
"plopp",
52-
"pooch",
53-
"pytest>=5.2",
54-
"pytest-cov>=3.0.0",
55-
"ruff",
56-
"toml>=0.10",
57-
"yapf>=0.31.0",
43+
"build==1.2.2.post1",
44+
"codecov==2.1.13",
45+
"coverage==7.7.0",
46+
"coveralls==4.0.1",
47+
"flake8==7.1.2",
48+
"ipykernel==6.29.5",
49+
"jupyter==1.1.1",
50+
"jupyterlab==4.3.6",
51+
"plopp==25.3.0",
52+
"pooch==1.8.2",
53+
"pytest==8.3.5",
54+
"pytest-cov==6.0.0",
55+
"ruff==0.11.0",
56+
"toml==0.10.2",
57+
"yapf==0.43.0",
5858
]
59+
5960
docs = [
60-
"myst_parser",
61-
"nbsphinx",
62-
"sphinx_autodoc_typehints",
63-
"sphinx_book_theme",
64-
"sphinx-copybutton",
65-
"toml"
61+
"myst_parser==4.0.1",
62+
"nbsphinx==0.9.7",
63+
"sphinx_autodoc_typehints==3.0.1",
64+
"sphinx_book_theme==1.1.4",
65+
"sphinx-copybutton==0.5.2",
66+
"toml==0.10.2",
6667
]
6768

6869
[project.urls]
@@ -131,10 +132,9 @@ force-single-line = true
131132
legacy_tox_ini = """
132133
[tox]
133134
isolated_build = True
134-
envlist = py{3.9,3.10,3.11,3.12}
135+
envlist = py{3.10,3.11,3.12}
135136
[gh-actions]
136137
python =
137-
3.9: py39
138138
3.10: py310
139139
3.11: py311
140140
3.12: py312

src/easyreflectometry/calculators/refl1d/wrapper.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from typing import Tuple
44

55
import numpy as np
6-
from refl1d import model
76
from refl1d import names
7+
from refl1d.sample.layers import Repeat
88

99
from easyreflectometry.model import PercentageFwhm
1010

@@ -34,16 +34,16 @@ def create_layer(self, name: str):
3434
magnetism = names.Magnetism(rhoM=0.0, thetaM=0.0)
3535
else:
3636
magnetism = None
37-
self.storage['layer'][name] = model.Slab(name=str(name), magnetism=magnetism)
37+
self.storage['layer'][name] = names.Slab(name=str(name), magnetism=magnetism)
3838

3939
def create_item(self, name: str):
4040
"""
4141
Create an item using Repeat.
4242
4343
:param name: The name of the item
4444
"""
45-
self.storage['item'][name] = model.Repeat(
46-
model.Stack(model.Slab(names.SLD(), thickness=0, interface=0)), name=str(name)
45+
self.storage['item'][name] = Repeat(
46+
names.Stack(names.Slab(names.SLD(), thickness=0, interface=0)), name=str(name)
4747
)
4848
del self.storage['item'][name].stack[0]
4949

@@ -66,7 +66,7 @@ def get_layer_value(self, name: str, key: str) -> float:
6666
:param key: The given value keys
6767
"""
6868
if key in ['magnetism_rhoM', 'magnetism_thetaM']:
69-
return getattr(self.storage['layer'][name].magnetism, key.split('_')[-1])
69+
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
7070
return super().get_layer_value(name, key)
7171

7272
def create_model(self, name: str):
@@ -267,18 +267,18 @@ def _get_polarized_probe(
267267
return names.PolarizedQProbe(xs=four_probes, name='polarized')
268268

269269

270-
def _build_sample(storage: dict, model_name: str) -> model.Stack:
271-
sample = model.Stack()
270+
def _build_sample(storage: dict, model_name: str) -> names.Stack:
271+
sample = names.Stack()
272272
# -1 to reverse the order
273273
for i in storage['model'][model_name]['items'][::-1]:
274274
if i.repeat.value == 1:
275275
# -1 to reverse the order
276276
for j in range(len(i.stack))[::-1]:
277277
sample |= i.stack[j]
278278
else:
279-
stack = model.Stack()
279+
stack = names.Stack()
280280
# -1 to reverse the order
281281
for j in range(len(i.stack))[::-1]:
282282
stack |= i.stack[j]
283-
sample |= model.Repeat(stack, repeat=i.repeat.value)
283+
sample |= Repeat(stack, repeat=i.repeat.value)
284284
return sample

src/easyreflectometry/model/model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
import numpy as np
1111
from easyscience import global_object
12-
from easyscience.Objects.new_variable import Parameter
1312
from easyscience.Objects.ObjectClasses import BaseObj
13+
from easyscience.Objects.variable import Parameter
1414

1515
from easyreflectometry.sample import BaseAssembly
1616
from easyreflectometry.sample import Sample
@@ -26,15 +26,15 @@
2626
'url': 'https://github.com/reflectivity/edu_outreach/blob/master/refl_maths/paper.tex',
2727
'value': 1.0,
2828
'min': 0,
29-
'max': np.Inf,
29+
'max': np.inf,
3030
'fixed': True,
3131
},
3232
'background': {
3333
'description': 'Linear background to include in reflectometry data',
3434
'url': 'https://github.com/reflectivity/edu_outreach/blob/master/refl_maths/paper.tex',
3535
'value': 1e-8,
3636
'min': 0.0,
37-
'max': np.Inf,
37+
'max': np.inf,
3838
'fixed': True,
3939
},
4040
'resolution': {

src/easyreflectometry/project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from easyscience import global_object
1212
from easyscience.fitting import AvailableMinimizers
1313
from easyscience.fitting.fitter import DEFAULT_MINIMIZER
14-
from easyscience.Objects.new_variable import Parameter
14+
from easyscience.Objects.variable import Parameter
1515
from scipp import DataGroup
1616

1717
from easyreflectometry.calculators import CalculatorFactory

src/easyreflectometry/sample/assemblies/repeating_multilayer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import Union
33

44
from easyscience import global_object
5-
from easyscience.Objects.new_variable import Parameter
5+
from easyscience.Objects.variable import Parameter
66

77
from easyreflectometry.utils import get_as_parameter
88

0 commit comments

Comments
 (0)