corelp 1.0.33__py3-none-any.whl → 1.0.35__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.
@@ -52,8 +52,8 @@ class Print() :
52
52
 
53
53
  Parameters
54
54
  ----------
55
- string : object
56
- The object to print. Its :meth:`__str__` representation is used.
55
+ *strings : tuple
56
+ The objects to print. Its :meth:`__str__` representation is used.
57
57
  verbose : bool, optional
58
58
  If ``True`` (default), printing is performed.
59
59
  If ``False``, printing is skipped unless overridden.
@@ -135,14 +135,17 @@ class Print() :
135
135
  """
136
136
 
137
137
  # Main function
138
- def __call__(self, string, verbose=None, *, return_string=False, file=None, mode='a', end='\n', **kwargs) :
138
+ def __call__(self, *strings, verbose=None, return_string=False, file=None, mode='a', end='\n', **kwargs) :
139
+
139
140
  # Muting
140
141
  verbose = verbose if verbose is not None else self.verbose
141
142
  if not verbose :
142
143
  return None
143
144
 
145
+ # Formatting string
146
+ string = ", ".join([str(string) for string in strings]) + end
147
+
144
148
  # Printing markdown
145
- string = str(string) + end
146
149
  self.print(Markdown(string), **kwargs)
147
150
 
148
151
  # Writting to file
@@ -170,7 +173,7 @@ class Print() :
170
173
  def log(self) :
171
174
  return self.console.log
172
175
  pyprint = pyprint # python print
173
- richprint = richprint # rich print
176
+ richprint = richprint # rich prints
174
177
 
175
178
 
176
179
 
@@ -281,7 +284,8 @@ class Print() :
281
284
  AvgLoopTimeColumn(),
282
285
  TimeRemainingColumn(),
283
286
  EndTimeColumn(),
284
- transient=False
287
+ transient=False,
288
+ console=self.console
285
289
  )
286
290
 
287
291
  _bars : dict = field(default=None, repr=False)
@@ -34,7 +34,8 @@ def test_user_inputs() :
34
34
  raise ValueError(f'{inputs} should be dict(a=1)')
35
35
  user_inputs() #init
36
36
  b = 2
37
- if user_inputs() != {'b': 2} :
37
+ inputs = user_inputs()
38
+ if inputs != {'b': 2} :
38
39
  raise ValueError(f'{inputs} should be dict(b=2)')
39
40
 
40
41
 
@@ -19,18 +19,14 @@ import inspect
19
19
 
20
20
  # %% Function
21
21
 
22
- def user_inputs() :
22
+ def user_inputs(reset=False) :
23
23
  r"""
24
- Return a dictionary of variables defined by the user in the interactive
25
- environment.
24
+ Return a dictionary of variables defined by the user in the interactive environment.
26
25
 
27
- This function is intended for use inside other functions via
28
- ``function(**user_inputs())``.
29
- **It should not be used to store its return value**, e.g. **do not do**::
30
-
31
- variable = user_inputs()
32
-
33
- Instead, call it directly when needed.
26
+ Parameters
27
+ ----------
28
+ reset : bool or str
29
+ True to set as first call, String value to define a group of parameters
34
30
 
35
31
  Returns
36
32
  -------
@@ -40,30 +36,49 @@ def user_inputs() :
40
36
  Examples
41
37
  --------
42
38
  >>> from corelp import user_inputs
43
- >>> user_inputs() # First call (initializes and clears import-related variables)
44
- {}
39
+ >>> user_inputs(True) # First call (initializes and clears import-related variables)
40
+ None
45
41
  >>> a = 1 # User defines a variable
46
42
  >>> user_inputs() # Now returns: {'a': 1}
47
43
  {'a': 1}
