Skip to content

Commit c7e2ec4

Browse files
authored
Merge pull request #106 from easyscience/develop
Release 1.3.0
2 parents 5fdd558 + d83380a commit c7e2ec4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2735
-3367
lines changed

.github/workflows/documentation-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Set up Python
3333
uses: actions/setup-python@v5
3434
with:
35-
python-version: 3.9
35+
python-version: 3.10
3636
- name: Install Pandoc, repo and dependencies
3737
run: |
3838
sudo apt install pandoc

.github/workflows/python-ci.yml

Lines changed: 1 addition & 1 deletion
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', '3.13']
3434
os: [ubuntu-latest, macos-latest, windows-latest]
3535

3636
runs-on: ${{ matrix.os }}

.github/workflows/python-package.yml

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

2727
steps:

.github/workflows/python-publish.yml

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

2929
- uses: actions/setup-python@v5
3030
with:
31-
python-version: 3.9
31+
python-version: 3.10
3232

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

pyproject.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@ 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",
27+
"Programming Language :: Python :: 3.13",
2828
"Development Status :: 3 - Alpha"
2929
]
30-
requires-python = ">=3.9,<3.13"
30+
requires-python = ">=3.10"
3131
dependencies = [
3232
"asteval",
3333
"bumps",
3434
"DFO-LS",
3535
"lmfit",
36-
"numpy==1.26", # Should be updated to numpy 2.0
36+
"numpy",
3737
"uncertainties",
3838
"xarray",
39-
"pint==0.23", # Only to ensure that unit is reported as dimensionless rather than empty string
39+
"pint", # Only to ensure that unit is reported as dimensionless rather than empty string
4040
"scipp"
4141
]
4242

@@ -128,13 +128,13 @@ force-single-line = true
128128
legacy_tox_ini = """
129129
[tox]
130130
isolated_build = True
131-
envlist = py{3.9,3.10,3.11,3.12}
131+
envlist = py{3.10,3.11,3.12,3.13}
132132
[gh-actions]
133133
python =
134-
3.9: py39
135134
3.10: py310
136135
3.11: py311
137136
3.12: py312
137+
3.13: py313
138138
[gh-actions:env]
139139
PLATFORM =
140140
ubuntu-latest: linux

src/easyscience/Constraints.py

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,9 @@ def __init__(self, dependent_obj: V, operator: str, value: Number):
194194
super(NumericConstraint, self).__init__(dependent_obj, operator=operator, value=value)
195195

196196
def _parse_operator(self, obj: V, *args, **kwargs) -> Number:
197-
## TODO clean when full move to new_variable
198-
import easyscience.Objects.new_variable.parameter
197+
## TODO Probably needs to be updated when DescriptorArray is implemented
199198

200-
if isinstance(obj, easyscience.Objects.new_variable.parameter.Parameter):
201-
value = obj.value_no_call_back
202-
else:
203-
value = obj.raw_value
199+
value = obj.value_no_call_back
204200

205201
if isinstance(value, list):
206202
value = np.array(value)
@@ -258,13 +254,7 @@ def __init__(self, dependent_obj: V, operator: str, value: str):
258254
super(SelfConstraint, self).__init__(dependent_obj, operator=operator, value=value)
259255

260256
def _parse_operator(self, obj: V, *args, **kwargs) -> Number:
261-
## TODO clean when full move to new_variable
262-
import easyscience.Objects.new_variable.parameter
263-
264-
if isinstance(obj, easyscience.Objects.new_variable.parameter.Parameter):
265-
value = obj.value_no_call_back
266-
else:
267-
value = obj.raw_value
257+
value = obj.value_no_call_back
268258

269259
self.aeval.symtable['value1'] = value
270260
self.aeval.symtable['value2'] = getattr(obj, self.value)
@@ -322,13 +312,7 @@ def __init__(self, dependent_obj: V, operator: str, independent_obj: V):
322312
self.external = True
323313

324314
def _parse_operator(self, obj: V, *args, **kwargs) -> Number:
325-
## TODO clean when full move to new_variable
326-
import easyscience.Objects.new_variable.parameter
327-
328-
if isinstance(obj, easyscience.Objects.new_variable.parameter.Parameter):
329-
value = obj.value_no_call_back
330-
else:
331-
value = obj.raw_value
315+
value = obj.value_no_call_back
332316

333317
self.aeval.symtable['value1'] = value
334318
try:
@@ -417,16 +401,11 @@ def __init__(
417401
self.external = True
418402

419403
def _parse_operator(self, independent_objs: List[V], *args, **kwargs) -> Number:
420-
import easyscience.Objects.new_variable.parameter
421404

422405
in_str = ''
423406
value = None
424407
for idx, obj in enumerate(independent_objs):
425-
## TODO clean when full move to new_variable
426-
if isinstance(obj, easyscience.Objects.new_variable.parameter.Parameter):
427-
self.aeval.symtable['p' + str(self.independent_obj_ids[idx])] = obj.value_no_call_back
428-
else:
429-
self.aeval.symtable['p' + str(self.independent_obj_ids[idx])] = obj.raw_value
408+
self.aeval.symtable['p' + str(self.independent_obj_ids[idx])] = obj.value_no_call_back
430409

431410
in_str += ' p' + str(self.independent_obj_ids[idx])
432411
if idx < len(self.operator):
@@ -485,25 +464,16 @@ def __init__(
485464
self.external = True
486465

487466
def _parse_operator(self, obj: V, *args, **kwargs) -> Number:
488-
import easyscience.Objects.new_variable.parameter
489467

490468
self.aeval.symtable[f'f{id(self.function)}'] = self.function
491469
value_str = f'r_value = f{id(self.function)}('
492470
if isinstance(obj, list):
493471
for o in obj:
494-
## TODO clean when full move to new_variable
495-
if isinstance(o, easyscience.Objects.new_variable.parameter.Parameter):
496-
value_str += f'{o.value_no_call_back},'
497-
else:
498-
value_str += f'{o.raw_value},'
472+
value_str += f'{o.value_no_call_back},'
499473

500474
value_str = value_str[:-1]
501475
else:
502-
## TODO clean when full move to new_variable
503-
if isinstance(obj, easyscience.Objects.new_variable.parameter.Parameter):
504-
value_str += f'{obj.value_no_call_back}'
505-
else:
506-
value_str += f'{obj.raw_value}'
476+
value_str += f'{obj.value_no_call_back}'
507477

508478
value_str += ')'
509479
try:

src/easyscience/Objects/Groups.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515
from typing import List
1616
from typing import Optional
1717
from typing import Tuple
18+
from typing import TypeVar
1819
from typing import Union
1920

2021
from easyscience.global_object.undo_redo import NotarizedDict
21-
from easyscience.Objects.new_variable.descriptor_base import DescriptorBase
2222
from easyscience.Objects.ObjectClasses import BasedBase
23-
from easyscience.Objects.ObjectClasses import Descriptor
23+
from easyscience.Objects.variable.descriptor_base import DescriptorBase
2424

2525
if TYPE_CHECKING:
2626
from easyscience.Objects.Inferface import iF
2727
from easyscience.Objects.ObjectClasses import B
28-
from easyscience.Objects.Variable import V
28+
V = TypeVar('V', bound=DescriptorBase)
2929

3030

3131
class BaseCollection(BasedBase, MutableSequence):
@@ -69,7 +69,7 @@ def __init__(
6969
_kwargs[key] = item
7070
kwargs = _kwargs
7171
for item in list(kwargs.values()) + _args:
72-
if not issubclass(type(item), (Descriptor, DescriptorBase, BasedBase)):
72+
if not issubclass(type(item), (DescriptorBase, BasedBase)):
7373
raise AttributeError('A collection can only be formed from easyscience objects.')
7474
args = _args
7575
_kwargs = {}
@@ -102,12 +102,12 @@ def insert(self, index: int, value: Union[V, B]) -> None:
102102
:param index: Index for EasyScience object to be inserted.
103103
:type index: int
104104
:param value: Object to be inserted.
105-
:type value: Union[BasedBase, Descriptor]
105+
:type value: Union[BasedBase, DescriptorBase]
106106
:return: None
107107
:rtype: None
108108
"""
109109
t_ = type(value)
110-
if issubclass(t_, (BasedBase, Descriptor, DescriptorBase)):
110+
if issubclass(t_, (BasedBase, DescriptorBase)):
111111
update_key = list(self._kwargs.keys())
112112
values = list(self._kwargs.values())
113113
# Update the internal dict
@@ -124,7 +124,7 @@ def insert(self, index: int, value: Union[V, B]) -> None:
124124

