corelp 1.0.16__py3-none-any.whl → 1.0.18__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.
@@ -14,6 +14,7 @@ Gets last user inputs dictionnary from global variables.
14
14
 
15
15
  # %% Libraries
16
16
  import inspect
17
+ from IPython import get_ipython
17
18
 
18
19
 
19
20
 
@@ -48,12 +49,29 @@ def user_inputs() :
48
49
  {'a': 1}
49
50
  """
50
51
 
51
- frame = inspect.currentframe().f_back
52
- current_vars = {**frame.f_globals, **frame.f_locals}
53
- current_vars = {k: v for k, v in current_vars.items() if not k.startswith("_")}
54
- inputs = {k: v for k, v in current_vars.items() if k not in _user_inputs or _user_inputs[k] != v}
55
- _user_inputs.update(inputs)
56
- return inputs
52
+ # ---- Detect execution environment ----
53
+ ipy = get_ipython()
54
+
55
+ if ipy is not None:
56
+ # Running in IPython or Jupyter
57
+ ns = ipy.user_ns
58
+ else:
59
+ # Running in normal Python script
60
+ frame = inspect.currentframe().f_back
61
+ ns = {**frame.f_globals, **frame.f_locals}
62
+
63
+ # ---- Filter user variables (ignore internals starting with "_") ----
64
+ ns = {k: v for k, v in ns.items() if not k.startswith("_")}
65
+
66
+ # ---- Return only new or updated variables ----
67
+ updated = {
68
+ k: v
69
+ for k, v in ns.items()
70
+ if k not in _user_inputs or _user_inputs[k] is not v
71
+ }
72
+
73
+ _user_inputs.update(updated)
74
+ return updated
57
75
 
58
76
 
59
77
 
@@ -1,9 +1,11 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: corelp
3
- Version: 1.0.16
3
+ Version: 1.0.18
4
4
  Summary: A library that gathers core functions for python programming.
5
5
  Requires-Dist: corelp
6
6
  Requires-Dist: ipykernel
7
+ Requires-Dist: ipython
8
+ Requires-Dist: ipywidgets
7
9
  Requires-Dist: joblib
8
10
  Requires-Dist: pytest
9
11
  Requires-Dist: rich
@@ -38,11 +38,11 @@ corelp/modules/test_LP/test.py,sha256=KwAeIZWQ7pZX85J50q6qfB4HuJUgREu1ieB_byPqI2
38
38
  corelp/modules/test_LP/test_test.py,sha256=sXI6G4OBnWXSqrfMy9QdabkYIvcD80EmnNcnQiXxcRI,605
39
39
  corelp/modules/user_inputs_LP/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
40
  corelp/modules/user_inputs_LP/test_user_inputs.py,sha256=lK8pYm5q5ob9ry3T-gU3J_-KZMKWCCmeuFjjH7DkF_8,927
41
- corelp/modules/user_inputs_LP/user_inputs.py,sha256=O5-nHsZyiwrzJppWI4zs198-XX1KeyMf5qpR3U2oLAM,1585
41
+ corelp/modules/user_inputs_LP/user_inputs.py,sha256=2lGkIl2dA_1mcDB8ExvJg4xlcx26viKi878M9ml0MUo,1964
42
42
  corelp/modules.json,sha256=ZQ8BMU8X2u71wfVj_AufwOoJUPdaxU_AHn7Ohbkp-Pc,3122
43
43
  corelp/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
44
  corelp/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
45
  corelp/scripts.json,sha256=RBNvo1WzZ4oRRq0W9-hknpT7T8If536DEMBg9hyq_4o,2
46
- corelp-1.0.16.dist-info/WHEEL,sha256=NHRAbdxxzyL9K3IO2LjmlNqKSyPZnKv2BD16YYVKo18,79
47
- corelp-1.0.16.dist-info/METADATA,sha256=gSBRyGuuLcaTIGD9d1yOXzkfNEzPxEIvRm3GjAJgCls,1900
48
- corelp-1.0.16.dist-info/RECORD,,
46
+ corelp-1.0.18.dist-info/WHEEL,sha256=NHRAbdxxzyL9K3IO2LjmlNqKSyPZnKv2BD16YYVKo18,79
47
+ corelp-1.0.18.dist-info/METADATA,sha256=lcSBWjBvuIqvnSLZ4lOvidW6P3ukdjMiXSoqxTnEQJE,1949
48
+ corelp-1.0.18.dist-info/RECORD,,