param 2.2.1rc2__tar.gz → 2.3.0a1__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.
Files changed (74) hide show
  1. {param-2.2.1rc2 → param-2.3.0a1}/.gitignore +1 -1
  2. {param-2.2.1rc2 → param-2.3.0a1}/PKG-INFO +14 -5
  3. {param-2.2.1rc2 → param-2.3.0a1}/numbergen/__init__.py +51 -29
  4. {param-2.2.1rc2 → param-2.3.0a1}/param/__init__.py +54 -26
  5. {param-2.2.1rc2 → param-2.3.0a1}/param/_utils.py +234 -183
  6. {param-2.2.1rc2 → param-2.3.0a1}/param/_version.py +16 -3
  7. {param-2.2.1rc2 → param-2.3.0a1}/param/depends.py +4 -4
  8. {param-2.2.1rc2 → param-2.3.0a1}/param/ipython.py +22 -8
  9. {param-2.2.1rc2 → param-2.3.0a1}/param/parameterized.py +2212 -928
  10. {param-2.2.1rc2 → param-2.3.0a1}/param/parameters.py +193 -236
  11. {param-2.2.1rc2 → param-2.3.0a1}/param/reactive.py +978 -241
  12. {param-2.2.1rc2 → param-2.3.0a1}/param/serializer.py +4 -4
  13. {param-2.2.1rc2 → param-2.3.0a1}/param/version.py +45 -15
  14. {param-2.2.1rc2 → param-2.3.0a1}/pyproject.toml +15 -9
  15. param-2.3.0a1/tests/__init__.py +1 -0
  16. {param-2.2.1rc2 → param-2.3.0a1}/tests/conftest.py +5 -1
  17. {param-2.2.1rc2 → param-2.3.0a1}/tests/testaddparameter.py +2 -0
  18. {param-2.2.1rc2 → param-2.3.0a1}/tests/testbytesparam.py +1 -1
  19. {param-2.2.1rc2 → param-2.3.0a1}/tests/testcompositeparams.py +3 -3
  20. param-2.3.0a1/tests/testdefaultfactory.py +310 -0
  21. {param-2.2.1rc2 → param-2.3.0a1}/tests/testdefaults.py +4 -3
  22. param-2.3.0a1/tests/testdeprecations.py +87 -0
  23. {param-2.2.1rc2 → param-2.3.0a1}/tests/testdynamicparams.py +12 -12
  24. {param-2.2.1rc2 → param-2.3.0a1}/tests/testfiledeserialization.py +1 -1
  25. param-2.3.0a1/tests/testimports.py +30 -0
  26. {param-2.2.1rc2 → param-2.3.0a1}/tests/testipythonmagic.py +1 -1
  27. {param-2.2.1rc2 → param-2.3.0a1}/tests/testjsonserialization.py +1 -1
  28. {param-2.2.1rc2 → param-2.3.0a1}/tests/testlist.py +24 -2
  29. {param-2.2.1rc2 → param-2.3.0a1}/tests/testlistselector.py +16 -7
  30. {param-2.2.1rc2 → param-2.3.0a1}/tests/testnumpy.py +1 -1
  31. {param-2.2.1rc2 → param-2.3.0a1}/tests/testobjectselector.py +15 -6
  32. {param-2.2.1rc2 → param-2.3.0a1}/tests/testpandas.py +1 -1
  33. {param-2.2.1rc2 → param-2.3.0a1}/tests/testparamdepends.py +19 -0
  34. param-2.3.0a1/tests/testparameter.py +69 -0
  35. {param-2.2.1rc2 → param-2.3.0a1}/tests/testparameterizedobject.py +151 -12
  36. {param-2.2.1rc2 → param-2.3.0a1}/tests/testparamunion.py +1 -1
  37. {param-2.2.1rc2 → param-2.3.0a1}/tests/testreactive.py +59 -58
  38. {param-2.2.1rc2 → param-2.3.0a1}/tests/testrefs.py +49 -20
  39. {param-2.2.1rc2 → param-2.3.0a1}/tests/testsignatures.py +3 -22
  40. {param-2.2.1rc2 → param-2.3.0a1}/tests/teststringparam.py +1 -1
  41. {param-2.2.1rc2 → param-2.3.0a1}/tests/testtimedependent.py +28 -28
  42. {param-2.2.1rc2 → param-2.3.0a1}/tests/testutils.py +122 -2
  43. {param-2.2.1rc2 → param-2.3.0a1}/tests/testversion.py +3 -1
  44. {param-2.2.1rc2 → param-2.3.0a1}/tests/testwatch.py +12 -11
  45. {param-2.2.1rc2 → param-2.3.0a1}/tests/utils.py +8 -3
  46. param-2.2.1rc2/tests/__init__.py +0 -0
  47. param-2.2.1rc2/tests/testdeprecations.py +0 -205
  48. param-2.2.1rc2/tests/testimports.py +0 -20
  49. {param-2.2.1rc2 → param-2.3.0a1}/LICENSE.txt +0 -0
  50. {param-2.2.1rc2 → param-2.3.0a1}/README.md +0 -0
  51. {param-2.2.1rc2 → param-2.3.0a1}/param/display.py +0 -0
  52. {param-2.2.1rc2 → param-2.3.0a1}/tests/testbind.py +0 -0
  53. {param-2.2.1rc2 → param-2.3.0a1}/tests/testbooleanparam.py +0 -0
  54. {param-2.2.1rc2 → param-2.3.0a1}/tests/testcalendardateparam.py +0 -0
  55. {param-2.2.1rc2 → param-2.3.0a1}/tests/testcalendardaterangeparam.py +0 -0
  56. {param-2.2.1rc2 → param-2.3.0a1}/tests/testcallable.py +0 -0
  57. {param-2.2.1rc2 → param-2.3.0a1}/tests/testclassselector.py +0 -0
  58. {param-2.2.1rc2 → param-2.3.0a1}/tests/testcolorparameter.py +0 -0
  59. {param-2.2.1rc2 → param-2.3.0a1}/tests/testcomparator.py +0 -0
  60. {param-2.2.1rc2 → param-2.3.0a1}/tests/testcustomparam.py +0 -0
  61. {param-2.2.1rc2 → param-2.3.0a1}/tests/testdateparam.py +0 -0
  62. {param-2.2.1rc2 → param-2.3.0a1}/tests/testdaterangeparam.py +0 -0
  63. {param-2.2.1rc2 → param-2.3.0a1}/tests/testfileselector.py +0 -0
  64. {param-2.2.1rc2 → param-2.3.0a1}/tests/testmultifileselector.py +0 -0
  65. {param-2.2.1rc2 → param-2.3.0a1}/tests/testnumbergen.py +0 -0
  66. {param-2.2.1rc2 → param-2.3.0a1}/tests/testnumberparameter.py +0 -0
  67. {param-2.2.1rc2 → param-2.3.0a1}/tests/testparameterizedrepr.py +0 -0
  68. {param-2.2.1rc2 → param-2.3.0a1}/tests/testparamoutput.py +0 -0
  69. {param-2.2.1rc2 → param-2.3.0a1}/tests/testpathparam.py +0 -0
  70. {param-2.2.1rc2 → param-2.3.0a1}/tests/testpickle.py +0 -0
  71. {param-2.2.1rc2 → param-2.3.0a1}/tests/testrangeparameter.py +0 -0
  72. {param-2.2.1rc2 → param-2.3.0a1}/tests/testreprhtml.py +0 -0
  73. {param-2.2.1rc2 → param-2.3.0a1}/tests/testselector.py +0 -0
  74. {param-2.2.1rc2 → param-2.3.0a1}/tests/testtupleparam.py +0 -0
