steer-core 0.1.10__py3-none-any.whl → 0.1.11__py3-none-any.whl

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.
Binary file
@@ -280,10 +280,10 @@ class CoordinateMixin:
280
280
  Returns
281
281
  -------
282
282
  Tuple[np.ndarray, np.ndarray]
283
- Modified x and y coordinate arrays with None separators between segments
283
+ Modified x and y coordinate arrays with np.nan separators between segments
284
284
  """
285
285
  if len(x_coords) == 0 or len(y_coords) == 0:
286
- return np.array([]), np.array([])
286
+ return np.array([], dtype=float), np.array([], dtype=float)
287
287
 
288
288
  x_min, x_max = np.min(x_coords), np.max(x_coords)
289
289
  y_min, y_max = np.min(y_coords), np.max(y_coords)
@@ -297,7 +297,7 @@ class CoordinateMixin:
297
297
  if len(valid_positions) == 0:
298
298
  rect_x = [x_min, x_max, x_max, x_min, x_min]
299
299
  rect_y = [y_min, y_min, y_max, y_max, y_min]
300
- return np.array(rect_x, dtype=object), np.array(rect_y, dtype=object)
300
+ return np.array(rect_x, dtype=float), np.array(rect_y, dtype=float)
301
301
 
302
302
  # Sort weld tab cut positions
303
303
  cuts = np.sort(valid_positions)
@@ -317,7 +317,7 @@ class CoordinateMixin:
317
317
  if start < x_max:
318
318
  segments.append((start, x_max))
319
319
 
320
- # Build rectangles for each kept segment with None separators
320
+ # Build rectangles for each kept segment with np.nan separators
321
321
  x_result = []
322
322
  y_result = []
323
323
 
@@ -329,10 +329,10 @@ class CoordinateMixin:
329
329
  x_result.extend(rect_x)
330
330
  y_result.extend(rect_y)
331
331
 
332
- # Add None separator (except for the last segment)
332
+ # Add np.nan separator (except for the last segment)
333
333
  if i < len(segments) - 1: # Fixed: use index comparison
334
- x_result.append(None)
335
- y_result.append(None)
334
+ x_result.append(np.nan)
335
+ y_result.append(np.nan)
336
336
 
337
- return np.array(x_result, dtype=object), np.array(y_result, dtype=object)
337
+ return np.array(x_result, dtype=float), np.array(y_result, dtype=float)
338
338
 
@@ -14,124 +14,26 @@ ALLOWED_REFERENCE = [
14
14
  class ValidationMixin:
15
15
 
16
16
  @staticmethod
17
- def validate_formulations(value: Type) -> None:
17
+ def validate_type(value: Type, expected_type: Type, name: str) -> None:
18
18
  """
19
- Validate that a value is an instance of _ElectrodeFormulation.
19
+ Validate that a value is of the expected type.
20
20
 
21
21
  Parameters
22
22
  ----------
23
23
  value : Type
24
24
  The value to validate.
25
+ expected_type : Type
26
+ The expected type of the value.
27
+ name : str
28
+ The name of the parameter for error messages.
25
29
 
26
30
  Raises
27
31
  ------
28
32
  TypeError
