steer-core 0.1.10__tar.gz → 0.1.11__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.
- {steer_core-0.1.10 → steer_core-0.1.11}/PKG-INFO +1 -1
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core/Data/database.db +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core/Mixins/Coordinates.py +8 -8
- steer_core-0.1.10/steer_core/Mixins/Validators.py → steer_core-0.1.11/steer_core/Mixins/validators.py +9 -185
- steer_core-0.1.11/steer_core/__init__.py +1 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core.egg-info/PKG-INFO +1 -1
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core.egg-info/SOURCES.txt +1 -0
- steer_core-0.1.10/steer_core/__init__.py +0 -1
- {steer_core-0.1.10 → steer_core-0.1.11}/README.md +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/setup.cfg +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/setup.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core/Apps/Components/MaterialSelectors.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core/Apps/Components/RangeSliderComponents.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core/Apps/Components/SliderComponents.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core/Apps/Components/__init__.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core/Apps/ContextManagers.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core/Apps/Performance/CallbackTimer.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core/Apps/Performance/__init__.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core/Apps/Utils/SliderControls.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core/Apps/Utils/__init__.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core/Apps/__init__.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core/Constants/Units.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core/Constants/Universal.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core/Constants/__init__.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core/ContextManagers/__init__.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core/Data/__init__.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core/DataManager.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core/Decorators/Coordinates.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core/Decorators/Electrochemical.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core/Decorators/General.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core/Decorators/Objects.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core/Decorators/__init__.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core/Mixins/Colors.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core/Mixins/Data.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core/Mixins/Serializer.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core/Mixins/__init__.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core.egg-info/dependency_links.txt +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core.egg-info/requires.txt +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/steer_core.egg-info/top_level.txt +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/test/test_compound_components.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/test/test_compound_components_clean.py +0 -0
- {steer_core-0.1.10 → steer_core-0.1.11}/test/test_slider_controls.py +0 -0
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
|
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=
|
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
|
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
|
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(
|
335
|
-
y_result.append(
|
334
|
+
x_result.append(np.nan)
|
335
|
+
y_result.append(np.nan)
|
336
336
|
|
337
|
-
return np.array(x_result, dtype=
|
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
|
17
|
+
def validate_type(value: Type, expected_type: Type, name: str) -> None:
|
18
18
|
"""
|
19
|
-
Validate that a value is
|
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
|
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
|
-
|
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
|
@@ -0,0 +1 @@
|
|
1
|
+
__version__ = "0.1.11"
|
@@ -34,6 +34,7 @@ steer_core/Mixins/Data.py
|
|
34
34
|
steer_core/Mixins/Serializer.py
|
35
35
|
steer_core/Mixins/Validators.py
|
36
36
|
steer_core/Mixins/__init__.py
|
37
|
+
steer_core/Mixins/validators.py
|
37
38
|
test/test_compound_components.py
|
38
39
|
test/test_compound_components_clean.py
|
39
40
|
test/test_slider_controls.py
|
@@ -1 +0,0 @@
|
|
1
|
-
__version__ = "0.1.10"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|