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

Files changed (415) hide show
  1. pymodaq/__init__.py +57 -91
  2. pymodaq/control_modules/daq_move.py +64 -46
  3. pymodaq/control_modules/daq_move_ui.py +34 -12
  4. pymodaq/control_modules/daq_viewer.py +55 -30
  5. pymodaq/control_modules/daq_viewer_ui.py +6 -6
  6. pymodaq/control_modules/mocks.py +1 -1
  7. pymodaq/control_modules/move_utility_classes.py +51 -43
  8. pymodaq/control_modules/utils.py +43 -20
  9. pymodaq/control_modules/viewer_utility_classes.py +54 -18
  10. pymodaq/daq_utils/daq_utils.py +6 -0
  11. pymodaq/dashboard.py +639 -323
  12. pymodaq/examples/function_plotter.py +13 -12
  13. pymodaq/examples/tcp_client.py +1 -1
  14. pymodaq/extensions/__init__.py +1 -1
  15. pymodaq/extensions/bayesian/bayesian_optimisation.py +44 -32
  16. pymodaq/extensions/bayesian/utils.py +10 -10
  17. pymodaq/extensions/console.py +7 -6
  18. pymodaq/extensions/daq_logger/__init__.py +1 -0
  19. pymodaq/extensions/{daq_logger.py → daq_logger/daq_logger.py} +30 -30
  20. pymodaq/{utils/db/db_logger → extensions/daq_logger/db}/db_logger.py +16 -15
  21. pymodaq/{utils/db/db_logger → extensions/daq_logger/db}/db_logger_models.py +2 -0
  22. pymodaq/{utils/h5modules → extensions/daq_logger}/h5logging.py +7 -8
  23. pymodaq/extensions/daq_scan.py +42 -34
  24. pymodaq/extensions/daq_scan_ui.py +18 -18
  25. pymodaq/extensions/h5browser.py +2 -3
  26. pymodaq/extensions/pid/__init__.py +4 -2
  27. pymodaq/extensions/pid/daq_move_PID.py +3 -3
  28. pymodaq/extensions/pid/pid_controller.py +59 -50
  29. pymodaq/extensions/pid/utils.py +10 -5
  30. pymodaq/extensions/utils.py +33 -3
  31. pymodaq/post_treatment/load_and_plot.py +10 -7
  32. pymodaq/resources/preset_default.xml +1 -1
  33. pymodaq/updater.py +107 -0
  34. pymodaq/utils/array_manipulation.py +4 -384
  35. pymodaq/utils/calibration_camera.py +12 -9
  36. pymodaq/utils/chrono_timer.py +11 -10
  37. pymodaq/utils/config.py +3 -458
  38. pymodaq/utils/daq_utils.py +9 -715
  39. pymodaq/utils/data.py +17 -2959
  40. pymodaq/utils/enums.py +4 -74
  41. pymodaq/utils/exceptions.py +0 -4
  42. pymodaq/utils/gui_utils/__init__.py +8 -8
  43. pymodaq/utils/gui_utils/loader_utils.py +26 -1
  44. pymodaq/utils/gui_utils/utils.py +8 -162
  45. pymodaq/utils/gui_utils/widgets/lcd.py +6 -109
  46. pymodaq/utils/h5modules/__init__.py +0 -4
  47. pymodaq/utils/h5modules/module_saving.py +9 -8
  48. pymodaq/utils/leco/__init__.py +2 -2
  49. pymodaq/utils/leco/daq_move_LECODirector.py +3 -6
  50. pymodaq/utils/leco/daq_xDviewer_LECODirector.py +5 -5
  51. pymodaq/utils/leco/director_utils.py +2 -2
  52. pymodaq/utils/leco/leco_director.py +3 -3
  53. pymodaq/utils/leco/pymodaq_listener.py +4 -3
  54. pymodaq/utils/leco/utils.py +11 -9
  55. pymodaq/utils/logger.py +4 -76
  56. pymodaq/utils/managers/batchscan_manager.py +16 -19
  57. pymodaq/utils/managers/modules_manager.py +30 -17
  58. pymodaq/utils/managers/overshoot_manager.py +48 -6
  59. pymodaq/utils/managers/preset_manager.py +39 -59
  60. pymodaq/utils/managers/preset_manager_utils.py +28 -22
  61. pymodaq/utils/managers/remote_manager.py +12 -10
  62. pymodaq/utils/math_utils.py +4 -582
  63. pymodaq/utils/messenger.py +4 -64
  64. pymodaq/utils/parameter/__init__.py +6 -9
  65. pymodaq/utils/parameter/utils.py +4 -328
  66. pymodaq/utils/scanner/scan_config.py +1 -1
  67. pymodaq/utils/scanner/scan_factory.py +16 -12
  68. pymodaq/utils/{plotting → scanner}/scan_selector.py +19 -20
  69. pymodaq/utils/scanner/scanner.py +10 -8
  70. pymodaq/utils/scanner/scanners/_1d_scanners.py +8 -5
  71. pymodaq/utils/scanner/scanners/_2d_scanners.py +5 -5
  72. pymodaq/utils/scanner/scanners/sequential.py +8 -8
  73. pymodaq/utils/scanner/scanners/tabular.py +9 -9
  74. pymodaq/utils/scanner/utils.py +6 -4
  75. pymodaq/utils/svg/svg_viewer2D.py +3 -4
  76. pymodaq/utils/tcp_ip/mysocket.py +4 -110
  77. pymodaq/utils/tcp_ip/serializer.py +4 -801
  78. pymodaq/utils/tcp_ip/tcp_server_client.py +15 -13
  79. pymodaq-5.0.1.dist-info/METADATA +242 -0
  80. pymodaq-5.0.1.dist-info/RECORD +122 -0
  81. {pymodaq-4.4.7.dist-info → pymodaq-5.0.1.dist-info}/WHEEL +1 -1
  82. {pymodaq-4.4.7.dist-info → pymodaq-5.0.1.dist-info}/entry_points.txt +1 -0
  83. pymodaq/examples/custom_app.py +0 -258
  84. pymodaq/examples/custom_viewer.py +0 -112
  85. pymodaq/examples/parameter_ex.py +0 -138
  86. pymodaq/examples/preset_MockCamera.xml +0 -1
  87. pymodaq/post_treatment/daq_measurement/daq_measurement_GUI.py +0 -142
  88. pymodaq/post_treatment/daq_measurement/daq_measurement_GUI.ui +0 -232
  89. pymodaq/post_treatment/daq_measurement/daq_measurement_main.py +0 -391
  90. pymodaq/post_treatment/daq_measurement/process_from_QtDesigner_DAQ_Measurement_GUI.bat +0 -2
  91. pymodaq/post_treatment/process_to_scalar.py +0 -263
  92. pymodaq/resources/QtDesigner_Ressources/Icon_Library/1d.png +0 -0
  93. pymodaq/resources/QtDesigner_Ressources/Icon_Library/2d.png +0 -0
  94. pymodaq/resources/QtDesigner_Ressources/Icon_Library/3d.png +0 -0
  95. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Add2.png +0 -0
  96. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Add_Step.png +0 -0
  97. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Approve.png +0 -0
  98. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Approve_All.png +0 -0
  99. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Browse_Dir_Path.png +0 -0
  100. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Calculator.png +0 -0
  101. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ChnGroup.png +0 -0
  102. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ChnNum.png +0 -0
  103. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ChnText.png +0 -0
  104. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ChnTime.png +0 -0
  105. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ChnWave.png +0 -0
  106. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Close3.png +0 -0
  107. pymodaq/resources/QtDesigner_Ressources/Icon_Library/CollapseAll.png +0 -0
  108. pymodaq/resources/QtDesigner_Ressources/Icon_Library/CollapseAll_32.png +0 -0
  109. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ColorPicker.png +0 -0
  110. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Contract.png +0 -0
  111. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Create.png +0 -0
  112. pymodaq/resources/QtDesigner_Ressources/Icon_Library/DeleteLayer.png +0 -0
  113. pymodaq/resources/QtDesigner_Ressources/Icon_Library/EditOpen.png +0 -0
  114. pymodaq/resources/QtDesigner_Ressources/Icon_Library/EditRedo.png +0 -0
  115. pymodaq/resources/QtDesigner_Ressources/Icon_Library/EditUndo.png +0 -0
  116. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Ellipse.png +0 -0
  117. pymodaq/resources/QtDesigner_Ressources/Icon_Library/EllipseFilled.png +0 -0
  118. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Error.png +0 -0
  119. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ErrorMessage.png +0 -0
  120. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Error_16.png +0 -0
  121. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Exit.png +0 -0
  122. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Expand.png +0 -0
  123. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ExpandAll.png +0 -0
  124. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ExpandAll_32.png +0 -0
  125. pymodaq/resources/QtDesigner_Ressources/Icon_Library/FFT.png +0 -0
  126. pymodaq/resources/QtDesigner_Ressources/Icon_Library/HLM.ico +0 -0
  127. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Help.png +0 -0
  128. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Help_32.png +0 -0
  129. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Histogram.png +0 -0
  130. pymodaq/resources/QtDesigner_Ressources/Icon_Library/LUT_LookUpTable.png +0 -0
  131. pymodaq/resources/QtDesigner_Ressources/Icon_Library/MagnifyingGlass.png +0 -0
  132. pymodaq/resources/QtDesigner_Ressources/Icon_Library/MagnifyingGlass_24.png +0 -0
  133. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Marker.png +0 -0
  134. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Math.png +0 -0
  135. pymodaq/resources/QtDesigner_Ressources/Icon_Library/MeasurementStudio_32.png +0 -0
  136. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Move.png +0 -0
  137. pymodaq/resources/QtDesigner_Ressources/Icon_Library/MoveDown.png +0 -0
  138. pymodaq/resources/QtDesigner_Ressources/Icon_Library/MoveUp.png +0 -0
  139. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Multiply.png +0 -0
  140. pymodaq/resources/QtDesigner_Ressources/Icon_Library/NewFile.png +0 -0
  141. pymodaq/resources/QtDesigner_Ressources/Icon_Library/NewLayer.png +0 -0
  142. pymodaq/resources/QtDesigner_Ressources/Icon_Library/New_File.png +0 -0
  143. pymodaq/resources/QtDesigner_Ressources/Icon_Library/New_Folder.png +0 -0
  144. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open.png +0 -0
  145. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open_1D.png +0 -0
  146. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open_2D.png +0 -0
  147. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open_File.png +0 -0
  148. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open_File_32.png +0 -0
  149. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open_sim.png +0 -0
  150. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Options.png +0 -0
  151. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Oscilloscope.png +0 -0
  152. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Oscilloscope_16.png +0 -0
  153. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Pass.png +0 -0
  154. pymodaq/resources/QtDesigner_Ressources/Icon_Library/RGB.png +0 -0
  155. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Rectangle.png +0 -0
  156. pymodaq/resources/QtDesigner_Ressources/Icon_Library/RectangleFilled.png +0 -0
  157. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Redo.png +0 -0
  158. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Refresh.png +0 -0
  159. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Refresh2.png +0 -0
  160. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Refresh_32.png +0 -0
  161. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Region.png +0 -0
  162. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Rendezvous.png +0 -0
  163. pymodaq/resources/QtDesigner_Ressources/Icon_Library/SELECT.png +0 -0
  164. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Save.png +0 -0
  165. pymodaq/resources/QtDesigner_Ressources/Icon_Library/SaveAll.png +0 -0
  166. pymodaq/resources/QtDesigner_Ressources/Icon_Library/SaveAll_32.png +0 -0
  167. pymodaq/resources/QtDesigner_Ressources/Icon_Library/SaveAs.png +0 -0
  168. pymodaq/resources/QtDesigner_Ressources/Icon_Library/SaveAs_32.png +0 -0
  169. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Save_24.png +0 -0
  170. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Save_32.png +0 -0
  171. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Search.png +0 -0
  172. pymodaq/resources/QtDesigner_Ressources/Icon_Library/SelectPolygon.png +0 -0
  173. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Select_24.png +0 -0
  174. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Settings.png +0 -0
  175. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Snap&Save.png +0 -0
  176. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Snapshot.png +0 -0
  177. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Snapshot2.png +0 -0
  178. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Snapshot2_16.png +0 -0
  179. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Snapshot2_32.png +0 -0
  180. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Spreadsheet.png +0 -0
  181. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Statistics.png +0 -0
  182. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Statistics2.png +0 -0
  183. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Status.png +0 -0
  184. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Subtract.png +0 -0
  185. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Vision.png +0 -0
  186. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Volts.png +0 -0
  187. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Wait2.png +0 -0
  188. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Zoom_1_1.png +0 -0
  189. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Zoom_in.png +0 -0
  190. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Zoom_out.png +0 -0
  191. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Zoom_to_Selection.png +0 -0
  192. pymodaq/resources/QtDesigner_Ressources/Icon_Library/abort.png +0 -0
  193. pymodaq/resources/QtDesigner_Ressources/Icon_Library/advanced2.png +0 -0
  194. pymodaq/resources/QtDesigner_Ressources/Icon_Library/algo.png +0 -0
  195. pymodaq/resources/QtDesigner_Ressources/Icon_Library/autoscale.png +0 -0
  196. pymodaq/resources/QtDesigner_Ressources/Icon_Library/b_icon.png +0 -0
  197. pymodaq/resources/QtDesigner_Ressources/Icon_Library/back.png +0 -0
  198. pymodaq/resources/QtDesigner_Ressources/Icon_Library/bg_icon.png +0 -0
  199. pymodaq/resources/QtDesigner_Ressources/Icon_Library/camera.png +0 -0
  200. pymodaq/resources/QtDesigner_Ressources/Icon_Library/camera_snap.png +0 -0
  201. pymodaq/resources/QtDesigner_Ressources/Icon_Library/cartesian.png +0 -0
  202. pymodaq/resources/QtDesigner_Ressources/Icon_Library/clear2.png +0 -0
  203. pymodaq/resources/QtDesigner_Ressources/Icon_Library/clear_ROI.png +0 -0
  204. pymodaq/resources/QtDesigner_Ressources/Icon_Library/close2.png +0 -0
  205. pymodaq/resources/QtDesigner_Ressources/Icon_Library/cluster2.png +0 -0
  206. pymodaq/resources/QtDesigner_Ressources/Icon_Library/color.png +0 -0
  207. pymodaq/resources/QtDesigner_Ressources/Icon_Library/color2.png +0 -0
  208. pymodaq/resources/QtDesigner_Ressources/Icon_Library/continuous.png +0 -0
  209. pymodaq/resources/QtDesigner_Ressources/Icon_Library/data.png +0 -0
  210. pymodaq/resources/QtDesigner_Ressources/Icon_Library/delay.png +0 -0
  211. pymodaq/resources/QtDesigner_Ressources/Icon_Library/download.png +0 -0
  212. pymodaq/resources/QtDesigner_Ressources/Icon_Library/download2.png +0 -0
  213. pymodaq/resources/QtDesigner_Ressources/Icon_Library/error2.png +0 -0
  214. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ethernet.png +0 -0
  215. pymodaq/resources/QtDesigner_Ressources/Icon_Library/exit2.png +0 -0
  216. pymodaq/resources/QtDesigner_Ressources/Icon_Library/fan.png +0 -0
  217. pymodaq/resources/QtDesigner_Ressources/Icon_Library/filter2.png +0 -0
  218. pymodaq/resources/QtDesigner_Ressources/Icon_Library/g_icon.png +0 -0
  219. pymodaq/resources/QtDesigner_Ressources/Icon_Library/gear2.png +0 -0
  220. pymodaq/resources/QtDesigner_Ressources/Icon_Library/go_to.png +0 -0
  221. pymodaq/resources/QtDesigner_Ressources/Icon_Library/go_to_1.png +0 -0
  222. pymodaq/resources/QtDesigner_Ressources/Icon_Library/go_to_2.png +0 -0
  223. pymodaq/resources/QtDesigner_Ressources/Icon_Library/grab.png +0 -0
  224. pymodaq/resources/QtDesigner_Ressources/Icon_Library/graph.png +0 -0
  225. pymodaq/resources/QtDesigner_Ressources/Icon_Library/greenLight2.png +0 -0
  226. pymodaq/resources/QtDesigner_Ressources/Icon_Library/greenLight2_32.png +0 -0
  227. pymodaq/resources/QtDesigner_Ressources/Icon_Library/green_light.png +0 -0
  228. pymodaq/resources/QtDesigner_Ressources/Icon_Library/grey_icon.png +0 -0
  229. pymodaq/resources/QtDesigner_Ressources/Icon_Library/greyscale.png +0 -0
  230. pymodaq/resources/QtDesigner_Ressources/Icon_Library/help1.png +0 -0
  231. pymodaq/resources/QtDesigner_Ressources/Icon_Library/help1_32.png +0 -0
  232. pymodaq/resources/QtDesigner_Ressources/Icon_Library/home2.png +0 -0
  233. pymodaq/resources/QtDesigner_Ressources/Icon_Library/information2.png +0 -0
  234. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ini.png +0 -0
  235. pymodaq/resources/QtDesigner_Ressources/Icon_Library/input.png +0 -0
  236. pymodaq/resources/QtDesigner_Ressources/Icon_Library/integrator.png +0 -0
  237. pymodaq/resources/QtDesigner_Ressources/Icon_Library/joystick.png +0 -0
  238. pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_green.png +0 -0
  239. pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_green_16.png +0 -0
  240. pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_red.png +0 -0
  241. pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_red_16.png +0 -0
  242. pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_yellow.png +0 -0
  243. pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_yellow_16.png +0 -0
  244. pymodaq/resources/QtDesigner_Ressources/Icon_Library/limiter.png +0 -0
  245. pymodaq/resources/QtDesigner_Ressources/Icon_Library/load_ROI.png +0 -0
  246. pymodaq/resources/QtDesigner_Ressources/Icon_Library/meshPlot.png +0 -0
  247. pymodaq/resources/QtDesigner_Ressources/Icon_Library/meter.png +0 -0
  248. pymodaq/resources/QtDesigner_Ressources/Icon_Library/meter2.png +0 -0
  249. pymodaq/resources/QtDesigner_Ressources/Icon_Library/meter_32.png +0 -0
  250. pymodaq/resources/QtDesigner_Ressources/Icon_Library/move_contour.png +0 -0
  251. pymodaq/resources/QtDesigner_Ressources/Icon_Library/move_straight_line.png +0 -0
  252. pymodaq/resources/QtDesigner_Ressources/Icon_Library/movie.png +0 -0
  253. pymodaq/resources/QtDesigner_Ressources/Icon_Library/multi_point.png +0 -0
  254. pymodaq/resources/QtDesigner_Ressources/Icon_Library/multiplexer.png +0 -0
  255. pymodaq/resources/QtDesigner_Ressources/Icon_Library/new.png +0 -0
  256. pymodaq/resources/QtDesigner_Ressources/Icon_Library/openArrow.png +0 -0
  257. pymodaq/resources/QtDesigner_Ressources/Icon_Library/openTree.png +0 -0
  258. pymodaq/resources/QtDesigner_Ressources/Icon_Library/oscilloscope2.png +0 -0
  259. pymodaq/resources/QtDesigner_Ressources/Icon_Library/oscilloscope3.png +0 -0
  260. pymodaq/resources/QtDesigner_Ressources/Icon_Library/overlay.png +0 -0
  261. pymodaq/resources/QtDesigner_Ressources/Icon_Library/pass2.png +0 -0
  262. pymodaq/resources/QtDesigner_Ressources/Icon_Library/pass2_16.png +0 -0
  263. pymodaq/resources/QtDesigner_Ressources/Icon_Library/pass_32.png +0 -0
  264. pymodaq/resources/QtDesigner_Ressources/Icon_Library/pause.png +0 -0
  265. pymodaq/resources/QtDesigner_Ressources/Icon_Library/permute.png +0 -0
  266. pymodaq/resources/QtDesigner_Ressources/Icon_Library/phase.png +0 -0
  267. pymodaq/resources/QtDesigner_Ressources/Icon_Library/play.png +0 -0
  268. pymodaq/resources/QtDesigner_Ressources/Icon_Library/polar.png +0 -0
  269. pymodaq/resources/QtDesigner_Ressources/Icon_Library/pole_zero.png +0 -0
  270. pymodaq/resources/QtDesigner_Ressources/Icon_Library/powerMeter.png +0 -0
  271. pymodaq/resources/QtDesigner_Ressources/Icon_Library/powerSwitch.png +0 -0
  272. pymodaq/resources/QtDesigner_Ressources/Icon_Library/powerSwitch_16.png +0 -0
  273. pymodaq/resources/QtDesigner_Ressources/Icon_Library/print2.png +0 -0
  274. pymodaq/resources/QtDesigner_Ressources/Icon_Library/print2_32.png +0 -0
  275. pymodaq/resources/QtDesigner_Ressources/Icon_Library/properties.png +0 -0
  276. pymodaq/resources/QtDesigner_Ressources/Icon_Library/r_icon.png +0 -0
  277. pymodaq/resources/QtDesigner_Ressources/Icon_Library/radiocontrolbutton.png +0 -0
  278. pymodaq/resources/QtDesigner_Ressources/Icon_Library/random.png +0 -0
  279. pymodaq/resources/QtDesigner_Ressources/Icon_Library/read2.png +0 -0
  280. pymodaq/resources/QtDesigner_Ressources/Icon_Library/red_light.png +0 -0
  281. pymodaq/resources/QtDesigner_Ressources/Icon_Library/remove.png +0 -0
  282. pymodaq/resources/QtDesigner_Ressources/Icon_Library/reset.png +0 -0
  283. pymodaq/resources/QtDesigner_Ressources/Icon_Library/rgb_icon.png +0 -0
  284. pymodaq/resources/QtDesigner_Ressources/Icon_Library/robot.png +0 -0
  285. pymodaq/resources/QtDesigner_Ressources/Icon_Library/rotation2.png +0 -0
  286. pymodaq/resources/QtDesigner_Ressources/Icon_Library/run2.png +0 -0
  287. pymodaq/resources/QtDesigner_Ressources/Icon_Library/run_all.png +0 -0
  288. pymodaq/resources/QtDesigner_Ressources/Icon_Library/saturation.png +0 -0
  289. pymodaq/resources/QtDesigner_Ressources/Icon_Library/saveTree.png +0 -0
  290. pymodaq/resources/QtDesigner_Ressources/Icon_Library/save_ROI.png +0 -0
  291. pymodaq/resources/QtDesigner_Ressources/Icon_Library/scale_horizontally.png +0 -0
  292. pymodaq/resources/QtDesigner_Ressources/Icon_Library/scale_vertically.png +0 -0
  293. pymodaq/resources/QtDesigner_Ressources/Icon_Library/search2.png +0 -0
  294. pymodaq/resources/QtDesigner_Ressources/Icon_Library/select2.png +0 -0
  295. pymodaq/resources/QtDesigner_Ressources/Icon_Library/select_all.png +0 -0
  296. pymodaq/resources/QtDesigner_Ressources/Icon_Library/select_all2.png +0 -0
  297. pymodaq/resources/QtDesigner_Ressources/Icon_Library/select_none.png +0 -0
  298. pymodaq/resources/QtDesigner_Ressources/Icon_Library/sequence.png +0 -0
  299. pymodaq/resources/QtDesigner_Ressources/Icon_Library/sequence2.png +0 -0
  300. pymodaq/resources/QtDesigner_Ressources/Icon_Library/snap.png +0 -0
  301. pymodaq/resources/QtDesigner_Ressources/Icon_Library/sort_ascend.png +0 -0
  302. pymodaq/resources/QtDesigner_Ressources/Icon_Library/spectrumAnalyzer.png +0 -0
  303. pymodaq/resources/QtDesigner_Ressources/Icon_Library/start.png +0 -0
  304. pymodaq/resources/QtDesigner_Ressources/Icon_Library/status_cancelled.png +0 -0
  305. pymodaq/resources/QtDesigner_Ressources/Icon_Library/stop.png +0 -0
  306. pymodaq/resources/QtDesigner_Ressources/Icon_Library/stop2.png +0 -0
  307. pymodaq/resources/QtDesigner_Ressources/Icon_Library/stop3.png +0 -0
  308. pymodaq/resources/QtDesigner_Ressources/Icon_Library/stop_all.png +0 -0
  309. pymodaq/resources/QtDesigner_Ressources/Icon_Library/sum.png +0 -0
  310. pymodaq/resources/QtDesigner_Ressources/Icon_Library/surfacePlot.png +0 -0
  311. pymodaq/resources/QtDesigner_Ressources/Icon_Library/target.png +0 -0
  312. pymodaq/resources/QtDesigner_Ressources/Icon_Library/tree.png +0 -0
  313. pymodaq/resources/QtDesigner_Ressources/Icon_Library/updateTree.png +0 -0
  314. pymodaq/resources/QtDesigner_Ressources/Icon_Library/utility2.png +0 -0
  315. pymodaq/resources/QtDesigner_Ressources/Icon_Library/utility_small.png +0 -0
  316. pymodaq/resources/QtDesigner_Ressources/Icon_Library/vector.png +0 -0
  317. pymodaq/resources/QtDesigner_Ressources/Icon_Library/verify.png +0 -0
  318. pymodaq/resources/QtDesigner_Ressources/Icon_Library/video.png +0 -0
  319. pymodaq/resources/QtDesigner_Ressources/Icon_Library/wait.png +0 -0
  320. pymodaq/resources/QtDesigner_Ressources/Icon_Library/waterfallPlot.png +0 -0
  321. pymodaq/resources/QtDesigner_Ressources/Icon_Library/watershed.png +0 -0
  322. pymodaq/resources/QtDesigner_Ressources/Icon_Library/yellow_light.png +0 -0
  323. pymodaq/resources/QtDesigner_Ressources/Icon_Library/zip_file.png +0 -0
  324. pymodaq/resources/QtDesigner_Ressources/Icon_Library/zoomAuto.png +0 -0
  325. pymodaq/resources/QtDesigner_Ressources/Icon_Library/zoomReset.png +0 -0
  326. pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources.bat +0 -2
  327. pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources.qrc +0 -238
  328. pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources_rc.py +0 -127453
  329. pymodaq/resources/QtDesigner_Ressources/__init__.py +0 -0
  330. pymodaq/resources/QtDesigner_Ressources/credit.rst +0 -7
  331. pymodaq/resources/QtDesigner_Ressources/icons.svg +0 -142
  332. pymodaq/resources/VERSION +0 -2
  333. pymodaq/resources/config_template.toml +0 -96
  334. pymodaq/resources/triangulation_data.npy +0 -0
  335. pymodaq/utils/abstract/__init__.py +0 -48
  336. pymodaq/utils/db/__init__.py +0 -0
  337. pymodaq/utils/db/db_logger/__init__.py +0 -0
  338. pymodaq/utils/factory.py +0 -82
  339. pymodaq/utils/gui_utils/custom_app.py +0 -133
  340. pymodaq/utils/gui_utils/dock.py +0 -107
  341. pymodaq/utils/gui_utils/file_io.py +0 -94
  342. pymodaq/utils/gui_utils/layout.py +0 -34
  343. pymodaq/utils/gui_utils/list_picker.py +0 -38
  344. pymodaq/utils/gui_utils/widgets/__init__.py +0 -5
  345. pymodaq/utils/gui_utils/widgets/label.py +0 -24
  346. pymodaq/utils/gui_utils/widgets/push.py +0 -149
  347. pymodaq/utils/gui_utils/widgets/qled.py +0 -62
  348. pymodaq/utils/gui_utils/widgets/spinbox.py +0 -24
  349. pymodaq/utils/gui_utils/widgets/table.py +0 -263
  350. pymodaq/utils/gui_utils/widgets/tree_layout.py +0 -188
  351. pymodaq/utils/gui_utils/widgets/tree_toml.py +0 -110
  352. pymodaq/utils/h5modules/backends.py +0 -1022
  353. pymodaq/utils/h5modules/browsing.py +0 -627
  354. pymodaq/utils/h5modules/data_saving.py +0 -1107
  355. pymodaq/utils/h5modules/exporter.py +0 -119
  356. pymodaq/utils/h5modules/exporters/__init__.py +0 -0
  357. pymodaq/utils/h5modules/exporters/base.py +0 -111
  358. pymodaq/utils/h5modules/exporters/flimj.py +0 -63
  359. pymodaq/utils/h5modules/exporters/hyperspy.py +0 -143
  360. pymodaq/utils/h5modules/saving.py +0 -866
  361. pymodaq/utils/h5modules/utils.py +0 -115
  362. pymodaq/utils/managers/action_manager.py +0 -489
  363. pymodaq/utils/managers/parameter_manager.py +0 -279
  364. pymodaq/utils/managers/roi_manager.py +0 -740
  365. pymodaq/utils/parameter/ioxml.py +0 -545
  366. pymodaq/utils/parameter/pymodaq_ptypes/__init__.py +0 -38
  367. pymodaq/utils/parameter/pymodaq_ptypes/bool.py +0 -31
  368. pymodaq/utils/parameter/pymodaq_ptypes/date.py +0 -126
  369. pymodaq/utils/parameter/pymodaq_ptypes/filedir.py +0 -143
  370. pymodaq/utils/parameter/pymodaq_ptypes/itemselect.py +0 -265
  371. pymodaq/utils/parameter/pymodaq_ptypes/led.py +0 -44
  372. pymodaq/utils/parameter/pymodaq_ptypes/list.py +0 -150
  373. pymodaq/utils/parameter/pymodaq_ptypes/numeric.py +0 -18
  374. pymodaq/utils/parameter/pymodaq_ptypes/pixmap.py +0 -175
  375. pymodaq/utils/parameter/pymodaq_ptypes/slide.py +0 -166
  376. pymodaq/utils/parameter/pymodaq_ptypes/table.py +0 -135
  377. pymodaq/utils/parameter/pymodaq_ptypes/tableview.py +0 -149
  378. pymodaq/utils/parameter/pymodaq_ptypes/text.py +0 -142
  379. pymodaq/utils/plotting/__init__.py +0 -0
  380. pymodaq/utils/plotting/data_viewers/__init__.py +0 -10
  381. pymodaq/utils/plotting/data_viewers/base.py +0 -286
  382. pymodaq/utils/plotting/data_viewers/viewer.py +0 -275
  383. pymodaq/utils/plotting/data_viewers/viewer0D.py +0 -298
  384. pymodaq/utils/plotting/data_viewers/viewer1D.py +0 -826
  385. pymodaq/utils/plotting/data_viewers/viewer1Dbasic.py +0 -231
  386. pymodaq/utils/plotting/data_viewers/viewer2D.py +0 -1118
  387. pymodaq/utils/plotting/data_viewers/viewer2D_basic.py +0 -146
  388. pymodaq/utils/plotting/data_viewers/viewerND.py +0 -800
  389. pymodaq/utils/plotting/gant_chart.py +0 -123
  390. pymodaq/utils/plotting/image_viewer.py +0 -97
  391. pymodaq/utils/plotting/items/__init__.py +0 -0
  392. pymodaq/utils/plotting/items/axis_scaled.py +0 -93
  393. pymodaq/utils/plotting/items/crosshair.py +0 -94
  394. pymodaq/utils/plotting/items/image.py +0 -388
  395. pymodaq/utils/plotting/navigator.py +0 -353
  396. pymodaq/utils/plotting/plotter/plotter.py +0 -94
  397. pymodaq/utils/plotting/plotter/plotters/__init__.py +0 -0
  398. pymodaq/utils/plotting/plotter/plotters/matplotlib_plotters.py +0 -134
  399. pymodaq/utils/plotting/plotter/plotters/qt_plotters.py +0 -78
  400. pymodaq/utils/plotting/utils/__init__.py +0 -0
  401. pymodaq/utils/plotting/utils/axes_viewer.py +0 -88
  402. pymodaq/utils/plotting/utils/filter.py +0 -585
  403. pymodaq/utils/plotting/utils/lineout.py +0 -226
  404. pymodaq/utils/plotting/utils/plot_utils.py +0 -579
  405. pymodaq/utils/plotting/utils/signalND.py +0 -1347
  406. pymodaq/utils/plotting/widgets.py +0 -76
  407. pymodaq/utils/qvariant.py +0 -12
  408. pymodaq/utils/slicing.py +0 -63
  409. pymodaq/utils/units.py +0 -216
  410. pymodaq-4.4.7.dist-info/METADATA +0 -163
  411. pymodaq-4.4.7.dist-info/RECORD +0 -446
  412. /pymodaq/{post_treatment/daq_analysis → daq_utils}/__init__.py +0 -0
  413. /pymodaq/{utils/abstract/logger.py → extensions/daq_logger/abstract.py} +0 -0
  414. /pymodaq/{post_treatment/daq_measurement → extensions/daq_logger/db}/__init__.py +0 -0
  415. {pymodaq-4.4.7.dist-info → pymodaq-5.0.1.dist-info}/licenses/LICENSE +0 -0
