easyscience 0.9.0__tar.gz → 1.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. {easyscience-0.9.0 → easyscience-1.0.1}/PKG-INFO +5 -7
  2. {easyscience-0.9.0 → easyscience-1.0.1}/pyproject.toml +7 -10
  3. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Datasets/xarray.py +2 -3
  4. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Objects/Groups.py +3 -3
  5. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Objects/ObjectClasses.py +10 -23
  6. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Objects/Variable.py +6 -19
  7. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Objects/new_variable/descriptor_base.py +6 -18
  8. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Objects/new_variable/descriptor_number.py +2 -2
  9. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Objects/new_variable/parameter.py +3 -19
  10. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Objects/virtual.py +9 -11
  11. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Utils/classTools.py +14 -14
  12. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Utils/io/template.py +1 -1
  13. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Utils/io/xml.py +19 -21
  14. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/__init__.py +5 -2
  15. easyscience-1.0.1/src/easyscience/__version__.py +1 -0
  16. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/fitting/Constraints.py +67 -62
  17. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/fitting/__init__.py +2 -1
  18. easyscience-1.0.1/src/easyscience/fitting/available_minimizers.py +88 -0
  19. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/fitting/fitter.py +2 -2
  20. easyscience-1.0.1/src/easyscience/fitting/minimizers/factory.py +43 -0
  21. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/fitting/minimizers/minimizer_base.py +14 -3
  22. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/fitting/minimizers/minimizer_bumps.py +3 -7
  23. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/fitting/minimizers/minimizer_dfo.py +0 -6
  24. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/fitting/minimizers/minimizer_lmfit.py +3 -9
  25. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/global_object/global_object.py +22 -2
  26. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/global_object/map.py +29 -45
  27. easyscience-0.9.0/src/easyscience/Utils/typing.py +0 -14
  28. easyscience-0.9.0/src/easyscience/__version__.py +0 -1
  29. easyscience-0.9.0/src/easyscience/fitting/minimizers/factory.py +0 -107
  30. {easyscience-0.9.0 → easyscience-1.0.1}/.gitignore +0 -0
  31. {easyscience-0.9.0 → easyscience-1.0.1}/LICENSE +0 -0
  32. {easyscience-0.9.0 → easyscience-1.0.1}/README.md +0 -0
  33. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Datasets/__init__.py +0 -0
  34. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Objects/Inferface.py +0 -0
  35. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Objects/__init__.py +0 -0
  36. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Objects/core.py +0 -0
  37. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Objects/job/__init__.py +0 -0
  38. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Objects/job/analysis.py +0 -0
  39. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Objects/job/experiment.py +0 -0
  40. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Objects/job/job.py +0 -0
  41. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Objects/job/theoreticalmodel.py +0 -0
  42. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Objects/new_variable/__init__.py +0 -0
  43. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Objects/new_variable/descriptor_bool.py +0 -0
  44. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Objects/new_variable/descriptor_str.py +0 -0
  45. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/REDIRECT.py +0 -0
  46. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Utils/Exceptions.py +0 -0
  47. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Utils/__init__.py +0 -0
  48. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Utils/classUtils.py +0 -0
  49. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Utils/decorators.py +0 -0
  50. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Utils/io/__init__.py +0 -0
  51. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Utils/io/dict.py +0 -0
  52. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Utils/io/json.py +0 -0
  53. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/Utils/string.py +0 -0
  54. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/fitting/minimizers/__init__.py +0 -0
  55. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/fitting/minimizers/utils.py +0 -0
  56. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/fitting/multi_fitter.py +0 -0
  57. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/global_object/__init__.py +0 -0
  58. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/global_object/hugger/__init__.py +0 -0
  59. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/global_object/hugger/hugger.py +0 -0
  60. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/global_object/hugger/property.py +0 -0
  61. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/global_object/logger.py +0 -0
  62. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/global_object/undo_redo.py +0 -0
  63. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/models/__init__.py +0 -0
  64. {easyscience-0.9.0 → easyscience-1.0.1}/src/easyscience/models/polynomial.py +0 -0
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: easyscience
3
- Version: 0.9.0
3
+ Version: 1.0.1
4
4
  Summary: Generic logic for easyScience libraries