@@ -20,7 +20,7 @@ jupyter_execute/
20
20
  doc/Reference_Manual/
21
21
  doc/user_guide/data.pickle
22
22
  doc/user_guide/output.*
23
- doc/reference/generated
23
+ doc/reference/param/generated
24
24
 
25
25
  # Unit test / Coverage report
26
26
  .coverage
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: param
3
- Version: 2.2.1rc2
3
+ Version: 2.3.0a1
4
4
  Summary: Make your Python code clearer and more reliable by declaring Parameters.
5
5
  Project-URL: Homepage, https://param.holoviz.org/
6
6
  Project-URL: Tracker, https://github.com/holoviz/param/issues
@@ -18,18 +18,18 @@ Classifier: License :: OSI Approved :: BSD License
18
18
  Classifier: Natural Language :: English
19
19
  Classifier: Operating System :: OS Independent
20
20
  Classifier: Programming Language :: Python :: 3
21
- Classifier: Programming Language :: Python :: 3.9
22
21
  Classifier: Programming Language :: Python :: 3.10
23
22
  Classifier: Programming Language :: Python :: 3.11
24
23
  Classifier: Programming Language :: Python :: 3.12
25
24
  Classifier: Programming Language :: Python :: 3.13
25
+ Classifier: Programming Language :: Python :: 3.14
26
26
  Classifier: Topic :: Scientific/Engineering