29
- If the value is not an instance of _ElectrodeFormulation.
30
- """
31
- from steer_opencell_design.Formulations.ElectrodeFormulations import _ElectrodeFormulation
32
-
33
- if not isinstance(value, _ElectrodeFormulation):
34
- raise TypeError(f"Expected an instance of _ElectrodeFormulation. Provided: {type(value)}.")
35
-
36
- @staticmethod
37
- def validate_insulation_material(value: Type) -> None:
38
- """
39
- Validate that a value is an instance of InsulationMaterial.
40
-
41
- Parameters
42
- ----------
43
- value : Type
44
- The value to validate.
45
-
46
- Raises
47
- ------
48
- TypeError
49
- If the value is not an instance of InsulationMaterial.
50
- """
51
- from steer_materials.CellMaterials.Base import InsulationMaterial
52
-
53
- if not isinstance(value, InsulationMaterial):
54
- raise TypeError(f"Expected an instance of InsulationMaterial. Provided: {type(value)}.")
55
-
56
- @staticmethod
57
- def validate_current_collector(value: Type) -> None:
58
- """
59
- Validate that a value is an instance of _CurrentCollector.
60
-
61
- Parameters
62
- ----------
63
- value : Type
64
- The value to validate.
65
-
66
- Raises
67
- ------
68
- TypeError
69
- If the value is not an instance of _CurrentCollector.
70
- """
71
- from steer_opencell_design.Components.CurrentCollectors import _CurrentCollector
72
-
73
- if not isinstance(value, _CurrentCollector):
74
- raise TypeError(f"Expected an instance of _CurrentCollector. Provided: {type(value)}.")
75
-
76
- @staticmethod
77
- def validate_active_material(value: Type) -> None:
78
- """
79
- Validate that a value is an instance of _ActiveMaterial.
80
-
81
- Parameters
82
- ----------
83
- value : Type
84
- The value to validate.
85
-
86
- Raises
87
- ------
88
- TypeError
89
- If the value is not an instance of _ActiveMaterial.
90
- """
91
- from steer_materials.CellMaterials.Electrode import _ActiveMaterial
92
-
93
- if not isinstance(value, _ActiveMaterial):
94
- raise TypeError(f"Expected an instance of _ActiveMaterial. Provided: {type(value)}.")
95
-
96
- @staticmethod
97
- def validate_binder(value: Type) -> None:
98
- """
99
- Validate that a value is an instance of Binder.
100
-
101
- Parameters
102
- ----------
103
- value : Type
104
- The value to validate.
105
-
106
- Raises
107
- ------
108
- TypeError
109
- If the value is not an instance of Binder.
110
- """
111
- from steer_materials.CellMaterials.Electrode import Binder
112
-
113
- if not isinstance(value, Binder):
114
- raise TypeError(f"Expected an instance of Binder. Provided: {type(value)}.")
115
-
116
- @staticmethod
117
- def validate_conductive_additive(value: Type) -> None:
118
- """
119
- Validate that a value is an instance of ConductiveAdditive.
120
-
121
- Parameters
122
- ----------
123
- value : Type
124
- The value to validate.
125
-
126
- Raises
127
- ------
128
- TypeError
129
- If the value is not an instance of ConductiveAdditive.
33
+ If the value is not of the expected type.
130
34
  """
131
- from steer_materials.CellMaterials.Electrode import ConductiveAdditive
132
-
133
- if not isinstance(value, ConductiveAdditive):
134
- raise TypeError(f"Expected an instance of ConductiveAdditive. Provided: {type(value)}.")
35
+ if not isinstance(value, expected_type):
36
+ raise TypeError(f"{name} must be of type {expected_type.__name__}. Provided: {type(value).__name__}.")
135
37
 
136
38
  @staticmethod
137
39
  def validate_percentage(value: float, name: str) -> None:
@@ -248,48 +150,6 @@ class ValidationMixin:
248
150
  if not all(isinstance(coord, (int, float)) for coord in datum):
249
151
  raise TypeError("All coordinates in datum must be numbers.")
250
152
 
251
- @staticmethod
252
- def validate_current_collector_material(material: Type) -> None:
253
- """
254
- Validate the current collector material.
255
-
256
- Parameters
257
- ----------
258
- material : str
259
- The material to validate.
260
-
261
- Raises
262
- ------
263
- ValueError
264
- If the material is not a valid current collector material.
265
- """
266
- from steer_materials.CellMaterials.Base import CurrentCollectorMaterial
267
-
268
- if type(material) is not CurrentCollectorMaterial:
269
-
270
- raise ValueError(f"Invalid current collector material: {material}. "
271
- "Must be an instance of CurrentCollectorMaterial.")
272
-
273
- @staticmethod
274
- def validate_weld_tab(tab) -> None:
275
- """
276
- Validate the weld tab.
277
-
278
- Parameters
279
- ----------
280
- tab : WeldTab
281
- The weld tab to validate.
282
-
283
- Raises
284
- ------
285
- ValueError
286
- If the weld tab is not valid.
287
- """
288
- from steer_opencell_design.Components.CurrentCollectors import WeldTab
289
-
290
- if not isinstance(tab, WeldTab):
291
- raise ValueError(f"Invalid weld tab: {tab}. Must be an instance of WeldTab.")
292
-
293
153
  @staticmethod
294
154
  def validate_positive_float(value: float, name: str) -> None:
295
155
  """
@@ -382,39 +242,3 @@ class ValidationMixin:
382
242
  if len(value) == 0:
383
243
  raise ValueError(f"{name} must not be an empty list. Provided: {value}.")
384
244
 
385
-
386
- class DataMixin:
387
- """
388
- A mixin class to handle data processing and validation for electrode materials.
389
- Provides methods to calculate properties, check curve directions, and process half-cell curves.
390
- """
391
- @staticmethod
392
- def enforce_monotonicity(array: np.ndarray) -> np.ndarray:
393
- """
394
- Enforces a monotonic version of the input array.
395
- If the array is not monotonic, it is smoothed using cumulative max/min.
396
- """
397
- x = np.arange(len(array))
398
- diff = np.diff(array)
399
-
400
- if np.all(diff >= 0):
401
- return array # Already monotonic increasing
402
-
403
- if np.all(diff <= 0):
404
- return array # Already monotonic decreasing, reverse it
405
-
406
- # Determine general trend (ascending or descending)
407
- ascending = array[-1] >= array[0]
408
-
409
- # Sort by x so that PCHIP works (PCHIP requires increasing x)
410
- # We'll smooth the array using PCHIP, then enforce monotonicity
411
- interpolator = PchipInterpolator(x, array, extrapolate=False)
412
- new_array = interpolator(x)
413
-
414
- # Enforce strict monotonicity post-smoothing
415
- if ascending:
416
- new_array = np.maximum.accumulate(new_array)
417
- else:
418
- new_array = np.minimum.accumulate(new_array)
419
-
420
- return new_array
steer_core/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.1.10"
1
+ __version__ = "0.1.11"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: steer-core
3
- Version: 0.1.10
3
+ Version: 0.1.11
4
4
  Summary: Modelling energy storage from cell to site - STEER OpenCell Design
