steer-core 0.1.10__py3-none-any.whl → 0.1.12__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.
@@ -36,12 +36,12 @@ class SliderWithTextInput:
36
36
  Example:
37
37
  >>> slider_component = SliderWithTextInput(
38
38
  ... id_base={'type': 'parameter', 'index': 0},
39
+ ... property_name='temperature',
40
+ ... title='Temperature (°C)',
39
41
  ... min_val=0.0,
40
42
  ... max_val=100.0,
41
43
  ... step=1.0,
42
- ... mark_interval=10.0,
43
- ... property_name='temperature',
44
- ... title='Temperature (°C)',
44
+ ... mark_interval=50.0,
45
45
  ... default_val=25.0,
46
46
  ... message='Optimal range is 20-30°C' # Optional message
47
47
  ... )
@@ -51,12 +51,12 @@ class SliderWithTextInput:
51
51
  def __init__(
52
52
  self,
53
53
  id_base: dict,
54
- min_val: float,
55
- max_val: float,
56
- step: float,
57
- mark_interval: float,
58
54
  property_name: str,
59
55
  title: str,
56
+ min_val: float = 0.0,
57
+ max_val: float = 100.0,
58
+ step: float = 1.0,
59
+ mark_interval: float = 50.0,
60
60
  default_val: Union[float, list[float]] = None,
61
61
  with_slider_titles: bool = True,
62
62
  slider_disable: bool = False,
@@ -71,17 +71,17 @@ class SliderWithTextInput:
71
71
  id_base (dict): Base dictionary for generating component IDs. Should contain
72
72
  identifying information that will be extended with component-specific
73
73
  subtypes and properties.
74
- min_val (float): Minimum value that can be selected on the slider or entered
75
- in the text input.
76
- max_val (float): Maximum value that can be selected on the slider or entered
77
- in the text input.
78
- step (float): The granularity of value changes. Determines the smallest
79
- increment/decrement possible.
80
- mark_interval (float): The spacing between tick marks displayed on the slider.
81
- Should be a multiple of step for best visual alignment.
82
74
  property_name (str): A string identifier for this specific property, used
83
75
  in ID generation and callbacks.
84
76
  title (str): Human-readable title displayed above the component.
77
+ min_val (float, optional): Minimum value that can be selected on the slider or entered
78
+ in the text input. Defaults to 0.0.
79
+ max_val (float, optional): Maximum value that can be selected on the slider or entered
80
+ in the text input. Defaults to 100.0.
81
+ step (float, optional): The granularity of value changes. Determines the smallest
82
+ increment/decrement possible. Defaults to 1.0.
83
+ mark_interval (float, optional): The spacing between tick marks displayed on the slider.
84
+ Should be a multiple of step for best visual alignment. Defaults to 50.0.
85
85
  default_val (Union[float, list[float]], optional): Initial value to display.
86
86
  If None, defaults to min_val. Can be a single float or list
87
87
  for compatibility with range sliders.
@@ -439,14 +439,14 @@ class SliderWithTextInputAndCheckbox(SliderWithTextInput):
439
439
  Example:
440
440
  >>> slider_component = SliderWithTextInputAndCheckbox(
441
441
  ... id_base={'type': 'parameter', 'index': 0},
442
+ ... property_name='temperature',
443
+ ... title='Temperature (°C)',
444
+ ... checkbox_message='Use automatic temperature control',
442
445
  ... min_val=0.0,
443
446
  ... max_val=100.0,
444
447
  ... step=1.0,
445
- ... mark_interval=10.0,
446
- ... property_name='temperature',
447
- ... title='Temperature (°C)',
448
+ ... mark_interval=50.0,
448
449
  ... default_val=25.0,
449
- ... checkbox_message='Use automatic temperature control',
450
450
  ... checkbox_default=True
451
451
  ... )
452
452
  >>> layout_element = slider_component() # Returns Dash HTML Div component
@@ -455,13 +455,13 @@ class SliderWithTextInputAndCheckbox(SliderWithTextInput):
455
455
  def __init__(
456
456
  self,
457
457
  id_base: dict,
458
- min_val: float,
459
- max_val: float,
460
- step: float,
461
- mark_interval: float,
462
458
  property_name: str,
463
459
  title: str,
464
460
  checkbox_message: str,
461
+ min_val: float = 0.0,
462
+ max_val: float = 100.0,
463
+ step: float = 1.0,
464
+ mark_interval: float = 50.0,
465
465
  default_val: Union[float, list[float]] = None,
466
466
  checkbox_default: bool = False,
467
467
  with_slider_titles: bool = True,
@@ -474,13 +474,13 @@ class SliderWithTextInputAndCheckbox(SliderWithTextInput):
474
474
 
475
475
  Args:
476
476
  id_base (dict): Base dictionary for generating component IDs.
477
- min_val (float): Minimum value for the slider and input.
478
- max_val (float): Maximum value for the slider and input.
479
- step (float): Step size for value increments/decrements.
480
- mark_interval (float): Interval between tick marks on the slider.
481
477
  property_name (str): String identifier for this property.
482
478
  title (str): Title displayed above the component.
483
479
  checkbox_message (str): Message displayed next to the checkbox.
480
+ min_val (float, optional): Minimum value for the slider and input. Defaults to 0.0.
481
+ max_val (float, optional): Maximum value for the slider and input. Defaults to 100.0.
482
+ step (float, optional): Step size for value increments/decrements. Defaults to 1.0.
483
+ mark_interval (float, optional): Interval between tick marks on the slider. Defaults to 50.0.
484
484
  default_val (Union[float, list[float]], optional): Initial value for slider/input.
485
485
  checkbox_default (bool, optional): Initial checked state of checkbox. Defaults to False.
486
486
  with_slider_titles (bool, optional): Whether to show title. Defaults to True.
@@ -491,12 +491,12 @@ class SliderWithTextInputAndCheckbox(SliderWithTextInput):
491
491
  # Initialize parent class
492
492
  super().__init__(
493
493
  id_base=id_base,
494
+ property_name=property_name,
495
+ title=title,
494
496
  min_val=min_val,
495
497
  max_val=max_val,
496
498
  step=step,
497
499
  mark_interval=mark_interval,
498
- property_name=property_name,
499
- title=title,
500
500
  default_val=default_val,
501
501
  with_slider_titles=with_slider_titles,
502
502
  slider_disable=slider_disable,
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.12"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: steer-core
3
- Version: 0.1.10
3
+ Version: 0.1.12
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,10 +1,10 @@
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=LcIlFjHZFfiF9Rd4UHoakmombOFkxIYk00I181frGBM,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
6
6
  steer_core/Apps/Components/RangeSliderComponents.py,sha256=At-xmyIS9GEAO7MzWXc4vwwzY-zqwNKdGHYkXSUIDck,21732
7
- steer_core/Apps/Components/SliderComponents.py,sha256=Vo1pXhWwjxaRF_q2jUDJD2M5OgFsfQW7oFlrceVMDc0,27404
7
+ steer_core/Apps/Components/SliderComponents.py,sha256=SQRt8LQxNHCeif70CF4cgx-Cvwx_poUSweu86qYJBlA,27680
8
8
  steer_core/Apps/Components/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  steer_core/Apps/Performance/CallbackTimer.py,sha256=wFbW2_nl6KdEKrtdviOh5y66ZQlbVf0ZDHm-SZBjbYg,390
10
10
  steer_core/Apps/Performance/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -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=IWiVyk8K0uTqGeZc8yvr6kT39Jx-YneyKEe7MNYqOBU,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.12.dist-info/METADATA,sha256=IVsM6pM9Egt65iofe3vwZBV2yNYBUPsQURPqKaPgGZ4,704
31
+ steer_core-0.1.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
32
+ steer_core-0.1.12.dist-info/top_level.txt,sha256=6LFpGCSDE_SqRoT7raeM3Ax7KTBKQnyXLXxM9kXtw5M,11
33
+ steer_core-0.1.12.dist-info/RECORD,,