27
27
  Classifier: Topic :: Software Development :: Libraries
28
- Requires-Python: >=3.9
28
+ Requires-Python: >=3.10
29
29
  Provides-Extra: all
30
30
  Requires-Dist: aiohttp; extra == 'all'
31
31
  Requires-Dist: cloudpickle; extra == 'all'
32
- Requires-Dist: gmpy; extra == 'all'
32
+ Requires-Dist: gmpy2; extra == 'all'
33
33
  Requires-Dist: ipython; extra == 'all'
34
34
  Requires-Dist: jsonschema; extra == 'all'
35
35
  Requires-Dist: nbval; extra == 'all'
@@ -42,6 +42,7 @@ Requires-Dist: panel; extra == 'all'
42
42
  Requires-Dist: pyarrow; extra == 'all'
43
43
  Requires-Dist: pytest; extra == 'all'
44
44
  Requires-Dist: pytest-asyncio; extra == 'all'
45
+ Requires-Dist: pytest-cov; extra == 'all'
45
46
  Requires-Dist: pytest-xdist; extra == 'all'
46
47
  Requires-Dist: tables; extra == 'all'
47
48
  Requires-Dist: xlrd; extra == 'all'
@@ -52,6 +53,7 @@ Requires-Dist: panel; extra == 'examples'
52
53
  Provides-Extra: tests
53
54
  Requires-Dist: pytest; extra == 'tests'
54
55
  Requires-Dist: pytest-asyncio; extra == 'tests'
56
+ Requires-Dist: pytest-cov; extra == 'tests'
55
57
  Provides-Extra: tests-deser
56
58
  Requires-Dist: odfpy; extra == 'tests-deser'
57
59
  Requires-Dist: openpyxl; extra == 'tests-deser'
@@ -69,7 +71,7 @@ Requires-Dist: pytest-xdist; extra == 'tests-examples'
69
71
  Provides-Extra: tests-full
70
72
  Requires-Dist: aiohttp; extra == 'tests-full'
71
73
  Requires-Dist: cloudpickle; extra == 'tests-full'
72
- Requires-Dist: gmpy; extra == 'tests-full'
74
+ Requires-Dist: gmpy2; extra == 'tests-full'
73
75
  Requires-Dist: ipython; extra == 'tests-full'
74
76
  Requires-Dist: jsonschema; extra == 'tests-full'
75
77
  Requires-Dist: nbval; extra == 'tests-full'
@@ -82,9 +84,16 @@ Requires-Dist: panel; extra == 'tests-full'
82
84
  Requires-Dist: pyarrow; extra == 'tests-full'
83
85
  Requires-Dist: pytest; extra == 'tests-full'
84
86
  Requires-Dist: pytest-asyncio; extra == 'tests-full'
87
+ Requires-Dist: pytest-cov; extra == 'tests-full'
85
88
  Requires-Dist: pytest-xdist; extra == 'tests-full'
86
89
  Requires-Dist: tables; extra == 'tests-full'
87
90
  Requires-Dist: xlrd; extra == 'tests-full'