5
- Project-URL: homepage, https://docs.easyscience.org
6
- Project-URL: documentation, https://docs.easyscience.org
5
+ Project-URL: homepage, https://github.com/EasyScience/EasyScience
6
+ Project-URL: documentation, https://easyscience.github.io/EasyScience/
7
7
  Author: EasyScience contributors
8
8
  License: BSD 3-Clause License
9
9
 
@@ -40,13 +40,12 @@ Classifier: License :: OSI Approved :: BSD License
40
40
  Classifier: Operating System :: OS Independent
41
41
  Classifier: Programming Language :: Python :: 3
42
42
  Classifier: Programming Language :: Python :: 3 :: Only
43
- Classifier: Programming Language :: Python :: 3.8
44
43
  Classifier: Programming Language :: Python :: 3.9
45
44
  Classifier: Programming Language :: Python :: 3.10
46
45
  Classifier: Programming Language :: Python :: 3.11
47
46
  Classifier: Programming Language :: Python :: 3.12
48
47
  Classifier: Topic :: Scientific/Engineering
49
- Requires-Python: <3.12,>=3.8
48
+ Requires-Python: <3.12,>=3.9
50
49
  Requires-Dist: asteval
51
50
  Requires-Dist: bumps
52
51
  Requires-Dist: dfo-ls
@@ -68,10 +67,9 @@ Requires-Dist: tox-gh-actions; extra == 'dev'
68
67
  Provides-Extra: docs
69
68
  Requires-Dist: doc8; extra == 'docs'
70
69
  Requires-Dist: readme-renderer; extra == 'docs'
71
- Requires-Dist: sphinx; extra == 'docs'
72
70
  Requires-Dist: sphinx-autodoc-typehints; extra == 'docs'
71
+ Requires-Dist: sphinx-book-theme; extra == 'docs'
73
72
  Requires-Dist: sphinx-gallery; extra == 'docs'
74
- Requires-Dist: sphinx-rtd-theme; extra == 'docs'
75
73
  Requires-Dist: toml; extra == 'docs'
76
74
  Description-Content-Type: text/markdown
77
75
 
@@ -21,14 +21,13 @@ classifiers = [
21
21
  "Topic :: Scientific/Engineering",
22
22
  "Programming Language :: Python :: 3",
23
23
  "Programming Language :: Python :: 3 :: Only",
24
- "Programming Language :: Python :: 3.8",
25
24
  "Programming Language :: Python :: 3.9",
26
25
  "Programming Language :: Python :: 3.10",
27
26
  "Programming Language :: Python :: 3.11",
28
27
  "Programming Language :: Python :: 3.12",
29
28
  "Development Status :: 3 - Alpha"
30
29
  ]
