Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/documentation-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: 3.10
- name: Install Pandoc, repo and dependencies
run: |
sudo apt install pandoc
Expand Down
2 changes: 1 addition & 1 deletion .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', '3.12']
python-version: ['3.10', '3.11', '3.12', '3.13']
os: [ubuntu-latest, macos-latest, windows-latest]

runs-on: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11']
python-version: ['3.10', '3.11', '3.12', '3.13']
if: "!contains(github.event.head_commit.message, '[ci skip]')"

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:

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

- name: Install dependencies and build
run: |
Expand Down
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ 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",
"Programming Language :: Python :: 3.13",
"Development Status :: 3 - Alpha"
]
requires-python = ">=3.9,<3.13"
requires-python = ">=3.10"
dependencies = [
"asteval",
"bumps",
"DFO-LS",
"lmfit",
"numpy==1.26", # Should be updated to numpy 2.0
"numpy",
"uncertainties",
"xarray",
"pint==0.23", # Only to ensure that unit is reported as dimensionless rather than empty string
"pint", # Only to ensure that unit is reported as dimensionless rather than empty string
"scipp"
]

Expand Down Expand Up @@ -128,13 +128,13 @@ 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,3.13}
[gh-actions]
python =
3.9: py39
3.10: py310
3.11: py311
3.12: py312
3.13: py313
[gh-actions:env]
PLATFORM =
ubuntu-latest: linux
Expand Down
44 changes: 7 additions & 37 deletions src/easyscience/Constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,9 @@ def __init__(self, dependent_obj: V, operator: str, value: Number):
super(NumericConstraint, self).__init__(dependent_obj, operator=operator, value=value)

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

if isinstance(obj, easyscience.Objects.new_variable.parameter.Parameter):
value = obj.value_no_call_back
else:
value = obj.raw_value
value = obj.value_no_call_back

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

def _parse_operator(self, obj: V, *args, **kwargs) -> Number:
## TODO clean when full move to new_variable
import easyscience.Objects.new_variable.parameter

if isinstance(obj, easyscience.Objects.new_variable.parameter.Parameter):
value = obj.value_no_call_back
else:
value = obj.raw_value
value = obj.value_no_call_back

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

def _parse_operator(self, obj: V, *args, **kwargs) -> Number:
## TODO clean when full move to new_variable
import easyscience.Objects.new_variable.parameter

if isinstance(obj, easyscience.Objects.new_variable.parameter.Parameter):
value = obj.value_no_call_back
else:
value = obj.raw_value
value = obj.value_no_call_back