48
44
  """
49
-
50
45
  frame = inspect.currentframe().f_back
51
46
  ns = {**frame.f_globals, **frame.f_locals}
52
47
 
53
48
  # ---- Filter user variables (ignore internals starting with "_") ----
54
- ns = {k: v for k, v in ns.items() if not k.startswith("_")}
55
-
56
- # ---- Return only new or updated variables ----
57
- updated = {
58
- k: v
59
- for k, v in ns.items()
60
- if k not in user_inputs.cache or user_inputs.cache[k] is not v
61
- }
62
-
63
- user_inputs.cache.update(updated)
64
- return updated
49
+ ns = {key: value for key, value in ns.items() if not key.startswith("_")}
50
+
51
+ # Validate status
52
+ if reset :
53
+ user_inputs.current_group = reset if isinstance(reset, str) else None
54
+ user_inputs.cache = None
55
+
56
+ # Case when user_inputs is on top : cache = None
57
+ if user_inputs.cache is None :
58
+ user_inputs.cache = ns
59
+ return
60
+
61
+ # Case when user_inputs is at bottom : cache = dict
62
+ else :
63
+ updated = { key: value for key, value in ns.items() if key not in user_inputs.cache or user_inputs.cache[key] is not value}
64
+ values = {key: value for key, value in updated.items() if not key.endswith('_')}
65
+ comments = {key: value for key, value in updated.items() if key.endswith('_')}
66
+
67
+ # Group values
68
+ if user_inputs.current_group is not None :
69
+ user_inputs.groups_values[user_inputs.current_group] = values
70
+ user_inputs.groups_comments[user_inputs.current_group] = comments
71
+
72
+ # End
73
+ user_inputs.current_group = None
74
+ user_inputs.cache = None
75
+ return values
76
+
77
+ user_inputs.cache = None
78
+ user_inputs.current_group = None
79
+ user_inputs.groups_values = {}
80
+ user_inputs.groups_comments = {}
65
81
 
66
- user_inputs.cache = {}
67
82
 
68
83
 
69
84
  # %% Test function run
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: corelp
3
- Version: 1.0.33
3
+ Version: 1.0.35
4
4
  Summary: A library that gathers core functions for python programming.
5
5
  Requires-Dist: joblib
6
6
  Requires-Dist: rich
@@ -22,7 +22,7 @@ corelp/modules/main_LP/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
22
22
  corelp/modules/main_LP/main.py,sha256=vU9zXt6bLux1Fq6FiPwxhTJVo4SxJYeMbwKF0v_AjDs,10169
23
23
  corelp/modules/main_LP/test_main.py,sha256=mxL645pZdkJ8J5MFdj0K-z8xRCGKQ0zw1NvmW3iPGB4,1741
24
24
  corelp/modules/print_LP/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
- corelp/modules/print_LP/print.py,sha256=7TYjAGypT_TI0UHmL9F8zPL7gjFfJn2DnCpx0cu4IGM,8565
25
+ corelp/modules/print_LP/print.py,sha256=qPCqLpY2PdGLQaWmZKv9oh-MnvmpNYAplPeOcizO0uU,8662
26
26
  corelp/modules/print_LP/test_print.py,sha256=uMmCrnyIVSlZg_ZEOk2mr5zDlEpTN2KMq4jFu5p6n4I,2292
27
27
  corelp/modules/prop_LP/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
28
  corelp/modules/prop_LP/prop.py,sha256=lfsENmjg65mpXxt9V9n3Nn__wHgNJA61l8_UXBKn1lc,3999
@@ -37,13 +37,13 @@ corelp/modules/test_LP/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
37
37
  corelp/modules/test_LP/test.py,sha256=KwAeIZWQ7pZX85J50q6qfB4HuJUgREu1ieB_byPqI2g,1361
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
- 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=dqv78EnT1NiUf4ix_P6bQLoiAjNKHjYVu7lZYm-jXtI,1713
40
+ corelp/modules/user_inputs_LP/test_user_inputs.py,sha256=-6YzBomJxIZSfnfbJPvnfgon3K5RTC3WQKNT4enpVH0,947
41
+ corelp/modules/user_inputs_LP/user_inputs.py,sha256=ochRTY892XwYANBRyP-kwR_-7S96AVF4fIhfe6P4t1c,2472
42
42
  corelp/modules.json,sha256=ZQ8BMU8X2u71wfVj_AufwOoJUPdaxU_AHn7Ohbkp-Pc,3122
43
43
  corelp/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
44
  corelp/pythonLP.png:Zone.Identifier,sha256=uVLSTPcBvE56fSHhroXGEYJOgFeaiYNsDLSbGTRGzP4,25
45
45
  corelp/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
46
  corelp/scripts.json,sha256=RBNvo1WzZ4oRRq0W9-hknpT7T8If536DEMBg9hyq_4o,2
47
- corelp-1.0.33.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
48
- corelp-1.0.33.dist-info/METADATA,sha256=pwYkVZsYhheWKpAm9-1Un6IyAurHA93nB5IEtanT8Cc,1698
49
- corelp-1.0.33.dist-info/RECORD,,
47
+ corelp-1.0.35.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
48
+ corelp-1.0.35.dist-info/METADATA,sha256=_vAnlUmQ2r-K1ii8wOzfI9Z4P5bm9US1g3MrblSVL9U,1698
49
+ corelp-1.0.35.dist-info/RECORD,,