91
+ Provides-Extra: tests-pypy
92
+ Requires-Dist: cloudpickle; extra == 'tests-pypy'
93
+ Requires-Dist: ipython; extra == 'tests-pypy'
94
+ Requires-Dist: jsonschema; extra == 'tests-pypy'
95
+ Requires-Dist: nest-asyncio; extra == 'tests-pypy'
96
+ Requires-Dist: numpy; extra == 'tests-pypy'
88
97
  Description-Content-Type: text/markdown
89
98
 
90
99
  <img src="https://raw.githubusercontent.com/holoviz/param/main/doc/_static/logo_horizontal.png" width=250>
@@ -133,24 +133,35 @@ operator_symbols = {
133
133
  }
134
134
 
135
135
  def pprint(x, *args, **kwargs):
136
- """Pretty-print the provided item, translating operators to their symbols"""
136
+ """Pretty-print the provided item, translating operators to their symbols."""
137
137
  return x.pprint(*args, **kwargs) if hasattr(x,'pprint') else operator_symbols.get(x, repr(x))
138
138
 
139
139
 
140
140
  class BinaryOperator(NumberGenerator):
141
- """Applies any binary operator to NumberGenerators or numbers to yield a NumberGenerator."""
141
+ """
142
+ Applies any binary operator to NumberGenerators or numbers to yield a NumberGenerator.
142
143
 
143
- def __init__(self,lhs,rhs,operator,reverse=False,**args):
144
- """
145
- Accepts two NumberGenerator operands, an operator, and
146
- optional arguments to be provided to the operator when calling
147
- it on the two operands.
148
- """
149
- # Note that it's currently not possible to set
150
- # parameters in the superclass when creating an instance,
151
- # because **args is used by this class itself.
152
- super().__init__()
144
+ Parameters
145
+ ----------
146
+ lhs: NumberGenerator or Number
147
+ The left-hand side operand, which can be a NumberGenerator or a number.
148
+ rhs: NumberGenerator or Number
149
+ The right-hand side operand, which can be a NumberGenerator or a number.
150
+ operator : callable
151
+ The binary operator to apply to the operands.
152
+ reverse : bool, optional
153
+ If `True`, swaps the left and right operands. Defaults to `False`.
154
+ **args:
155
+ Optional keyword arguments to pass to the operator when it is called.
156
+
157
+ Notes
158
+ -----
159
+ It is currently not possible to set parameters in the superclass during
160
+ initialization because `**args` is used by this class itself.
161
+ """
153
162
 
163
+ def __init__(self,lhs, rhs, operator, reverse=False, **args):
164
+ super().__init__()
154
165
  if reverse:
155
166
  self.lhs=rhs
156
167
  self.rhs=lhs
@@ -171,17 +182,25 @@ class BinaryOperator(NumberGenerator):
171
182
 
172
183
 
173
184
  class UnaryOperator(NumberGenerator):
174
- """Applies any unary operator to a NumberGenerator to yield another NumberGenerator."""
185
+ """
186
+ Applies any unary operator to a NumberGenerator to yield another NumberGenerator.
175
187
 
176
- def __init__(self,operand,operator,**args):
177
- """
178
- Accepts a NumberGenerator operand, an operator, and
179
- optional arguments to be provided to the operator when calling
180
- it on the operand.
181
- """
182
- # Note that it's currently not possible to set
183
- # parameters in the superclass when creating an instance,
184
- # because **args is used by this class itself.
188
+ Parameters
189
+ ----------
190
+ operand : NumberGenerator
191
+ The NumberGenerator to which the operator is applied.
192
+ operator : callable
193
+ The unary operator to apply to the operand.
194
+ **args:
195
+ Optional keyword arguments to pass to the operator when it is called.
196
+
197
+ Notes
198
+ -----
199
+ It is currently not possible to set parameters in the superclass during
200
+ initialization because `**args` is used by this class itself.
201
+ """
202
+
203
+ def __init__(self, operand, operator, **args):
185
204
  super().__init__()
186
205
 
187
206
  self.operand=operand