125125
def __getitem__(self, idx: Union[int, slice]) -> Union[V, B]:
126126
"""
127-
Get an item in the collection based on it's index.
127+
Get an item in the collection based on its index.
128128
129129
:param idx: index or slice of the collection.
130130
:type idx: Union[int, slice]
@@ -168,7 +168,7 @@ def __setitem__(self, key: int, value: Union[B, V]) -> None:
168168
if isinstance(value, Number): # noqa: S3827
169169
item = self.__getitem__(key)
170170
item.value = value
171-
elif issubclass(type(value), (BasedBase, Descriptor, DescriptorBase)):
171+
elif issubclass(type(value), (BasedBase, DescriptorBase)):
172172
update_key = list(self._kwargs.keys())
173173
values = list(self._kwargs.values())
174174
old_item = values[key]
@@ -242,7 +242,7 @@ def sort(self, mapping: Callable[[Union[B, V]], Any], reverse: bool = False) ->
242242
"""
243243
Sort the collection according to the given mapping.
244244
245-
:param mapping: mapping function to sort the collection. i.e. lambda parameter: parameter.raw_value
245+
:param mapping: mapping function to sort the collection. i.e. lambda parameter: parameter.value
246246
:type mapping: Callable
247247
:param reverse: Reverse the sorting.
248248
:type reverse: bool

src/easyscience/Objects/Inferface.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ def generate_bindings(self, model, *args, ifun=None, **kwargs):
152152
:return: binding property
153153
:rtype: property
154154
"""
155-
import easyscience.Objects.new_variable.parameter
156155

157156
class_links = self.__interface_obj.create(model)
158157
props = model._get_linkable_attributes()
@@ -164,12 +163,13 @@ def generate_bindings(self, model, *args, ifun=None, **kwargs):
164163
idx = props_names.index(item_key)
165164
prop = props[idx]
166165

167-
## TODO clean when full move to new_variable
168-
if isinstance(prop, easyscience.Objects.new_variable.parameter.Parameter):
169-
# Should be fetched this way to ensure we don't get value from callback
166+
# Should be fetched this way to ensure we don't get value from callback
167+
if hasattr(prop, 'value_no_call_back'):
168+
# Property object
170169
prop_value = prop.value_no_call_back
171170
else:
172-
prop_value = prop.raw_value
171+
# Descriptor object
172+
prop_value = prop.value
173173

174174
prop._callback = item.make_prop(item_key)
175175
prop._callback.fset(prop_value)

0 commit comments

Comments
 (0)