steer-core 0.1.5__py3-none-any.whl → 0.1.7__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.
@@ -0,0 +1,55 @@
1
+ import warnings
2
+ import time
3
+ from contextlib import contextmanager
4
+ from typing import List, Dict
5
+
6
+
7
+ @contextmanager
8
+ def capture_warnings(existing_warnings: List[Dict] = None, source: str = None, clear_source_warnings: bool = True):
9
+ """
10
+ Context manager to capture warnings and format them for Dash.
11
+
12
+ Parameters
13
+ ----------
14
+ existing_warnings : List[Dict], optional
15
+ Existing warnings to append to
16
+ source : str, optional
17
+ Source identifier for the warnings
18
+ clear_source_warnings : bool, optional
19
+ Whether to clear existing warnings from the same source before adding new ones
20
+
21
+ Yields
22
+ ------
23
+ List[Dict]
24
+ The combined list of warnings (existing + new)
25
+ """
26
+ if existing_warnings is None:
27
+ existing_warnings = []
28
+
29
+ # Clear existing warnings from the same source if requested
30
+ if clear_source_warnings and source:
31
+ existing_warnings = [w for w in existing_warnings if w.get('source') != source]
32
+
33
+ with warnings.catch_warnings(record=True) as warnings_list:
34
+ warnings.simplefilter("always")
35
+
36
+ # Yield the cleaned warnings list
37
+ yield existing_warnings
38
+
39
+ # Process any new warnings after the operation
40
+ new_warnings = []
41
+ for w in warnings_list:
42
+
43
+ new_warnings.append({
44
+ 'message': str(w.message),
45
+ 'category': w.category.__name__,
46
+ 'filename': w.filename,
47
+ 'lineno': w.lineno,
48
+ 'timestamp': time.time(),
49
+ 'source': source or 'unknown',
50
+ 'id': f"{source}_{int(time.time())}" if source else f"warning_{int(time.time())}"
51
+ })
52
+
53
+ # Add new warnings
54
+ existing_warnings.extend(new_warnings)
55
+
@@ -0,0 +1,17 @@
1
+ from functools import wraps
2
+ import time
3
+
4
+
5
+ def timed_callback(func):
6
+ """Time callback execution for optimization."""
7
+ @wraps(func)
8
+ def wrapper(*args, **kwargs):
9
+ start = time.time()
10
+ result = func(*args, **kwargs)
11
+ duration = time.time() - start
12
+
13
+ print(f"CALLBACK: {func.__name__} took {duration:.2f}s")
14
+
15
+ return result
16
+ return wrapper
17
+
File without changes
File without changes
File without changes
steer_core/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.1.5"
1
+ __version__ = "0.1.7"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: steer-core
3
- Version: 0.1.5
3
+ Version: 0.1.7
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,9 +1,14 @@
1
1
  steer_core/DataManager.py,sha256=r9AmA1Aqmjk66xrUp03GFdVbp0ChFod6NmonUr8SGOw,11094
2
- steer_core/__init__.py,sha256=rPSfWgIeq2YWVPyESOAwCBt8vftsTpIkuLAGDEzyRQc,22
2
+ steer_core/__init__.py,sha256=YpKDcdV7CqL8n45u267wKtyloM13FSVbOdrqgNZnSLM,22
3
+ steer_core/Apps/ContextManagers.py,sha256=p3_m6cio2bobP0gg03Iu18XRPHTeIsoZasf5TnLsvZg,1810
4
+ steer_core/Apps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ steer_core/Apps/Performance/CallbackTimer.py,sha256=wFbW2_nl6KdEKrtdviOh5y66ZQlbVf0ZDHm-SZBjbYg,390
6
+ steer_core/Apps/Performance/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
7
  steer_core/Constants/Units.py,sha256=Bdlv_APY2-kbKva3FW4jA0srTbavqAumrEaaQ6HNKuU,489
4
8
  steer_core/Constants/Universal.py,sha256=5FWdrex5NiI2DResDmwO7GIvGN2B0DNtdlG1l-ysDh8,41
5
9
  steer_core/Constants/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
10
  steer_core/ContextManagers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ steer_core/Data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
12
  steer_core/Decorators/Coordinates.py,sha256=qo79PlA8ZZ6QY-VvH9YGg27gqpVJ2-Xa3blyoQVCp7A,1436
8
13
  steer_core/Decorators/Electrochemical.py,sha256=fAy89aw3zspBu_8UPa5kEhUpvO-bYpM0xH1r6O6mSiA,985
9
14
  steer_core/Decorators/General.py,sha256=-Wu-kTC9JAokicgt_nvANR7zpbCBPNR1kDmY6jzHfy4,966
@@ -15,7 +20,7 @@ steer_core/Mixins/Data.py,sha256=wdNedZHS5Q7B-pCIoEbqTWMcxsC91CVn9pbQ2Zszg3w,136
15
20
  steer_core/Mixins/Serializer.py,sha256=x-aX8BcFSh5egZdkKinYMmIHLqZymCnETNUld3hzgnk,1039
16
21
  steer_core/Mixins/Validators.py,sha256=VmWmv1M8YqTzaIyc95TOvNEJScG7o8rQezQNor84DEc,12933
17
22
  steer_core/Mixins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
- steer_core-0.1.5.dist-info/METADATA,sha256=xJgmkHbcFprGia4hGD7NMRbwZbVmbHT5x408PktQ3us,703
19
- steer_core-0.1.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
20
- steer_core-0.1.5.dist-info/top_level.txt,sha256=6LFpGCSDE_SqRoT7raeM3Ax7KTBKQnyXLXxM9kXtw5M,11
21
- steer_core-0.1.5.dist-info/RECORD,,
23
+ steer_core-0.1.7.dist-info/METADATA,sha256=wFKUnaYyQrEqklkM8fDkk1Kd1O5aKUSW8T2M6IutL4c,703
24
+ steer_core-0.1.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
25
+ steer_core-0.1.7.dist-info/top_level.txt,sha256=6LFpGCSDE_SqRoT7raeM3Ax7KTBKQnyXLXxM9kXtw5M,11
26
+ steer_core-0.1.7.dist-info/RECORD,,