@@ -228,7 +247,11 @@ class Hash:
228
247
  numer, denom = val, 1
229
248
  elif isinstance(val, fractions.Fraction):
230
249
  numer, denom = val.numerator, val.denominator
250
+ elif hasattr(val, 'numerator') and hasattr(val, 'denominator'):
251
+ # gmpy2 mpq objects have these attributes
252
+ numer, denom = val.numerator, val.denominator
231
253
  elif hasattr(val, 'numer'):
254
+ # I think this branch supports gmpy (i.e. not gmpy2)
232
255
  (numer, denom) = (int(val.numer()), int(val.denom()))
233
256
  else:
234
257
  param.main.param.log(param.WARNING, "Casting type '%s' to Fraction.fraction"
@@ -237,15 +260,13 @@ class Hash:
237
260
  numer, denom = frac.numerator, frac.denominator
238
261
  return numer % I32, denom % I32
239
262
 
240
-
241
263
  def __getstate__(self):
242
- """Avoid Hashlib.md5 TypeError in deepcopy (hashlib issue)"""
264
+ """Avoid Hashlib.md5 TypeError in deepcopy (hashlib issue)."""
243
265
  d = self.__dict__.copy()
244
266
  d.pop('_digest')
245
267
  d.pop('_hash_struct')
246
268
  return d
247
269
 
248
-
249
270
  def __setstate__(self, d):
250
271
  self._digest = hashlib.md5()
251
272
  name, input_count = d['name'], d['input_count']
@@ -253,14 +274,13 @@ class Hash:
253
274
  self._hash_struct = struct.Struct( "!" +" ".join(["I"] * (input_count * 2)))
254
275
  self.__dict__.update(d)
255
276
 
256
-
257
277
  def __call__(self, *vals):
258
278
  """
259
279
  Given integer or rational inputs, generate a cross-platform,
260
280
  architecture-independent 32-bit integer hash.
261
281
  """
262
282
  # Convert inputs to (numer, denom) pairs with integers
263
- # becoming (int, 1) pairs to match gmpy.mpqs for int values.
283
+ # becoming (int, 1) pairs to match gmpy2.mpqs for int values.
264
284
  pairs = [self._rational(val) for val in vals]
265
285
  # Unpack pairs and fill struct with ints to update md5 hash
266
286
  ints = [el for pair in pairs for el in pair]
@@ -330,7 +350,9 @@ class TimeAwareRandomState(TimeAware):
330
350
 
331
351
  def _initialize_random_state(self, seed=None, shared=True, name=None):
332
352
  """
333
- Initialization method to be called in the constructor of
353
+ Initialize the random state correctly.
354
+
355
+ Method to be called in the constructor of
334
356
  subclasses to initialize the random state correctly.
335
357
 
336
358
  If seed is None, there is no control over the random stream
@@ -427,7 +449,7 @@ class RandomDistribution(NumberGenerator, TimeAwareRandomState):
427
449
 
428
450
  __abstract = True
429
451
 
430
- def __init__(self,**params):
452
+ def __init__(self, **params):
431
453
  """
432
454
  Initialize a new Random() instance and store the supplied
433
455
  positional and keyword arguments.
@@ -1,24 +1,65 @@
1
+
2
+ """
3
+ Param: A declarative framework for managing parameters and reactive programming in Python.
4
+
5
+ Param is a lightweight library for defining and managing user-modifiable parameters,
6
+ designed to simplify Python programs and enhance their readability, maintainability,
7
+ and robustness. In addition Param provides the `rx` framework for reactive programming.
8
+
9
+ Param is well-suited for use in scientific computing, data analysis tools,
10
+ graphical user interfaces (GUIs), and any Python application where well-defined,
11
+ validated parameters are needed.
12
+
13
+ References
14
+ ----------
15
+ For detailed documentation, see https://param.holoviz.org/.
16
+
17
+ Examples
18
+ --------
19
+ Here is an example of using `param.Parameterized` to define a class with validated parameters:
20
+
21
+ >>> import param
22
+ >>> class MyClass(param.Parameterized):
23
+ ... my_number = param.Number(default=1, bounds=(0, 10))
24
+ ... my_list = param.List(default=[1, 2, 3], item_type=int)
25
+
26
+ >>> obj = MyClass()
27
+ >>> obj.my_number = 5 # Valid
28
+ >>> obj.my_number = 15 # Raises ValueError: must be in range (0, 10)
29
+
30
+ Here is an example of using `param.rx` to define a reactive expression:
31
+
32
+ >>> import param
33
+ >>> rx_value = param.rx([1,2,3])
34
+ >>> rx_value.rx.len()
35
+ 3
36
+
37
+ Lets update the reactive value and check its length:
38
+
39
+ >>> rx_value.rx.value = [1,2,3,4]
40
+ >>> rx_value.rx.len()
41
+ 4
42
+ """
1
43
  import os
2
44
 
3
- from . import version # noqa: api import
4
- from .depends import depends # noqa: api import
5
- from .parameterized import ( # noqa: api import
45
+ from . import version
46
+ from .depends import depends
47
+ from .parameterized import (
6
48
  Parameterized, Parameter, Skip, String, ParameterizedFunction,
7
- ParamOverrides, Undefined, get_logger
49
+ ParamOverrides, Undefined, get_logger, ParameterizedABC,
8
50
  )
9
- from .parameterized import (batch_watch, output, script_repr, # noqa: api import
51
+ from .parameterized import (output, script_repr,
10
52
  discard_events, edit_constant)
11
- from .parameterized import shared_parameters # noqa: api import
12
- from .parameterized import logging_level # noqa: api import
13
- from .parameterized import DEBUG, VERBOSE, INFO, WARNING, ERROR, CRITICAL # noqa: api import
14
- from .parameters import ( # noqa: api import
53
+ from .parameterized import shared_parameters
54
+ from .parameterized import logging_level
55
+ from .parameterized import DEBUG, VERBOSE, INFO, WARNING, ERROR, CRITICAL
56
+ from .parameters import (
15
57
  guess_param_types,
16
58
  param_union,
17
59
  parameterized_class,
18
60
  guess_bounds,
19
61
  get_soft_bounds,
20
62
  resolve_path,
21
- normalize_path,
22
63
  Time,
23
64
  Infinity,
24
65
  Dynamic,
@@ -58,16 +99,10 @@ from .parameters import ( # noqa: api import
58
99
  CalendarDateRange,
59
100
  Event,
60
101
  )
61
- from .reactive import bind, rx # noqa: api import
62
- from ._utils import ( # noqa: api import
63
- produce_value,
64
- as_unicode,
65
- is_ordered_dict,
66
- hashable,
67
- named_objs,
102
+ from .reactive import bind, rx
103
+ from ._utils import (
68
104
  descendents,
69
105
  concrete_descendents,
70
- abbreviate_paths,
71
106
  exceptions_summarized,
72
107
  _is_number,
73
108
  )
@@ -155,6 +190,7 @@ __all__ = (
155
190
  'ParamOverrides',
156
191
  'Parameter',
157
192
  'Parameterized',
193
+ 'ParameterizedABC',
158
194
  'ParameterizedFunction',
159
195
  'Path',
160
196
  'Range',
@@ -171,9 +207,6 @@ __all__ = (
171
207
  'XYCoordinates',
172
208
  '__version__',
173
209
  '_is_number',
174
- 'abbreviate_paths',
175
- 'as_unicode',
176
- 'batch_watch',
177
210
  'bind',
178
211
  'concrete_descendents',
179
212
  'depends',
@@ -185,16 +218,11 @@ __all__ = (
185
218
  'get_soft_bounds',
186
219
  'guess_bounds',
187
220
  'guess_param_types',
188
- 'hashable',
189
- 'is_ordered_dict',
190
221
  'logging_level',
191
222
  'main',
192
- 'named_objs',
193
- 'normalize_path',
194
223
  'output',
195
224
  'param_union',
196
225
  'parameterized_class',
197
- 'produce_value',
198
226
  'random_seed',
199
227
  'resolve_path',
200
228
  'rx',