self.aeval.symtable['value1'] = value
try:
Expand Down Expand Up @@ -417,16 +401,11 @@ def __init__(
self.external = True

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

in_str = ''
value = None
for idx, obj in enumerate(independent_objs):
## TODO clean when full move to new_variable
if isinstance(obj, easyscience.Objects.new_variable.parameter.Parameter):
self.aeval.symtable['p' + str(self.independent_obj_ids[idx])] = obj.value_no_call_back
else:
self.aeval.symtable['p' + str(self.independent_obj_ids[idx])] = obj.raw_value
self.aeval.symtable['p' + str(self.independent_obj_ids[idx])] = obj.value_no_call_back

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

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

self.aeval.symtable[f'f{id(self.function)}'] = self.function
value_str = f'r_value = f{id(self.function)}('
if isinstance(obj, list):
for o in obj:
## TODO clean when full move to new_variable
if isinstance(o, easyscience.Objects.new_variable.parameter.Parameter):
value_str += f'{o.value_no_call_back},'
else:
value_str += f'{o.raw_value},'
value_str += f'{o.value_no_call_back},'

value_str = value_str[:-1]
else:
## TODO clean when full move to new_variable
if isinstance(obj, easyscience.Objects.new_variable.parameter.Parameter):
value_str += f'{obj.value_no_call_back}'
else:
value_str += f'{obj.raw_value}'
value_str += f'{obj.value_no_call_back}'

value_str += ')'
try:
Expand Down
18 changes: 9 additions & 9 deletions src/easyscience/Objects/Groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
from typing import List
from typing import Optional
from typing import Tuple
from typing import TypeVar
from typing import Union

from easyscience.global_object.undo_redo import NotarizedDict
from easyscience.Objects.new_variable.descriptor_base import DescriptorBase
from easyscience.Objects.ObjectClasses import BasedBase
from easyscience.Objects.ObjectClasses import Descriptor
from easyscience.Objects.variable.descriptor_base import DescriptorBase

if TYPE_CHECKING:
from easyscience.Objects.Inferface import iF
from easyscience.Objects.ObjectClasses import B
from easyscience.Objects.Variable import V
V = TypeVar('V', bound=DescriptorBase)


class BaseCollection(BasedBase, MutableSequence):
Expand Down Expand Up @@ -69,7 +69,7 @@ def __init__(
_kwargs[key] = item
kwargs = _kwargs
for item in list(kwargs.values()) + _args:
if not issubclass(type(item), (Descriptor, DescriptorBase, BasedBase)):
if not issubclass(type(item), (DescriptorBase, BasedBase)):
raise AttributeError('A collection can only be formed from easyscience objects.')
args = _args
_kwargs = {}
Expand Down Expand Up @@ -102,12 +102,12 @@ def insert(self, index: int, value: Union[V, B]) -> None:
:param index: Index for EasyScience object to be inserted.
:type index: int
:param value: Object to be inserted.
:type value: Union[BasedBase, Descriptor]
:type value: Union[BasedBase, DescriptorBase]
:return: None
:rtype: None
"""
t_ = type(value)
if issubclass(t_, (BasedBase, Descriptor, DescriptorBase)):
if issubclass(t_, (BasedBase, DescriptorBase)):
update_key = list(self._kwargs.keys())
values = list(self._kwargs.values())
# Update the internal dict
Expand All @@ -124,7 +124,7 @@ def insert(self, index: int, value: Union[V, B]) -> None:

def __getitem__(self, idx: Union[int, slice]) -> Union[V, B]:
"""
Get an item in the collection based on it's index.
Get an item in the collection based on its index.

:param idx: index or slice of the collection.
:type idx: Union[int, slice]
Expand Down Expand Up @@ -168,7 +168,7 @@ def __setitem__(self, key: int, value: Union[B, V]) -> None:
if isinstance(value, Number): # noqa: S3827
item = self.__getitem__(key)
item.value = value
elif issubclass(type(value), (BasedBase, Descriptor, DescriptorBase)):
elif issubclass(type(value), (BasedBase, DescriptorBase)):
update_key = list(self._kwargs.keys())
values = list(self._kwargs.values())
old_item = values[key]
Expand Down Expand Up @@ -242,7 +242,7 @@ def sort(self, mapping: Callable[[Union[B, V]], Any], reverse: bool = False) ->
"""
Sort the collection according to the given mapping.

:param mapping: mapping function to sort the collection. i.e. lambda parameter: parameter.raw_value
:param mapping: mapping function to sort the collection. i.e. lambda parameter: parameter.value
:type mapping: Callable
:param reverse: Reverse the sorting.
:type reverse: bool
Expand Down
10 changes: 5 additions & 5 deletions src/easyscience/Objects/Inferface.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ def generate_bindings(self, model, *args, ifun=None, **kwargs):
:return: binding property
:rtype: property
"""
import easyscience.Objects.new_variable.parameter

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

## TODO clean when full move to new_variable
if isinstance(prop, easyscience.Objects.new_variable.parameter.Parameter):
# Should be fetched this way to ensure we don't get value from callback
# Should be fetched this way to ensure we don't get value from callback
if hasattr(prop, 'value_no_call_back'):
# Property object
prop_value = prop.value_no_call_back
else:
prop_value = prop.raw_value
# Descriptor object
prop_value = prop.value

prop._callback = item.make_prop(item_key)
prop._callback.fset(prop_value)
Expand Down
Loading
Loading