@@ -4,807 +4,10 @@ Created the 20/10/2023
4
4
 
5
5
  @author: Sebastien Weber
6
6
  """
7
- from base64 import b64encode, b64decode
8
- from enum import Enum
9
- import numbers
10
- from typing import Optional, Tuple, List, Union, TYPE_CHECKING
11
7
 
8
+ from pymodaq_utils.utils import deprecation_msg
12
9
 
13
- import numpy as np
14
- from pymodaq.utils import data as data_mod
15
- from pymodaq.utils.data import DataWithAxes, DataToExport, Axis, DwaType
16
- from pymodaq.utils.parameter import Parameter, utils as putils, ioxml
10
+ from pymodaq_data.serialize.serializer_legacy import Serializer, DeSerializer, SocketString, Socket
17
11
 
18
-
19
- if TYPE_CHECKING:
20
- from pymodaq.utils.tcp_ip.mysocket import Socket
21
-
22
-
23
- SERIALIZABLE = Union[
24
- # native
25
- bool,
26
- bytes,
27
- str,
28
- complex, # float and int are subtypes for type hinting
29
- float,
30
- int,
31
- list,
32
- # numpy
33
- np.ndarray,
34
- # pymodaq
35
- Axis,
36
- DataWithAxes,
37
- DataToExport,
38
- putils.ParameterWithPath,
39
- ]
40
-
41
-
42
- class SerializableTypes(Enum):
43
- """Type names of serializable types"""
44
- BOOL = "bool"
45
- BYTES = "bytes"
46
- STRING = "string"
47
- SCALAR = "scalar"
48
- LIST = "list"
49
- ARRAY = "array"
50
- AXIS = "axis"
51
- DATA_WITH_AXES = "dwa"
52
- DATA_TO_EXPORT = "dte"
53
- PARAMETER = "parameter"
54
-
55
-
56
- class SocketString:
57
- """Mimic the Socket object but actually using a bytes string not a socket connection
58
-
59
- Implements a minimal interface of two methods
60
-
61
- Parameters
62
- ----------
63
- bytes_string: bytes
64
-
65
- See Also
66
- --------
67
- :class:`~pymodaq.utils.tcp_ip.mysocket.Socket`
68
- """
69
- def __init__(self, bytes_string: bytes):
70
- self._bytes_string = bytes_string
71
-
72
- def check_received_length(self, length: int) -> bytes:
73
- """
74
- Make sure all bytes (length) that should be received are received through the socket.
75
-
76
- Here just read the content of the underlying bytes string
77
-
78
- Parameters
79
- ----------
80
- length: int
81
- The number of bytes to be read from the socket
82
-
83
- Returns
84
- -------
85
- bytes
86
- """
87
- data = self._bytes_string[0:length]
88
- self._bytes_string = self._bytes_string[length:]
89
- return data
90
-
91
- def get_first_nbytes(self, length: int) -> bytes:
92
- """ Read the first N bytes from the socket
93
-
94
- Parameters
95
- ----------
96
- length: int
97
- The number of bytes to be read from the socket
98
-
99
- Returns
100
- -------
101
- bytes
102
- the read bytes string
103
- """
104
- return self.check_received_length(length)
105
-
106
-
107
- class Serializer:
108
- """Used to Serialize to bytes python objects, numpy arrays and PyMoDAQ DataWithAxes and
109
- DataToExport objects"""
110
-
111
- def __init__(self, obj: Optional[SERIALIZABLE] = None) -> None:
112
- self._bytes_string = b''
113
- self._obj = obj
114
-
115
- def to_bytes(self):
116
- """ Generic method to obtain the bytes string from various objects
117
-
118
- Compatible objects are:
119
-
120
- * :class:`bytes`
121
- * :class:`numbers.Number`
122
- * :class:`str`
123
- * :class:`numpy.ndarray`
124
- * :class:`~pymodaq.utils.data.Axis`
125
- * :class:`~pymodaq.utils.data.DataWithAxes` and sub-flavours
126
- * :class:`~pymodaq.utils.data.DataToExport`
127
- * :class:`list` of any objects above
128
-
129
- """
130
- if isinstance(self._obj, bytes):
131
- return self.bytes_serialization(self._obj)
132
- elif isinstance(self._obj, numbers.Number):
133
- return self.scalar_serialization(self._obj)
134
- elif isinstance(self._obj, str):
135
- return self.string_serialization(self._obj)
136
- elif isinstance(self._obj, np.ndarray):
137
- return self.ndarray_serialization(self._obj)
138
- elif isinstance(self._obj, Axis):
139
- return self.axis_serialization(self._obj)
140
- elif self._obj.__class__.__name__ in DwaType.names():
141
- return self.dwa_serialization(self._obj)
142
- elif isinstance(self._obj, DataToExport):
143
- return self.dte_serialization(self._obj)
144
- elif isinstance(self._obj, list):
145
- return self.list_serialization(self._obj)
146
- elif isinstance(self._obj, bool):
147
- return self.scalar_serialization(int(self._obj))
148
- raise ValueError
149
-
150
- def to_b64_string(self) -> str:
151
- b = self.to_bytes()
152
- return b64encode(b).decode()
153
-
154
- @staticmethod
155
- def int_to_bytes(an_integer: int) -> bytes:
156
- """Convert an unsigned integer into a byte array of length 4 in big endian
157
-
158
- Parameters
159
- ----------
160
- an_integer: int
161
-
162
- Returns
163
- -------
164
- bytearray
165
- """
166
- if not isinstance(an_integer, int):
167
- raise TypeError(f'{an_integer} should be an integer, not a {type(an_integer)}')
168
- elif an_integer < 0:
169
- raise ValueError('Can only serialize unsigned integer using this method')
170
- return an_integer.to_bytes(4, 'big')
171
-
172
- @staticmethod
173
- def str_to_bytes(message: str) -> bytes:
174
- if not isinstance(message, str):
175
- raise TypeError('Can only serialize str object using this method')
176
- return message.encode()
177
-
178
- @classmethod
179
- def str_len_to_bytes(cls, message: Union[str, bytes]) -> Tuple[bytes, bytes]:
180
- """ Convert a string and its length to two bytes
181
- Parameters
182
- ----------
183
- message: str
184
- the message to convert
185
-
186
- Returns
187
- -------
188
- bytes: message converted as a byte array
189
- bytes: length of the message byte array, itself as a byte array of length 4
190
- """
191
-
192
- if not isinstance(message, str) and not isinstance(message, bytes):
193
- message = str(message)
194
- if not isinstance(message, bytes):
195
- message = cls.str_to_bytes(message)
196
- return message, cls.int_to_bytes(len(message))
197
-
198
- def _int_serialization(self, int_obj: int) -> bytes:
199
- """Serialize an unsigned integer used for getting the length of messages internally, for outside integer
200
- serialization or deserialization use scalar_serialization"""
201
- int_bytes = self.int_to_bytes(int_obj)
202
- bytes_string = int_bytes
203
- self._bytes_string += bytes_string
204
- return bytes_string
205
-
206
- def bytes_serialization(self, bytes_string_in: bytes) -> bytes:
207
- bytes_string = b''
208
- bytes_string += self.int_to_bytes(len(bytes_string_in))
209
- bytes_string += bytes_string_in
210
- return bytes_string
211
-
212
- def string_serialization(self, string: str) -> bytes:
213
- """ Convert a string into a bytes message together with the info to convert it back
214
-
215
- Parameters
216
- ----------
217
- string: str
218
-
219
- Returns
220
- -------
221
- bytes: the total bytes message to serialize the string
222
- """
223
- bytes_string = b''
224
- cmd_bytes, cmd_length_bytes = self.str_len_to_bytes(string)
225
- bytes_string += cmd_length_bytes
226
- bytes_string += cmd_bytes
227
- self._bytes_string += bytes_string
228
- return bytes_string
229
-
230
- def scalar_serialization(self, scalar: complex) -> bytes:
231
- """ Convert a scalar into a bytes message together with the info to convert it back
232
-
233
- Parameters
234
- ----------
235
- scalar: A python number (complex or subtypes like float and int)
236
-
237
- Returns
238
- -------
239
- bytes: the total bytes message to serialize the scalar
240
- """
241
- if not isinstance(scalar, numbers.Number):
242
- # type hint is complex, instance comparison Number
243
- raise TypeError(f'{scalar} should be an integer or a float, not a {type(scalar)}')
244
- scalar_array = np.array([scalar])
245
- data_type = scalar_array.dtype.descr[0][1]
246
- data_bytes = scalar_array.tobytes()
247
-
248
- bytes_string = b''
249
- bytes_string += self.string_serialization(data_type)
250
- bytes_string += self._int_serialization(len(data_bytes))
251
- bytes_string += data_bytes
252
- self._bytes_string += bytes_string
253
- return bytes_string
254
-
255
- def ndarray_serialization(self, array: np.ndarray) -> bytes:
256
- """ Convert a ndarray into a bytes message together with the info to convert it back
257
-
258
- Parameters
259
- ----------
260
- array: np.ndarray
261
-
262
- Returns
263
- -------
264
- bytes: the total bytes message to serialize the scalar
265
-
266
- Notes
267
- -----
268
-
269
- The bytes sequence is constructed as:
270
-
271
- * get data type as a string
272
- * reshape array as 1D array and get the array dimensionality (len of array's shape)
273
- * convert Data array as bytes
274
- * serialize data type
275
- * serialize data length
276
- * serialize data shape length
277
- * serialize all values of the shape as integers converted to bytes
278
- * serialize array as bytes
279
- """
280
- if not isinstance(array, np.ndarray):
281
- raise TypeError(f'{array} should be an numpy array, not a {type(array)}')
282
- array_type = array.dtype.descr[0][1]
283
- array_shape = array.shape
284
-
285
- array = array.reshape(array.size)
286
- array_bytes = array.tobytes()
287
- bytes_string = b''
288
- bytes_string += self.string_serialization(array_type)
289
- bytes_string += self._int_serialization(len(array_bytes))
290
- bytes_string += self._int_serialization(len(array_shape))
291
- for shape_elt in array_shape:
292
- bytes_string += self._int_serialization(shape_elt)
293
- bytes_string += array_bytes
294
- self._bytes_string += bytes_string
295
- return bytes_string
296
-
297
- def object_type_serialization(self, obj: Union[Axis, DataToExport, DataWithAxes]) -> bytes:
298
- """ Convert an object type into a bytes message as a string together with the info to
299
- convert it back
300
-
301
- Applies to Data object from the pymodaq.utils.data module
302
- """
303
- return self.string_serialization(obj.__class__.__name__)
304
-
305
- def axis_serialization(self, axis: Axis) -> bytes:
306
- """ Convert an Axis object into a bytes message together with the info to convert it back
307
-
308
- Parameters
309
- ----------
310
- axis: Axis
311
-
312
- Returns
313
- -------
314
- bytes: the total bytes message to serialize the Axis
315
-
316
- Notes
317
- -----
318
-
319
- The bytes sequence is constructed as:
320
-
321
- * serialize the type: 'Axis'
322
- * serialize the axis label
323
- * serialize the axis units
324
- * serialize the axis array
325
- * serialize the axis
326
- * serialize the axis spread_order
327
- """
328
- if not isinstance(axis, Axis):
329
- raise TypeError(f'{axis} should be a list, not a {type(axis)}')
330
-
331
- bytes_string = b''
332
- bytes_string += self.object_type_serialization(axis)
333
- bytes_string += self.string_serialization(axis.label)
334
- bytes_string += self.string_serialization(axis.units)
335
- bytes_string += self.ndarray_serialization(axis.get_data())
336
- bytes_string += self.scalar_serialization(axis.index)
337
- bytes_string += self.scalar_serialization(axis.spread_order)
338
- self._bytes_string += bytes_string
339
- return bytes_string
340
-
341
- def list_serialization(self, list_object: List) -> bytes:
342
- """ Convert a list of objects into a bytes message together with the info to convert it back
343
-
344
- Parameters
345
- ----------
346
- list_object: list
347
- the list could contains either scalars, strings or ndarrays or Axis objects or DataWithAxis objects
348
- module
349
-
350
- Returns
351
- -------
352
- bytes: the total bytes message to serialize the list of objects
353
-
354
- Notes
355
- -----
356
-
357
- The bytes sequence is constructed as:
358
- * the length of the list
359
-
360
- Then for each object:
361
-
362
- * get data type as a string
363
- * use the serialization method adapted to each object in the list
364
- """
365
- if not isinstance(list_object, list):
366
- raise TypeError(f'{list_object} should be a list, not a {type(list_object)}')
367
-
368
- bytes_string = b''
369
-
370
- bytes_string += self._int_serialization(len(list_object))
371
- for obj in list_object:
372
- bytes_string += self.type_and_object_serialization(obj)
373
- self._bytes_string += bytes_string
374
- return bytes_string
375
-
376
- def type_and_object_serialization(self, obj: Optional[SERIALIZABLE] = None) -> bytes:
377
- """Serialize an object with its type, such that it can be retrieved by
378
- `DeSerializer.type_and_object_deserialization`.
379
- """
380
-
381
- if obj is None and self._obj is not None:
382
- obj = self._obj
383
-
384
- bytes_string = b''
385
- if isinstance(obj, DataWithAxes):
386
- bytes_string += self.string_serialization(SerializableTypes.DATA_WITH_AXES.value)
387
- bytes_string += self.dwa_serialization(obj)
388
-
389
- elif isinstance(obj, Axis):
390
- bytes_string += self.string_serialization(SerializableTypes.AXIS.value)
391
- bytes_string += self.axis_serialization(obj)
392
-
393
- elif isinstance(obj, np.ndarray):
394
- bytes_string += self.string_serialization(SerializableTypes.ARRAY.value)
395
- bytes_string += self.ndarray_serialization(obj)
396
-
397
- elif isinstance(obj, bytes):
398
- bytes_string += self.string_serialization(SerializableTypes.BYTES.value)
399
- bytes_string += self.bytes_serialization(obj)
400
-
401
- elif isinstance(obj, str):
402
- bytes_string += self.string_serialization(SerializableTypes.STRING.value)
403
- bytes_string += self.string_serialization(obj)
404
-
405
- elif isinstance(obj, bool):
406
- bytes_string += self.string_serialization(SerializableTypes.BOOL.value)
407
- bytes_string += self.scalar_serialization(obj)
408
-
409
- elif isinstance(obj, numbers.Number):
410
- bytes_string += self.string_serialization(SerializableTypes.SCALAR.value)
411
- bytes_string += self.scalar_serialization(obj)
412
-
413
- elif isinstance(obj, list):
414
- bytes_string += self.string_serialization(SerializableTypes.LIST.value)
415
- bytes_string += self.list_serialization(obj)
416
-
417
- elif isinstance(obj, putils.ParameterWithPath):
418
- path = obj.path
419
- param_as_xml = ioxml.parameter_to_xml_string(obj.parameter)
420
- bytes_string += self.string_serialization(SerializableTypes.PARAMETER.value)
421
- bytes_string += self.list_serialization(path)
422
- bytes_string += self.bytes_serialization(param_as_xml)
423
-
424
- elif isinstance(obj, DataToExport):
425
- bytes_string += self.string_serialization(SerializableTypes.DATA_TO_EXPORT.value)
426
- bytes_string += self.dte_serialization(obj)
427
-
428
- else:
429
- raise TypeError(
430
- f'the element {obj} type cannot be serialized into bytes, only numpy arrays'
431
- f', strings, or scalars (int or float)')
432
-
433
- return bytes_string
434
-
435
- def dwa_serialization(self, dwa: DataWithAxes) -> bytes:
436
- """ Convert a DataWithAxes into a bytes string
437
-
438
- Parameters
439
- ----------
440
- dwa: DataWithAxes
441
-
442
- Returns
443
- -------
444
- bytes: the total bytes message to serialize the DataWithAxes
445
-
446
- Notes
447
- -----
448
- The bytes sequence is constructed as:
449
-
450
- * serialize the string type: 'DataWithAxes'
451
- * serialize the timestamp: float
452
- * serialize the name
453
- * serialize the units
454
- * serialize the source enum as a string
455
- * serialize the dim enum as a string
456
- * serialize the distribution enum as a string
457
- * serialize the list of numpy arrays
458
- * serialize the list of labels
459
- * serialize the origin
460
- * serialize the nav_index tuple as a list of int
461
- * serialize the list of axis
462
- * serialize the errors attributes (None or list(np.ndarray))
463
- * serialize the list of names of extra attributes
464
- * serialize the extra attributes
465
- """
466
- if not isinstance(dwa, DataWithAxes):
467
- raise TypeError(f'{dwa} should be a DataWithAxes, not a {type(dwa)}')
468
-
469
- bytes_string = b''
470
- bytes_string += self.object_type_serialization(dwa)
471
- bytes_string += self.scalar_serialization(dwa.timestamp)
472
- bytes_string += self.string_serialization(dwa.name)
473
- bytes_string += self.string_serialization(dwa.units)
474
- bytes_string += self.string_serialization(dwa.source.name)
475
- bytes_string += self.string_serialization(dwa.dim.name)
476
- bytes_string += self.string_serialization(dwa.distribution.name)
477
- bytes_string += self.list_serialization(dwa.data)
478
- bytes_string += self.list_serialization(dwa.labels)
479
- bytes_string += self.string_serialization(dwa.origin)
480
- bytes_string += self.list_serialization(list(dwa.nav_indexes))
481
- bytes_string += self.list_serialization(dwa.axes)
482
- if dwa.errors is None:
483
- errors = [] # have to use this extra attribute as if I force dwa.errors = [], it will be
484
- #internally modified as None again
485
- else:
486
- errors = dwa.errors
487
- bytes_string += self.list_serialization(errors)
488
- bytes_string += self.list_serialization(dwa.extra_attributes)
489
- for attribute in dwa.extra_attributes:
490
- bytes_string += self.type_and_object_serialization(getattr(dwa, attribute))
491
- self._bytes_string += bytes_string
492
- return bytes_string
493
-
494
- def dte_serialization(self, dte: DataToExport) -> bytes:
495
- """ Convert a DataToExport into a bytes string
496
-
497
- Parameters
498
- ----------
499
- dte: DataToExport
500
-
501
- Returns
502
- -------
503
- bytes: the total bytes message to serialize the DataToExport
504
-
505
- Notes
506
- -----
507
- The bytes sequence is constructed as:
508
-
509
- * serialize the string type: 'DataToExport'
510
- * serialize the timestamp: float
511
- * serialize the name
512
- * serialize the list of DataWithAxes
513
- """
514
- if not isinstance(dte, DataToExport):
515
- raise TypeError(f'{dte} should be a DataToExport, not a {type(dte)}')
516
-
517
- bytes_string = b''
518
- bytes_string += self.object_type_serialization(dte)
519
- bytes_string += self.scalar_serialization(dte.timestamp)
520
- bytes_string += self.string_serialization(dte.name)
521
- bytes_string += self.list_serialization(dte.data)
522
- self._bytes_string += bytes_string
523
- return bytes_string
524
-
525
-
526
- class DeSerializer:
527
- """Used to DeSerialize bytes to python objects, numpy arrays and PyMoDAQ Axis, DataWithAxes and DataToExport
528
- objects
529
-
530
- Parameters
531
- ----------
532
- bytes_string: bytes or Socket
533
- the bytes string to deserialize into an object: int, float, string, arrays, list, Axis, DataWithAxes...
534
- Could also be a Socket object reading bytes from the network having a `get_first_nbytes` method
535
-
536
- See Also
537
- --------
538
- :py:class:`~pymodaq.utils.tcp_ip.serializer.SocketString`
539
- :py:class:`~pymodaq.utils.tcp_ip.mysocket.Socket`
540
- """
541
-
542
- def __init__(self, bytes_string: Union[bytes, 'Socket'] = None) -> None:
543
- if isinstance(bytes_string, bytes):
544
- bytes_string = SocketString(bytes_string)
545
- self._bytes_string = bytes_string
546
-
547
- @classmethod
548
- def from_b64_string(cls, b64_string: Union[bytes, str]) -> "DeSerializer":
549
- return cls(b64decode(b64_string))
550
-
551
- @staticmethod
552
- def bytes_to_string(message: bytes) -> str:
553
- return message.decode()
554
-
555
- @staticmethod
556
- def bytes_to_int(bytes_string: bytes) -> int:
557
- """Convert a bytes of length 4 into an integer"""
558
- if not isinstance(bytes_string, bytes):
559
- raise TypeError(f'{bytes_string} should be an bytes string, not a {type(bytes_string)}')
560
- assert len(bytes_string) == 4
561
- return int.from_bytes(bytes_string, 'big')
562
-
563
- @staticmethod
564
- def bytes_to_scalar(data: bytes, dtype: np.dtype) -> complex:
565
- """Convert bytes to a scalar given a certain numpy dtype
566
-
567
- Parameters
568
- ----------
569
- data: bytes
570
- dtype:np.dtype
571
-
572
- Returns
573
- -------
574
- numbers.Number
575
- """
576
- return np.frombuffer(data, dtype=dtype)[0]
577
-
578
- @staticmethod
579
- def bytes_to_nd_array(data: bytes, dtype: np.dtype, shape: Tuple[int]) -> np.ndarray:
580
- """Convert bytes to a ndarray given a certain numpy dtype and shape
581
-
582
- Parameters
583
- ----------
584
- data: bytes
585
- dtype: np.dtype
586
- shape: tuple of int
587
-
588
- Returns
589
- -------
590
- np.ndarray
591
- """
592
- array = np.frombuffer(data, dtype=dtype)
593
- array = array.reshape(tuple(shape))
594
- array = np.atleast_1d(array) # remove singleton dimensions but keeping ndarrays
595
- return array
596
-
597
- def _int_deserialization(self) -> int:
598
- """Convert the fourth first bytes into an unsigned integer to be used internally. For integer serialization
599
- use scal_serialization"""
600
- int_obj = self.bytes_to_int(self._bytes_string.get_first_nbytes(4))
601
- return int_obj
602
-
603
- def bytes_deserialization(self) -> bytes:
604
- bstring_len = self._int_deserialization()
605
- bstr = self._bytes_string.get_first_nbytes(bstring_len)
606
- return bstr
607
-
608
- def string_deserialization(self) -> str:
609
- """Convert bytes into a str object
610
-
611
- Convert first the fourth first bytes into an int encoding the length of the string to decode
612
-
613
- Returns
614
- -------
615
- str: the decoded string
616
- """
617
- string_len = self._int_deserialization()
618
- str_obj = self._bytes_string.get_first_nbytes(string_len).decode()
619
- return str_obj
620
-
621
- def scalar_deserialization(self) -> complex:
622
- """Convert bytes into a python number object
623
-
624
- Get first the data type from a string deserialization, then the data length and finally convert this
625
- length of bytes into a number (float, int)
626
-
627
- Returns
628
- -------
629
- numbers.Number: the decoded number
630
- """
631
- data_type = self.string_deserialization()
632
- data_len = self._int_deserialization()
633
- number = np.frombuffer(self._bytes_string.get_first_nbytes(data_len), dtype=data_type)[0]
634
- if 'f' in data_type:
635
- number = float(number) # because one get numpy float type
636
- elif 'i' in data_type:
637
- number = int(number) # because one get numpy int type
638
- elif 'c' in data_type:
639
- number = complex(number) # because one get numpy complex type
640
- return number
641
-
642
- def boolean_deserialization(self) -> bool:
643
- """Convert bytes into a boolean object
644
-
645
- Get first the data type from a string deserialization, then the data length and finally
646
- convert this length of bytes into a number (float, int) and cast it to a bool
647
-
648
- Returns
649
- -------
650
- bool: the decoded boolean
651
- """
652
- number = self.scalar_deserialization()
653
- return bool(number)
654
-
655
- def ndarray_deserialization(self) -> np.ndarray:
656
- """Convert bytes into a numpy ndarray object
657
-
658
- Convert the first bytes into a ndarray reading first information about the array's data
659
-
660
- Returns
661
- -------
662
- ndarray: the decoded numpy array
663
- """
664
- ndarray_type = self.string_deserialization()
665
- ndarray_len = self._int_deserialization()
666
- shape_len = self._int_deserialization()
667
- shape = []
668
- for ind in range(shape_len):
669
- shape_elt = self._int_deserialization()
670
- shape.append(shape_elt)
671
-
672
- ndarray = np.frombuffer(self._bytes_string.get_first_nbytes(ndarray_len), dtype=ndarray_type)
673
- ndarray = ndarray.reshape(tuple(shape))
674
- ndarray = np.atleast_1d(ndarray) # remove singleton dimensions
675
- return ndarray
676
-
677
- def type_and_object_deserialization(self) -> SERIALIZABLE:
678
- """ Deserialize specific objects from their binary representation (inverse of `Serializer.type_and_object_serialization`).
679
-
680
- See Also
681
- --------
682
- Serializer.dwa_serialization, Serializer.dte_serialization
683
-
684
- """
685
- obj_type = self.string_deserialization()
686
- elt = None
687
- if obj_type == SerializableTypes.SCALAR.value:
688
- elt = self.scalar_deserialization()
689
- elif obj_type == SerializableTypes.STRING.value:
690
- elt = self.string_deserialization()
691
- elif obj_type == SerializableTypes.BYTES.value:
692
- elt = self.bytes_deserialization()
693
- elif obj_type == SerializableTypes.ARRAY.value:
694
- elt = self.ndarray_deserialization()
695
- elif obj_type == SerializableTypes.DATA_WITH_AXES.value:
696
- elt = self.dwa_deserialization()
697
- elif obj_type == SerializableTypes.DATA_TO_EXPORT.value:
698
- elt = self.dte_deserialization()
699
- elif obj_type == SerializableTypes.AXIS.value:
700
- elt = self.axis_deserialization()
701
- elif obj_type == SerializableTypes.BOOL.value:
702
- elt = self.boolean_deserialization()
703
- elif obj_type == SerializableTypes.LIST.value:
704
- elt = self.list_deserialization()
705
- elif obj_type == SerializableTypes.PARAMETER.value:
706
- elt = self.parameter_deserialization()
707
- else:
708
- print(f'invalid object type {obj_type}')
709
- elt = None # desired behavior?
710
- return elt
711
-
712
- def list_deserialization(self) -> list:
713
- """Convert bytes into a list of homogeneous objects
714
-
715
- Convert the first bytes into a list reading first information about the list elt types, length ...
716
-
717
- Returns
718
- -------
719
- list: the decoded list
720
- """
721
- list_obj = []
722
- list_len = self._int_deserialization()
723
-
724
- for ind in range(list_len):
725
- list_obj.append(self.type_and_object_deserialization())
726
- return list_obj
727
-
728
- def parameter_deserialization(self) -> putils.ParameterWithPath:
729
- path = self.list_deserialization()
730
- param_as_xml = self.string_deserialization()
731
- param_dict = ioxml.XML_string_to_parameter(param_as_xml)
732
- param_obj = Parameter(**param_dict[0])
733
- return putils.ParameterWithPath(param_obj, path)
734
-
735
- def axis_deserialization(self) -> Axis:
736
- """Convert bytes into an Axis object
737
-
738
- Convert the first bytes into an Axis reading first information about the Axis
739
-
740
- Returns
741
- -------
742
- Axis: the decoded Axis
743
- """
744
-
745
- class_name = self.string_deserialization()
746
- if class_name != Axis.__name__:
747
- raise TypeError(f'Attempting to deserialize an Axis but got the bytes for a {class_name}')
748
- axis_label = self.string_deserialization()
749
- axis_units = self.string_deserialization()
750
- axis_array = self.ndarray_deserialization()
751
- axis_index = self.scalar_deserialization()
752
- axis_spread_order = self.scalar_deserialization()
753
-
754
- axis = Axis(axis_label, axis_units, data=axis_array, index=axis_index,
755
- spread_order=axis_spread_order)
756
- return axis
757
-
758
- def dwa_deserialization(self) -> DataWithAxes:
759
- """Convert bytes into a DataWithAxes object
760
-
761
- Convert the first bytes into a DataWithAxes reading first information about the underlying data
762
-
763
- Returns
764
- -------
765
- DataWithAxes: the decoded DataWithAxes
766
- """
767
- class_name = self.string_deserialization()
768
- if class_name not in DwaType.names():
769
- raise TypeError(f'Attempting to deserialize a DataWithAxes '
770
- f'flavor but got the bytes for a {class_name}')
771
- timestamp = self.scalar_deserialization()
772
- dwa = getattr(data_mod, class_name)(self.string_deserialization(),
773
- units=self.string_deserialization(),
774
- source=self.string_deserialization(),
775
- dim=self.string_deserialization(),
776
- distribution=self.string_deserialization(),
777
- data=self.list_deserialization(),
778
- labels=self.list_deserialization(),
779
- origin=self.string_deserialization(),
780
- nav_indexes=tuple(self.list_deserialization()),
781
- axes=self.list_deserialization(),
782
- )
783
- errors = self.list_deserialization()
784
- if len(errors) != 0:
785
- dwa.errors = errors
786
- dwa.extra_attributes = self.list_deserialization()
787
- for attribute in dwa.extra_attributes:
788
- setattr(dwa, attribute, self.type_and_object_deserialization())
789
-
790
- dwa.timestamp = timestamp
791
- return dwa
792
-
793
- def dte_deserialization(self) -> DataToExport:
794
- """Convert bytes into a DataToExport object
795
-
796
- Convert the first bytes into a DataToExport reading first information about the underlying data
797
-
798
- Returns
799
- -------
800
- DataToExport: the decoded DataToExport
801
- """
802
- class_name = self.string_deserialization()
803
- if class_name != DataToExport.__name__:
804
- raise TypeError(f'Attempting to deserialize a DataToExport but got the bytes for a {class_name}')
805
- timestamp = self.scalar_deserialization()
806
- dte = DataToExport(self.string_deserialization(),
807
- data=self.list_deserialization(),
808
- )
809
- dte.timestamp = timestamp
810
- return dte
12
+ deprecation_msg('Importing Serializer, DeSerializer from pymodaq is deprecated in PyMoDAQ >= 5,'
13
+ 'import them from pymodaq_data.serialize.serializer')