5
5
  Home-page: https://github.com/nicholas9182/steer-core/
6
6
  Author: Nicholas Siemons
@@ -1,5 +1,5 @@
1
1
  steer_core/DataManager.py,sha256=KKpN8GiVHm8xfUmjHKgfLt_xRXT--dhNX8gxs022VHs,11156
2
- steer_core/__init__.py,sha256=z0zCHFTcKSR0tJ6h5qrpNmRVP21QIPP8N0p7quCnnm0,23
2
+ steer_core/__init__.py,sha256=nllDrH0jyChMuuYrK0CC55iTBKUNTUjejtcwxyUF2EQ,23
3
3
  steer_core/Apps/ContextManagers.py,sha256=p3_m6cio2bobP0gg03Iu18XRPHTeIsoZasf5TnLsvZg,1810
4
4
  steer_core/Apps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  steer_core/Apps/Components/MaterialSelectors.py,sha256=KVDhOK5c0LT-2z9_o_QYdk6wsDjPEZ0Wb4xHXOjZvNc,31715
@@ -15,19 +15,19 @@ steer_core/Constants/Universal.py,sha256=5FWdrex5NiI2DResDmwO7GIvGN2B0DNtdlG1l-y
15
15
  steer_core/Constants/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  steer_core/ContextManagers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  steer_core/Data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
- steer_core/Data/database.db,sha256=tPRIFjJeazk4VVtySkKvY9CaJf7nIA5EtVP7YtyFWZo,12795904
18
+ steer_core/Data/database.db,sha256=R2r_jtXnP_ywNScbGuZgMdlmHxcMZto19Ap0eSCY8n0,13615104
19
19
  steer_core/Decorators/Coordinates.py,sha256=qo79PlA8ZZ6QY-VvH9YGg27gqpVJ2-Xa3blyoQVCp7A,1436
20
20
  steer_core/Decorators/Electrochemical.py,sha256=fAy89aw3zspBu_8UPa5kEhUpvO-bYpM0xH1r6O6mSiA,985
21
21
  steer_core/Decorators/General.py,sha256=-Wu-kTC9JAokicgt_nvANR7zpbCBPNR1kDmY6jzHfy4,966
22
22
  steer_core/Decorators/Objects.py,sha256=xiQfFgyTY2k8MF4lWojHMWbUMzojpyt8fRGl5bTNze8,503
23
23
  steer_core/Decorators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
24
  steer_core/Mixins/Colors.py,sha256=rJnXyUb9hdy3SkzrPV9dXvnBFZ1funYRF8Q0EZr3vZA,1152
25
- steer_core/Mixins/Coordinates.py,sha256=L5-OqG30lpqLjJd4SDhSxF_W2G4q5vsLMFfxTZjNzcg,12937
25
+ steer_core/Mixins/Coordinates.py,sha256=lxToydRFDiRkHdA2sOJKZnu44ztbNfURV6aza5eMGtE,12969
26
26
  steer_core/Mixins/Data.py,sha256=wdNedZHS5Q7B-pCIoEbqTWMcxsC91CVn9pbQ2Zszg3w,1363
27
27
  steer_core/Mixins/Serializer.py,sha256=x-aX8BcFSh5egZdkKinYMmIHLqZymCnETNUld3hzgnk,1039
28
- steer_core/Mixins/Validators.py,sha256=VmWmv1M8YqTzaIyc95TOvNEJScG7o8rQezQNor84DEc,12933
29
28
  steer_core/Mixins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
- steer_core-0.1.10.dist-info/METADATA,sha256=eJrB0lxEXEtff8IWG70vGtIzvyyZq5n-PUQHobaR0LM,704
31
- steer_core-0.1.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
32
- steer_core-0.1.10.dist-info/top_level.txt,sha256=6LFpGCSDE_SqRoT7raeM3Ax7KTBKQnyXLXxM9kXtw5M,11
33
- steer_core-0.1.10.dist-info/RECORD,,
29
+ steer_core/Mixins/validators.py,sha256=3GwRJeC30JNpRYavkirdMsGlZxPrGVxe4cX0wxj8dG8,7449
30
+ steer_core-0.1.11.dist-info/METADATA,sha256=HKNtfkr6KVQlibYFgDNfIFc0CldmTf-j8-2kUvruXzk,704
31
+ steer_core-0.1.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
32
+ steer_core-0.1.11.dist-info/top_level.txt,sha256=6LFpGCSDE_SqRoT7raeM3Ax7KTBKQnyXLXxM9kXtw5M,11
33
+ steer_core-0.1.11.dist-info/RECORD,,