31
- requires-python = ">=3.8,<3.12"
30
+ requires-python = ">=3.9,<3.12"
32
31
  dependencies = [
33
32
  "asteval",
34
33
  "bumps",
@@ -55,16 +54,15 @@ dev = [
55
54
  docs = [
56
55
  "doc8",
57
56
  "readme-renderer",
58
- "Sphinx",
59
- "sphinx-rtd-theme",
60
- "sphinx-autodoc-typehints",
61
- "sphinx-gallery",
57
+ "sphinx_autodoc_typehints",
58
+ "sphinx_book_theme",
59
+ "sphinx_gallery",
62
60
  "toml"
63
61
  ]
64
62
 
65
63
  [project.urls]
66
- homepage = "https://docs.easyscience.org"
67
- documentation = "https://docs.easyscience.org"
64
+ homepage = "https://github.com/EasyScience/EasyScience"
65
+ documentation = "https://easyscience.github.io/EasyScience/"
68
66
 
69
67
  [tool.hatch.version]
70
68
  path = "src/easyscience/__version__.py"
@@ -130,10 +128,9 @@ force-single-line = true
130
128
  legacy_tox_ini = """
131
129
  [tox]
132
130
  isolated_build = True
133
- envlist = py{3.8,3.9,3.10,3.11,3.12}
131
+ envlist = py{3.9,3.10,3.11,3.12}
134
132
  [gh-actions]
135
133
  python =
136
- 3.8: py38
137
134
  3.9: py39
138
135
  3.10: py310
139
136
  3.11: py311
@@ -281,14 +281,13 @@ class EasyScienceDatasetAccessor:
281
281
 
282
282
  :param variable_label: Name of the DataArray to perform the calculation on
283
283
  :type variable_label: str
284
- :param sigma_func: Function to generate the sigmas. Must be of the form f(x) and return an array of the same
285
- shape as the input. DEFAULT: sqrt(|data|)
284
+ :param sigma_func: Function to generate the sigmas. Must be of the form f(x) and return an array of the same shape as the input. Default sqrt(\|x\|)
286
285
  :type sigma_func: Callable
287
286
  :param label_prefix: What prefix should be used to designate a sigma DataArray from a data DataArray
288
287
  :type label_prefix: str
289
288
  :return: None
290
289
  :rtype: None
291
- """
290
+ """ # noqa: E501
292
291
  sigma_values = sigma_func(self._obj[variable_label])
293
292
  self.sigma_attach(variable_label, sigma_values, label_prefix)
294
293
 
@@ -22,9 +22,9 @@ from easyscience.Objects.ObjectClasses import BasedBase
22
22
  from easyscience.Objects.ObjectClasses import Descriptor
23
23
 
24
24
  if TYPE_CHECKING:
25
- from easyscience.Utils.typing import B
26
- from easyscience.Utils.typing import V
27
- from easyscience.Utils.typing import iF
25
+ from easyscience.Objects.Inferface import iF
26
+ from easyscience.Objects.ObjectClasses import B
27
+ from easyscience.Objects.Variable import V
28
28
 
29
29
 
30
30
  class BaseCollection(BasedBase, MutableSequence):
@@ -28,9 +28,9 @@ from .Variable import Descriptor
28
28
  from .Variable import Parameter
29
29
 
30
30
  if TYPE_CHECKING:
31
- from easyscience.Utils.typing import C
32
- from easyscience.Utils.typing import V
33
- from easyscience.Utils.typing import iF
31
+ from easyscience.fitting.Constraints import C
32
+ from easyscience.Objects.Inferface import iF
33
+ from easyscience.Objects.Variable import V
34
34
 
35
35
 
36
36
  class BasedBase(ComponentSerializer):
@@ -41,10 +41,10 @@ class BasedBase(ComponentSerializer):
41
41
  def __init__(self, name: str, interface: Optional[iF] = None, unique_name: Optional[str] = None):
42
42
  self._global_object = global_object
43
43
  if unique_name is None:
44
- unique_name = self._unique_name_generator()
44
+ unique_name = self._global_object.generate_unique_name(self.__class__.__name__)
45
45
  self._unique_name = unique_name
46
46
  self._name = name
47
- self._global_object.map.add_vertex(self, obj_type="created")
47
+ self._global_object.map.add_vertex(self, obj_type='created')
48
48
  self.interface = interface
49
49
  self.user_data: dict = {}
50
50
 
@@ -69,16 +69,16 @@ class BasedBase(ComponentSerializer):
69
69
 
70
70
  @property
71
71
  def unique_name(self) -> str:
72
- """ Get the unique name of the object."""
72
+ """Get the unique name of the object."""
73
73
  return self._unique_name
74
74
 
75
75
  @unique_name.setter
76
76
  def unique_name(self, new_unique_name: str):
77
- """ Set a new unique name for the object. The old name is still kept in the map.
78
-
77
+ """Set a new unique name for the object. The old name is still kept in the map.
78
+
79
79
  :param new_unique_name: New unique name for the object"""
80
80
  if not isinstance(new_unique_name, str):
81
- raise TypeError("Unique name has to be a string.")
81
+ raise TypeError('Unique name has to be a string.')
82
82
  self._unique_name = new_unique_name
83
83
  self._global_object.map.add_vertex(self)
84
84
 
@@ -206,18 +206,6 @@ class BasedBase(ComponentSerializer):
206
206
  fit_list.append(item)
207
207
  return fit_list
208
208
 
209
- def _unique_name_generator(self) -> str:
210
- """
211
- Generate a generic unique name for the object using the class name and a global iterator.
212
- """
213
- class_name = self.__class__.__name__
214
- iterator_string = str(self._global_object.map._get_name_iterator(class_name))
215
- name = class_name + "_" + iterator_string
216
- while name in self._global_object.map.vertices():
217
- iterator_string = str(self._global_object.map._get_name_iterator(class_name))
218
- name = class_name + "_" + iterator_string
219
- return name
220
-
221
209
  def __dir__(self) -> Iterable[str]:
222
210
  """
223
211
  This creates auto-completion and helps out in iPython notebooks.
@@ -226,7 +214,6 @@ class BasedBase(ComponentSerializer):
226
214
  """
227
215
  new_class_objs = list(k for k in dir(self.__class__) if not k.startswith('_'))
228
216
  return sorted(new_class_objs)
229
-
230
217
 
231
218
 
232
219
  if TYPE_CHECKING:
@@ -267,7 +254,7 @@ class BaseObj(BasedBase):
267
254
  self._kwargs = kwargs
268
255
  for key in kwargs.keys():
269
256
  if key in known_keys:
270
- raise AttributeError("Kwargs cannot overwrite class attributes in BaseObj.")
257
+ raise AttributeError('Kwargs cannot overwrite class attributes in BaseObj.')
271
258
  if issubclass(type(kwargs[key]), (BasedBase, Descriptor, DescriptorBase)) or 'BaseCollection' in [
272
259
  c.__name__ for c in type(kwargs[key]).__bases__
273
260
  ]:
@@ -37,7 +37,7 @@ from easyscience.Utils.classTools import addProp
37
37
  from easyscience.Utils.Exceptions import CoreSetException
38
38
 
39
39
  if TYPE_CHECKING:
40
- from easyscience.Utils.typing import C
40
+ from easyscience.fitting.Constraints import C
41
41
 
42
42
  Q_ = ureg.Quantity
43
43
  M_ = ureg.Measurement
@@ -109,7 +109,7 @@ class Descriptor(ComponentSerializer):
109
109
  if not hasattr(self, '_args'):
110
110
  self._args = {'value': None, 'units': ''}
111
111
  if unique_name is None:
112
- unique_name = self._unique_name_generator()
112
+ unique_name = self._global_object.generate_unique_name(self.__class__.__name__)
113
113
  self._unique_name = unique_name
114
114
  self.name = name
115
115
  # Let the collective know we've been assimilated
@@ -190,14 +190,14 @@ class Descriptor(ComponentSerializer):
190
190
  :return: Unique name of this object
191
191
  """
192
192
  return self._unique_name
193
-
193
+
194
194
  @unique_name.setter
195
195
  def unique_name(self, new_unique_name: str):
196
- """ Set a new unique name for the object. The old name is still kept in the map.
197
-
196
+ """Set a new unique name for the object. The old name is still kept in the map.
197
+
198
198
  :param new_unique_name: New unique name for the object"""
199
199
  if not isinstance(new_unique_name, str):
200
- raise TypeError("Unique name has to be a string.")
200
+ raise TypeError('Unique name has to be a string.')
201
201
  self._unique_name = new_unique_name
202
202
  self._global_object.map.add_vertex(self)
203
203
 
@@ -363,19 +363,6 @@ class Descriptor(ComponentSerializer):
363
363
  self._args['value'] = self.raw_value
364
364
  self._args['units'] = str(self.unit)
365
365
 
366
- def _unique_name_generator(self) -> str:
367
- """
368
- Generate a generic unique name for the object using the class name and a global iterator.
369
- """
370
- class_name = self.__class__.__name__
371
- iterator_string = str(self._global_object.map._get_name_iterator(class_name))
372
- name = class_name + "_" + iterator_string
373
- while name in self._global_object.map.vertices():
374
- iterator_string = str(self._global_object.map._get_name_iterator(class_name))
375
- name = class_name + "_" + iterator_string
376
- return name
377
-
378
-
379
366
  # @cached_property
380
367
  @property
381
368
  def compatible_units(self) -> List[str]:
@@ -55,7 +55,7 @@ class DescriptorBase(ComponentSerializer, metaclass=abc.ABCMeta):
55
55
  """
56
56
 
57
57
  if unique_name is None:
58
- unique_name = self._unique_name_generator()
58
+ unique_name = self._global_object.generate_unique_name(self.__class__.__name__)
59
59
  self._unique_name = unique_name
60
60
 
61
61
  if not isinstance(name, str):
@@ -178,29 +178,17 @@ class DescriptorBase(ComponentSerializer, metaclass=abc.ABCMeta):
178
178
  :return: Unique name of this object
179
179
  """
180
180
  return self._unique_name
181
-
181
+
182
182
  @unique_name.setter
183
183
  def unique_name(self, new_unique_name: str):
184
- """ Set a new unique name for the object. The old name is still kept in the map.
185
-
184
+ """Set a new unique name for the object. The old name is still kept in the map.
185
+
186
186
  :param new_unique_name: New unique name for the object"""
187
187
  if not isinstance(new_unique_name, str):
188
- raise TypeError("Unique name has to be a string.")
188
+ raise TypeError('Unique name has to be a string.')
189
189
  self._unique_name = new_unique_name
190
190
  self._global_object.map.add_vertex(self)
191
191
 
192
- def _unique_name_generator(self) -> str:
193
- """
194
- Generate a generic unique name for the object using the class name and a global iterator.
195
- """
196
- class_name = self.__class__.__name__
197
- iterator_string = str(self._global_object.map._get_name_iterator(class_name))
198
- name = class_name + "_" + iterator_string
199
- while name in self._global_object.map.vertices():
200
- iterator_string = str(self._global_object.map._get_name_iterator(class_name))
201
- name = class_name + "_" + iterator_string
202
- return name
203
-
204
192
  @property
205
193
  @abc.abstractmethod
206
194
  def value(self) -> Any:
@@ -218,6 +206,6 @@ class DescriptorBase(ComponentSerializer, metaclass=abc.ABCMeta):
218
206
  def __copy__(self) -> DescriptorBase:
219
207
  """Return a copy of the object."""
220
208
  temp = self.as_dict()
221
- temp["unique_name"] = None
209
+ temp['unique_name'] = None
222
210
  new_obj = self.__class__.from_dict(temp)
223
211
  return new_obj
@@ -101,7 +101,7 @@ class DescriptorNumber(DescriptorBase):
101
101
 
102
102
  @full_value.setter
103
103
  def full_value(self, full_value: Variable) -> None:
104
- raise AttributeError(f'Full_value is read-only. Change the value and variance seperately. or create a new {self.__class__.__name__}.') # noqa: E501
104
+ raise AttributeError(f'Full_value is read-only. Change the value and variance seperately. Or create a new {self.__class__.__name__}.') # noqa: E501
105
105
 
106
106
  @property
107
107
  def value(self) -> numbers.Number:
@@ -122,7 +122,7 @@ class DescriptorNumber(DescriptorBase):
122
122
  """
123
123
  if not isinstance(value, numbers.Number) or isinstance(value, bool):
124
124
  raise TypeError(f'{value=} must be a number')
125
- self._scalar.value = value
125
+ self._scalar.value = float(value)
126
126
 
127
127
  @property
128
128
  def unit(self) -> str:
@@ -126,7 +126,7 @@ class Parameter(DescriptorNumber):
126
126
  @property
127
127
  def value_no_call_back(self) -> numbers.Number:
128
128
  """
129
- Get the currently hold value of self surpassing call back.
129
+ Get the currently hold value of self suppressing call back.
130
130
 
131
131
  :return: Value of self without unit.
132
132
  """
@@ -147,24 +147,8 @@ class Parameter(DescriptorNumber):
147
147
  return self._scalar
148
148
 
149
149
  @full_value.setter
150
- @property_stack_deco
151
150
  def full_value(self, scalar: Variable) -> None:
152
- """
153
- Set the value of self. This creates a scipp scalar with a unit.
154
-
155
- :param full_value: New value of self
156
- """
157
- if not self.enabled:
158
- if global_object.debug:
159
- raise CoreSetException(f'{str(self)} is not enabled.')
160
- return
161
- if not isinstance(scalar, Variable) and len(scalar.dims) == 0:
162
- raise TypeError(f'{scalar=} must be a Scipp scalar')
163
- if not isinstance(scalar.value, numbers.Number) or isinstance(scalar.value, bool):
164
- raise TypeError('value of Scipp scalar must be a number')
165
- self._scalar = scalar
166
- if self._callback.fset is not None:
167
- self._callback.fset(scalar)
151
+ raise AttributeError(f'Full_value is read-only. Change the value and variance seperately. Or create a new {self.__class__.__name__}.') # noqa: E501
168
152
 
169
153
  @property
170
154
  def value(self) -> numbers.Number:
@@ -215,7 +199,7 @@ class Parameter(DescriptorNumber):
215
199
 
216
200
  value = self._constraint_runner(self._constraints.virtual, value)
217
201
 
218
- self._scalar.value = value
202
+ self._scalar.value = float(value)
219
203
  if self._callback.fset is not None:
220
204
  self._callback.fset(self._scalar.value)
221
205
 
@@ -18,7 +18,7 @@ from easyscience import global_object
18
18
  from easyscience.fitting.Constraints import ObjConstraint
19
19
 
20
20
  if TYPE_CHECKING:
21
- from easyscience.Utils.typing import BV
21
+ from easyscience.Objects.ObjectClasses import BV
22
22
 
23
23
 
24
24
  def raise_(ex):
@@ -48,7 +48,7 @@ def realizer(obj: BV):
48
48
  args = []
49
49
  if klass in ec_var.__dict__.values(): # is_variable check
50
50
  kwargs = obj.encode_data()
51
- kwargs["unique_name"] = None
51
+ kwargs['unique_name'] = None
52
52
  return klass(**kwargs)
53
53
  else:
54
54
  kwargs = {name: realizer(item) for name, item in obj._kwargs.items()}
@@ -97,9 +97,7 @@ def component_realizer(obj: BV, component: str, recursive: bool = True):
97
97
  key = value.unique_name
98
98
  if getattr(value, '__old_class__', value.__class__) in ec_var.__dict__.values():
99
99
  continue
100
- component._global_object.map.prune_vertex_from_edge(
101
- component, component._kwargs[key]
102
- )
100
+ component._global_object.map.prune_vertex_from_edge(component, component._kwargs[key])
103
101
  component._global_object.map.add_edge(component, old_component._kwargs[key])
104
102
  component._kwargs[key] = old_component._kwargs[key]
105
103
  done_mapping = False
@@ -142,12 +140,12 @@ def virtualizer(obj: BV) -> BV:
142
140
  # The supplied class
143
141
  klass = getattr(obj, '__old_class__', obj.__class__)
144
142
  virtual_options = {
145
- "_is_virtual": True,
146
- "is_virtual": property(fget=lambda self: self._is_virtual),
147
- "_derived_from": property(fget=lambda self: obj.unique_name),
148
- "__non_virtual_class__": klass,
149
- "realize": realizer,
150
- "relalize_component": component_realizer,
143
+ '_is_virtual': True,
144
+ 'is_virtual': property(fget=lambda self: self._is_virtual),
145
+ '_derived_from': property(fget=lambda self: obj.unique_name),
146
+ '__non_virtual_class__': klass,
147
+ 'realize': realizer,
148
+ 'relalize_component': component_realizer,
151
149
  }
152
150
 
153
151
  import easyscience.Objects.Variable as ec_var
@@ -4,8 +4,8 @@
4
4
 
5
5
  from __future__ import annotations
6
6
 
7
- __author__ = "github.com/wardsimon"
8
- __version__ = "0.1.0"
7
+ __author__ = 'github.com/wardsimon'
8
+ __version__ = '0.1.0'
9
9
 
10
10
  from typing import TYPE_CHECKING
11
11
  from typing import List
@@ -15,15 +15,15 @@ from easyscience import global_object
15
15
  from easyscience.global_object.hugger.property import LoggedProperty
16
16
 
17
17
  if TYPE_CHECKING:
18
- from easyscience.Utils.typing import BV
19
- from easyscience.Utils.typing import B
18
+ from easyscience.Objects.ObjectClasses import BV
19
+ from easyscience.Objects.ObjectClasses import B
20
20
 
21
21
 
22
22
  def addLoggedProp(inst: BV, name: str, *args, **kwargs) -> None:
23
23
  cls = type(inst)
24
- annotations = getattr(cls, "__annotations__", False)
25
- if not hasattr(cls, "__perinstance"):
26
- cls = type(cls.__name__, (cls,), {"__module__": inst.__module__})
24
+ annotations = getattr(cls, '__annotations__', False)
25
+ if not hasattr(cls, '__perinstance'):
26
+ cls = type(cls.__name__, (cls,), {'__module__': inst.__module__})
27
27
  cls.__perinstance = True
28
28
  if annotations:
29
29
  cls.__annotations__ = annotations
@@ -34,9 +34,9 @@ def addLoggedProp(inst: BV, name: str, *args, **kwargs) -> None:
34
34
 
35
35
  def addProp(inst: BV, name: str, *args, **kwargs) -> None:
36
36
  cls = type(inst)
37
- annotations = getattr(cls, "__annotations__", False)
38
- if not hasattr(cls, "__perinstance"):
39
- cls = type(cls.__name__, (cls,), {"__module__": __name__})
37
+ annotations = getattr(cls, '__annotations__', False)
38
+ if not hasattr(cls, '__perinstance'):
39
+ cls = type(cls.__name__, (cls,), {'__module__': __name__})
40
40
  cls.__perinstance = True
41
41
  if annotations:
42
42
  cls.__annotations__ = annotations
@@ -48,8 +48,8 @@ def addProp(inst: BV, name: str, *args, **kwargs) -> None:
48
48
 
49
49
  def removeProp(inst: BV, name: str) -> None:
50
50
  cls = type(inst)
51
- if not hasattr(cls, "__perinstance"):
52
- cls = type(cls.__name__, (cls,), {"__module__": __name__})
51
+ if not hasattr(cls, '__perinstance'):
52
+ cls = type(cls.__name__, (cls,), {'__module__': __name__})
53
53
  cls.__perinstance = True
54
54
  inst.__old_class__ = inst.__class__
55
55
  inst.__class__ = cls
@@ -65,8 +65,8 @@ def generatePath(model_obj: B, skip_first: bool = False) -> Tuple[List[int], Lis
65
65
  for par in pars:
66
66
  elem = par.unique_name
67
67
  route = global_object.map.reverse_route(elem, model_id)
68
- objs = [getattr(global_object.map.get_item_by_key(r), "name") for r in route]
68
+ objs = [getattr(global_object.map.get_item_by_key(r), 'name') for r in route]
69
69
  objs.reverse()
70
- names.append(".".join(objs[start_idx:]))
70
+ names.append('.'.join(objs[start_idx:]))
71
71
  ids.append(elem.int)
72
72
  return ids, names
@@ -27,7 +27,7 @@ from typing import TypeVar
27
27
  import numpy as np
28
28
 
29
29
  if TYPE_CHECKING:
30
- from easyscience.Utils.typing import BV
30
+ from easyscience.Objects.ObjectClasses import BV
31
31
 
32
32
  _e = json.JSONEncoder()
33
33
 
@@ -4,8 +4,8 @@
4
4
 
5
5
  from __future__ import annotations
6
6
 
7
- __author__ = "github.com/wardsimon"
8
- __version__ = "0.0.1"
7
+ __author__ = 'github.com/wardsimon'
8
+ __version__ = '0.0.1'
9
9
 
10
10
  import sys
11
11
  import xml.etree.ElementTree as ET
@@ -22,7 +22,7 @@ from easyscience.Utils.io.dict import DictSerializer
22
22
  from easyscience.Utils.io.template import BaseEncoderDecoder
23
23
 
24
24
  if TYPE_CHECKING:
25
- from easyscience.Utils.typing import BV
25
+ from easyscience.Objects.ObjectClasses import BV
26
26
 
27
27
 
28
28
  can_intent = (sys.version_info.major > 2) & (sys.version_info.minor > 8)
@@ -64,16 +64,16 @@ class XMLSerializer(BaseEncoderDecoder):
64
64
  obj_dict = obj
65
65
  else:
66
66
  obj_dict = encoder().encode(obj, skip=skip, full_encode=True, **kwargs)
67
- block = ET.Element("data")
67
+ block = ET.Element('data')
68
68
  self._check_class(block, None, obj_dict, skip=skip)
69
- header = ""
69
+ header = ''
70
70
  if use_header:
71
71
  header = '?xml version="1.0" encoding="UTF-8"?'
72
72
  if not fast and can_intent:
73
73
  ET.indent(block)
74
74
  if use_header:
75
- header += "\n"
76
- return header + ET.tostring(block, encoding="unicode")
75
+ header += '\n'
76
+ return header + ET.tostring(block, encoding='unicode')
77
77
 
78
78
  @classmethod
79
79
  def decode(cls, data: str) -> BV:
@@ -97,8 +97,8 @@ class XMLSerializer(BaseEncoderDecoder):
97
97
  """
98
98
 
99
99
  label = element.tag
100
- if label[0] == "_":
101
- label = "@" + label[2:]
100
+ if label[0] == '_':
101
+ label = '@' + label[2:]
102
102
  if len(element) == 0:
103
103
  out_dict[label] = XMLSerializer.string_to_variable(element.text)
104
104
  else:
@@ -123,25 +123,23 @@ class XMLSerializer(BaseEncoderDecoder):
123
123
  return in_string
124
124
  in_string = in_string.strip()
125
125
  if "'" in in_string:
126
- in_string = in_string.replace("'", "")
126
+ in_string = in_string.replace("'", '')
127
127
  if '"' in in_string:
128
- in_string = in_string.replace('"', "")
128
+ in_string = in_string.replace('"', '')
129
129
  try:
130
130
  value = float(in_string)
131
131
  except ValueError:
132
- if in_string == "True":
132
+ if in_string == 'True':
133
133
  value = True
134
- elif in_string == "False":
134
+ elif in_string == 'False':
135
135
  value = False
136
- elif in_string == "None":
136
+ elif in_string == 'None':
137
137
  value = None
138
138
  else:
139
139
  value = in_string
140
140
  return value
141
141
 
142
- def _check_class(
143
- self, element, key: str, value: Any, skip: Optional[List[str]] = None
144
- ):
142
+ def _check_class(self, element, key: str, value: Any, skip: Optional[List[str]] = None):
145
143
  """
146
144
  Add a value to an element or create a new element based on input type.
147
145
  """
@@ -151,8 +149,8 @@ class XMLSerializer(BaseEncoderDecoder):
151
149
  if k in skip:
152
150
  continue
153
151
  kk = k
154
- if k[0] == "@":
155
- kk = "__" + kk[1:]
152
+ if k[0] == '@':
153
+ kk = '__' + kk[1:]
156
154
  if not isinstance(v, list):
157
155
  s = ET.SubElement(element, kk)
158
156
  self._check_class(s, kk, v, skip=skip)
@@ -167,11 +165,11 @@ class XMLSerializer(BaseEncoderDecoder):
167
165
  s = ET.SubElement(element, key)
168
166
  self._check_class(s, None, i, skip=skip)
169
167
  elif value is None:
170
- element.text = "None"
168
+ element.text = 'None'
171
169
  elif issubclass(T_, Number):
172
170
  element.text = str(value)
173
171
  elif issubclass(T_, np.ndarray):
174
172
  element.text = str(value.tolist())
175
173
  else:
176
- print(f"Cannot encode {T_} to XML")
174
+ print(f'Cannot encode {T_} to XML')
177
175
  raise NotImplementedError
@@ -17,9 +17,12 @@ global_object = GlobalObject()
17
17
  global_object.instantiate_stack()
18
18
  global_object.stack.enabled = False
19
19
 
20
+
20
21
  # alias for global_object, remove later
21
22
  def __getattr__(name):
22
23
  if name == 'borg':
23
- warnings.warn("The 'borg' has been renamed to 'global_object', this alias will be deprecated in the future", DeprecationWarning) # noqa: E501
24
+ warnings.warn(
25
+ "The 'borg' has been renamed to 'global_object', this alias will be deprecated in the future", DeprecationWarning
26
+ ) # noqa: E501
24
27
  print("The 'borg' has been renamed to 'global_object', this alias will be deprecated in the future")
25
- return global_object
28
+ return global_object
@@ -0,0 +1 @@
1
+ __version__ = '1.0.1'