pymodaq 4.4.0__py3-none-any.whl → 4.4.2__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.

Potentially problematic release.


This version of pymodaq might be problematic. Click here for more details.

@@ -1,3 +1,5 @@
1
+ import numbers
2
+
1
3
  from time import perf_counter
2
4
  from typing import Union, List, Dict, TYPE_CHECKING, Optional
3
5
  from numbers import Number
@@ -61,9 +63,15 @@ class DataActuatorType(BaseEnum):
61
63
  DataActuator = 1
62
64
 
63
65
 
64
- def comon_parameters(epsilon=config('actuator', 'epsilon_default')):
66
+ def comon_parameters(epsilon=config('actuator', 'epsilon_default'),
67
+ epsilons=None):
68
+ if epsilons is not None:
69
+ epsilon=epsilons
65
70
  if isinstance(epsilon, list):
66
71
  epsilon=epsilon[0]
72
+ elif isinstance(epsilon, dict):
73
+ epsilon=epsilon[list[epsilon.keys()][0]]
74
+
67
75
  return [{'title': 'Units:', 'name': 'units', 'type': 'str', 'value': '', 'readonly': True},
68
76
  {'title': 'Epsilon:', 'name': 'epsilon', 'type': 'float',
69
77
  'value': epsilon,
@@ -106,32 +114,45 @@ class MoveCommand:
106
114
  self.value = value
107
115
 
108
116
 
109
- def comon_parameters_fun(is_multiaxes = False,
110
- axes_names: Union[List[str], Dict[str, int]] = [],
117
+ def comon_parameters_fun(is_multiaxes=False, axes_names=None,
111
118
  axis_names: Union[List, Dict] = [],
112
119
  master=True,
113
- epsilon=config('actuator', 'epsilon_default')):
120
+ epsilon: float = config('actuator', 'epsilon_default')):
121
+
114
122
  """Function returning the common and mandatory parameters that should be on the actuator plugin level
115
123
 
116
124
  Parameters
117
125
  ----------
118
- is_multiaxes: bool
126
+ is_multiaxes: bool # deprecated not need anymore
119
127
  If True, display the particular settings to define which axis the controller is driving
120
- axis_names: list of str
128
+ axes_names: deprecated, use axis_names
129
+ axis_names: list of str or dictionnary of string as key and integer as value
121
130
  The string identifier of every axis the controller can drive
122
131
  master: bool
123
132
  If True consider this plugin has to init the controller, otherwise use an already initialized instance
133
+ epsilon: float
134
+ deprecated (< 5.0.0) no more used here
135
+
124
136
  """
125
- if axis_names == [] and len(axes_names) != 0:
137
+ if axes_names is not None and len(axis_names) == 0:
138
+ if len(axes_names) == 0:
139
+ axes_names = ['']
126
140
  axis_names = axes_names
127
141
 
142
+ is_multiaxes = len(axis_names) > 1
143
+ if isinstance(axis_names, list):
144
+ axis_name = axis_names[0]
145
+ elif isinstance(axis_names, dict):
146
+ axis_name = axis_names[list(axis_names.keys())[0]]
128
147
  params = [
129
- {'title': 'MultiAxes:', 'name': 'multiaxes', 'type': 'group', 'visible': is_multiaxes, 'children': [
130
- {'title': 'is Multiaxes:', 'name': 'ismultiaxes', 'type': 'bool', 'value': is_multiaxes,
131
- 'default': False},
148
+ {'title': 'MultiAxes:', 'name': 'multiaxes', 'type': 'group',
149
+ 'visible': is_multiaxes, 'children': [
150
+ {'title': 'is Multiaxes:', 'name': 'ismultiaxes', 'type': 'bool',
151
+ 'value': is_multiaxes, 'default': False},
132
152
  {'title': 'Status:', 'name': 'multi_status', 'type': 'list',
133
153
  'value': 'Master' if master else 'Slave', 'limits': ['Master', 'Slave']},
134
- {'title': 'Axis:', 'name': 'axis', 'type': 'list', 'limits': axis_names},
154
+ {'title': 'Axis:', 'name': 'axis', 'type': 'list', 'limits': axis_names,
155
+ 'value': axis_name},
135
156
  ]},
136
157
  ] + comon_parameters(epsilon)
137
158
  return params
@@ -231,10 +252,16 @@ class DAQ_Move_base(QObject):
231
252
 
232
253
  move_done_signal = Signal(DataActuator)
233
254
  is_multiaxes = False
234
- stage_names = []
255
+ stage_names = [] # deprecated
256
+
257
+ _axis_names: Union[list, Dict[str, int]] = None
258
+ _controller_units: Union[str, List[str], Dict[str, int]] = ''
259
+ _epsilons: Union[float, List[float], Dict[str, float]] = None
260
+ _epsilon = 1.0 # deprecated
261
+
262
+
235
263
  params = []
236
- _controller_units: Union[str, List[str]] = ''
237
- _epsilon = 1.0
264
+
238
265
  data_actuator_type = DataActuatorType.float
239
266
  data_shape = (1, ) # expected shape of the underlying actuator's value (in general a float so shape = (1, ))
240
267
 
@@ -264,11 +291,11 @@ class DAQ_Move_base(QObject):
264
291
  else:
265
292
  self._title = "myactuator"
266
293
 
267
- self._axis_units: List[str] = []
294
+ self._axis_units: Union[Dict[str, str], List[str]] = None
268
295
  self.axis_units = self._controller_units
269
- self._epsilons: List[float] = [] # self._epsilon if isinstance(self._epsilon, list) else\
270
- # [self._epsilon for _ in range(len(self.axis_name))]
271
- self.epsilons = self._epsilon
296
+ if self._epsilons is None:
297
+ self._epsilons = self._epsilon
298
+ self.epsilons = self._epsilons
272
299
  self.axis_name = self.axis_name # to trigger some actions on units and epsilons
273
300
 
274
301
  self._current_value = DataActuator(self._title,
@@ -293,16 +320,16 @@ class DAQ_Move_base(QObject):
293
320
 
294
321
  New in 4.4.0
295
322
  """
296
- return self.axis_units[self.axis_value]
323
+ return self.axis_units[self.axis_index_key]
297
324
 
298
325
  @axis_unit.setter
299
326
  def axis_unit(self, unit: str):
300
- self.axis_units[self.axis_value] = unit
327
+ self.axis_units[self.axis_index_key] = unit
301
328
  self.settings.child('units').setValue(unit)
302
329
  self.emit_status(ThreadCommand('units', unit))
303
330
 
304
331
  @property
305
- def axis_units(self) -> List[str]:
332
+ def axis_units(self) -> Union[List[str], Dict[str, str]]:
306
333
  """ Get/Set the units for each axis of the controller
307
334
 
308
335
  New in 4.4.0
@@ -310,10 +337,23 @@ class DAQ_Move_base(QObject):
310
337
  return self._axis_units
311
338
 
312
339
  @axis_units.setter
313
- def axis_units(self, units: Union[str, List[str]]):
340
+ def axis_units(self, units: Union[str, List[str], Dict[str, str]]):
314
341
  if isinstance(units, str):
315
- units = [units for _ in range(len(self.axis_names))]
316
- self._axis_units = units
342
+ if isinstance(self.axis_names, list):
343
+ units_tmp = [units for _ in range(len(self.axis_names))]
344
+ else:
345
+ units_tmp = {}
346
+ for key in self.axis_names:
347
+ units_tmp[key] = units
348
+ else:
349
+ if not isinstance(units, type(self.axis_names)):
350
+ raise TypeError('units should be defined just like axis_names: a str, list of string or'
351
+ 'dict of string')
352
+ if len(units) != len(self.axis_names):
353
+ raise ValueError('Units should be defined either as a single str or a list/dict with'
354
+ 'a str defined for each axis')
355
+ units_tmp = units
356
+ self._axis_units = units_tmp
317
357
 
318
358
  @property
319
359
  def epsilon(self) -> float:
@@ -321,14 +361,14 @@ class DAQ_Move_base(QObject):
321
361
 
322
362
  New in 4.4.0
323
363
  """
324
- return self.epsilons[self.axis_value]
364
+ return self.epsilons[self.axis_index_key]
325
365
 
326
366
  @epsilon.setter
327
367
  def epsilon(self, eps: float):
328
- self.epsilons[self.axis_value] = eps
368
+ self.epsilons[self.axis_index_key] = eps
329
369
 
330
370
  @property
331
- def epsilons(self) -> List[float]:
371
+ def epsilons(self) -> Union[List[float], Dict[str, float]]:
332
372
  """ Get/Set the epsilon for each axis of the controller
333
373
 
334
374
  New in 4.4.0
@@ -336,10 +376,24 @@ class DAQ_Move_base(QObject):
336
376
  return self._epsilons
337
377
 
338
378
  @epsilons.setter
339
- def epsilons(self, epsilons: Union[float, List[float]]):
340
- if not isinstance(epsilons, Iterable) and isinstance(epsilons, float):
341
- epsilons = [epsilons for _ in range(len(self.axis_names))]
342
- self._epsilons = epsilons
379
+ def epsilons(self, epsilons: Union[float, List[float], Dict[str, float]]):
380
+ if isinstance(epsilons, numbers.Number):
381
+ if isinstance(self.axis_names, list):
382
+ epsilons_tmp = [epsilons for _ in range(len(self.axis_names))]
383
+ else:
384
+ epsilons_tmp = {}
385
+ for key in self.axis_names:
386
+ epsilons_tmp[key] = epsilons
387
+ else:
388
+ if not isinstance(epsilons, type(self.axis_names)):
389
+ raise TypeError('units should be defined just like axis_names: a float, list of '
390
+ 'float or dict of float')
391
+ if len(epsilons) != len(self.axis_names):
392
+ raise ValueError('epsilons should be defined either as a single float or a '
393
+ 'list/dict with'
394
+ 'a float defined for each axis')
395
+ epsilons_tmp = epsilons
396
+ self._epsilons = epsilons_tmp
343
397
 
344
398
  @property
345
399
  def controller_units(self):
@@ -357,7 +411,7 @@ class DAQ_Move_base(QObject):
357
411
  def controller_units(self, units: str = ''):
358
412
  deprecation_msg('The property controller_units is deprecated please use the'
359
413
  'axis_unit property.')
360
- self._axis_units[self.axis_value] = units
414
+ self._axis_units[self.axis_index_key] = units
361
415
 
362
416
  @property
363
417
  def axis_name(self) -> Union[str]:
@@ -398,12 +452,29 @@ class DAQ_Move_base(QObject):
398
452
 
399
453
  @property
400
454
  def axis_value(self) -> int:
401
- """Get the current value selected from the current axis"""
455
+ """Get the current value selected from the current axis
456
+
457
+ In case axis_names is a list, return the element of the list: self.axis_name
458
+ In case axis_names is a dict, return the value of the dict self.axis_names[self.axis_name]
459
+ """
402
460
  if isinstance(self.axis_names, list):
403
- return self.axis_names.index(self.axis_name)
461
+ return self.axis_name
404
462
  else:
405
463
  return self.axis_names[self.axis_name]
406
464
 
465
+ @property
466
+ def axis_index_key(self) -> Union[int, str]:
467
+ """ Get the current index or key correspondingto the current axis
468
+
469
+ In case axis_names is a list, return the index wihtin the list
470
+ In case axis_names is a dict, return the key of the dict self.axis_name
471
+
472
+ """
473
+ if isinstance(self.axis_names, list):
474
+ return self.axis_names.index(self.axis_name)
475
+ else:
476
+ return self.axis_name
477
+
407
478
  def ini_attributes(self):
408
479
  """ To be subclassed, in order to init specific attributes needed by the real implementation"""
409
480
  self.controller = None
@@ -442,14 +513,14 @@ class DAQ_Move_base(QObject):
442
513
 
443
514
  @property
444
515
  def current_value(self):
445
- if self.data_actuator_type.name == 'float':
516
+ if self.data_actuator_type == self.data_actuator_type.float:
446
517
  return self._current_value.value()
447
518
  else:
448
519
  return self._current_value
449
520
 
450
521
  @current_value.setter
451
522
  def current_value(self, value: Union[float, DataActuator]):
452
- if not isinstance(value, DataActuator):
523
+ if isinstance(value, numbers.Number):
453
524
  self._current_value = DataActuator(self._title, data=value,
454
525
  units=self.axis_unit)
455
526
  else:
@@ -461,14 +532,14 @@ class DAQ_Move_base(QObject):
461
532
 
462
533
  @property
463
534
  def target_value(self):
464
- if self.data_actuator_type.name == 'float':
535
+ if self.data_actuator_type.name == self.data_actuator_type.float:
465
536
  return self._target_value.value()
466
537
  else:
467
538
  return self._target_value
468
539
 
469
540
  @target_value.setter
470
- def target_value(self, value: Union[float, DataActuator]):
471
- if not isinstance(value, DataActuator):
541
+ def target_value(self, value: Union[numbers.Number, DataActuator]):
542
+ if isinstance(value, numbers.Number):
472
543
  self._target_value = DataActuator(self._title, data=value,
473
544
  units=self.axis_unit)
474
545
  else:
pymodaq/resources/VERSION CHANGED
@@ -1,2 +1,2 @@
1
- version = '4.4.0'
1
+ version = '4.4.2'
2
2
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pymodaq
3
- Version: 4.4.0
3
+ Version: 4.4.2
4
4
  Summary: Modular Data Acquisition with Python
5
5
  Project-URL: Homepage, http://pymodaq.cnrs.fr
6
6
  Project-URL: Source, https://github.com/PyMoDAQ/PyMoDAQ
@@ -8,7 +8,7 @@ pymodaq/control_modules/daq_move_ui.py,sha256=IbqNAErwXGjKUbYEptvZUz3J8MapNBFIbQ
8
8
  pymodaq/control_modules/daq_viewer.py,sha256=5CYmdWHGE7sQApeMfdWNV3zbPyoxxYtzFlQ1PaEw4fI,57883
9
9
  pymodaq/control_modules/daq_viewer_ui.py,sha256=FWP3jdIOR9vTgYqNaaodteGZ3dwgQ1GdWKrOpOAuSrs,15693
10
10
  pymodaq/control_modules/mocks.py,sha256=hh_xSWp9g1UV3NAQVD9Ft9tNWfTsSvKU0OU0trgzP2w,1956
11
- pymodaq/control_modules/move_utility_classes.py,sha256=LUO7kGb-1iQOP_6Wvp46xnx5Z9wNxUhRzOfz9cfXH-s,39664
11
+ pymodaq/control_modules/move_utility_classes.py,sha256=WwZku-xFsyqun25IG9570_OU5x1frA9rIrxVu6XJKIk,42599
12
12
  pymodaq/control_modules/utils.py,sha256=5YdSwq_lFJm7IalYWe_Hn1U4LUoUmo1gedvV9UguU0Y,20016
13
13
  pymodaq/control_modules/viewer_utility_classes.py,sha256=OHxwue1t3z2AXyeqNjnwPT2pMc8yXhnqyiWc9IdCI2c,26841
14
14
  pymodaq/examples/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -58,7 +58,7 @@ pymodaq/post_treatment/daq_measurement/daq_measurement_GUI.py,sha256=1u7hWDaiwsZ
58
58
  pymodaq/post_treatment/daq_measurement/daq_measurement_GUI.ui,sha256=PyzbCWPMkh5oIYYteZczXyWMeHKW9EJmM1QlzXhnyTk,7037
59
59
  pymodaq/post_treatment/daq_measurement/daq_measurement_main.py,sha256=CAKwcWMOD86aXB8mbdxOK7e8nZRos5d59FzDtqK1QoY,17093
60
60
  pymodaq/post_treatment/daq_measurement/process_from_QtDesigner_DAQ_Measurement_GUI.bat,sha256=e1tu2A67MS9fk3jhriF6saQgRxWIucIvNW92iWXFP6E,164
61
- pymodaq/resources/VERSION,sha256=x4JbXmXiNnoebdA-11hkfcpy5BKE5mBMlysMVDo9SRw,19
61
+ pymodaq/resources/VERSION,sha256=u7UAa-_KS1Q9ODCq7-42m4PKdNLnm3M_qQLvikeM9Hc,19
62
62
  pymodaq/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
63
63
  pymodaq/resources/config_template.toml,sha256=d3pofgIK5FxaRMELAI1qEsRcMD3GlYd87zZjDj9G9m0,3210
64
64
  pymodaq/resources/preset_default.xml,sha256=Dt8iWLwPPOPtcG00JCVP-mh-G7KC6B0YN8hd8RQdnNI,27256
@@ -438,8 +438,8 @@ pymodaq/utils/tcp_ip/__init__.py,sha256=1e_EK0AgvdoLAD_CSGGEaITZdy6OWCO7ih9IAIp7
438
438
  pymodaq/utils/tcp_ip/mysocket.py,sha256=StAWj8dzHeMnbLj68Sel81uWFy-YkKVNRnVf7gXrESI,3452
439
439
  pymodaq/utils/tcp_ip/serializer.py,sha256=htVQCE4saRBMeIcseEyxTt5G58A341m6OGkaJUA34Wk,27766
440
440
  pymodaq/utils/tcp_ip/tcp_server_client.py,sha256=xIMTNgVW_rKK0yTi4FDNFLf85-Akb27Jz2LdrvOrP68,30660
441
- pymodaq-4.4.0.dist-info/METADATA,sha256=PGjrsAiJMph8il3hZKb9aJDvUShYG5CUrEYgTPsY8is,7623
442
- pymodaq-4.4.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
443
- pymodaq-4.4.0.dist-info/entry_points.txt,sha256=RAzdYNjvUT28I2eiCKki_g2NzXq0woWxhev6lwzwRv8,348
444
- pymodaq-4.4.0.dist-info/licenses/LICENSE,sha256=VKOejxexXAe3XwfhAhcFGqeXQ12irxVHdeAojZwFEI8,1108
445
- pymodaq-4.4.0.dist-info/RECORD,,
441
+ pymodaq-4.4.2.dist-info/METADATA,sha256=wc6QZZgW3pBAs85kQQ88JdPtJ8omKojHa1RDSgtuR3s,7623
442
+ pymodaq-4.4.2.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
443
+ pymodaq-4.4.2.dist-info/entry_points.txt,sha256=RAzdYNjvUT28I2eiCKki_g2NzXq0woWxhev6lwzwRv8,348
444
+ pymodaq-4.4.2.dist-info/licenses/LICENSE,sha256=VKOejxexXAe3XwfhAhcFGqeXQ12irxVHdeAojZwFEI8,1108
445
+ pymodaq-4.4.2.dist-info/RECORD,,