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
@@ -1,38 +1,17 @@
1
- import copy
2
- import os
3
- import sys
4
- import datetime
1
+
5
2
  import importlib
6
- import inspect
7
- import json
8
- import functools
9
- import platform
10
- import re
11
- import time
12
- import warnings
13
3
  from packaging import version as version_mod
14
- from pathlib import Path
15
4
  import pkgutil
16
- import traceback
17
5
  import platform
18
- from typing import Union, List
19
- from typing import Iterable as IterableType
20
- from collections.abc import Iterable
6
+ from pathlib import Path
21
7
 
22
- import numpy as np
23
- from qtpy import QtCore
24
- from qtpy.QtCore import QLocale
8
+ from pymodaq_utils.config import Config
9
+ from pymodaq_utils.utils import get_entrypoints, ThreadCommand, getLineInfo, find_keys_from_val, is_64bits, timer # for backcompat
10
+ from pymodaq_utils.logger import set_logger, get_module_name # for backcompat
25
11
 
26
- from pymodaq.utils import logger as logger_module
27
- from pymodaq.utils.config import get_set_preset_path, Config
28
- from pymodaq.utils.messenger import deprecation_msg
29
- from pymodaq.utils.qvariant import QVariant
12
+ from pymodaq.utils.data import DataFromPlugins # for backcompat
30
13
 
31
- if version_mod.parse(platform.python_version()) >= version_mod.parse('3.8'): # from version 3.8 this feature is included in the
32
- # standard lib
33
- from importlib import metadata
34
- else:
35
- import importlib_metadata as metadata
14
+ from pymodaq.utils.config import get_set_preset_path
36
15
 
37
16
  if version_mod.parse(platform.python_version()) >= version_mod.parse('3.9'):
38
17
  # from version 3.9 the cache decorator is available
@@ -41,95 +20,11 @@ else:
41
20
  from functools import lru_cache as cache
42
21
 
43
22
 
44
- logger = logger_module.set_logger(logger_module.get_module_name(__file__))
23
+ logger = set_logger(get_module_name(__file__))
45
24
 
46
25
  config = Config()
47
26
 
48
27
 
49
- class PlotColors:
50
-
51
- def __init__(self, colors=config('plotting', 'plot_colors')[:]):
52
-
53
- self._internal_counter = -1
54
-
55
- self.check_colors(colors)
56
- self._plot_colors = [tuple(color) for color in colors]
57
-
58
- def copy(self):
59
- return copy.copy(self)
60
-
61
- def remove(self, item):
62
- self._plot_colors.remove(item)
63
-
64
- def __getitem__(self, item: int):
65
- if not isinstance(item, int):
66
- raise TypeError('getter should be an integer')
67
- return tuple(self._plot_colors[item % len(self._plot_colors)])
68
-
69
- def __len__(self):
70
- return len(self._plot_colors)
71
-
72
- def __iter__(self):
73
- self._internal_counter = -1
74
- return self
75
-
76
- def __next__(self):
77
- if self._internal_counter >= len(self) - 1:
78
- raise StopIteration
79
- self._internal_counter += 1
80
- return self[self._internal_counter]
81
-
82
- def check_colors(self, colors: IterableType):
83
- if not isinstance(colors, Iterable):
84
- raise TypeError('Colors should be a list of 3-tuple 8 bits integer (0-255)')
85
- for color in colors:
86
- self.check_color(color)
87
-
88
- @staticmethod
89
- def check_color(color: IterableType):
90
- if not isinstance(color, Iterable) and len(color) != 3:
91
- raise TypeError('Colors should be a list of 3-tuple 8 bits integer (0-255)')
92
- for col_val in color:
93
- if not (isinstance(col_val, int) and 0 <= col_val <= 255):
94
- raise TypeError('Colors should be a list of 3-tuple 8 bits integer (0-255)')
95
-
96
-
97
- plot_colors = PlotColors()
98
-
99
-
100
- def is_64bits():
101
- return sys.maxsize > 2**32
102
-
103
-
104
- def timer(func):
105
- """Print the runtime of the decorated function"""
106
- @functools.wraps(func)
107
- def wrapper_timer(*args, **kwargs):
108
- start_time = time.perf_counter() # 1
109
- value = func(*args, **kwargs)
110
- end_time = time.perf_counter() # 2
111
- run_time = end_time - start_time # 3
112
- print(f"Finished {func.__name__!r} in {run_time:.4f} secs")
113
- return value
114
- return wrapper_timer
115
-
116
-
117
- def get_version():
118
- """Obtain pymodaq version from the VERSION file
119
-
120
- Follows the layout from the packaging tool hatch, hatchling
121
- """
122
- DEFAULT_PATTERN = r'(?i)^(__version__|VERSION) *= *([\'"])v?(?P<version>.+?)\2'
123
-
124
- with open(str(Path(__file__).parent.parent.joinpath('resources/VERSION')), 'r') as fvers:
125
- contents = fvers.read().strip()
126
- match = re.search(DEFAULT_PATTERN, contents, flags=re.MULTILINE)
127
- groups = match.groupdict()
128
- if 'version' not in groups:
129
- raise ValueError('no group named `version` was defined in the pattern')
130
- return groups['version']
131
-
132
-
133
28
  def copy_preset(): # pragma: no cover
134
29
  path = get_set_preset_path().joinpath('preset_default.xml')
135
30
  if not path.exists(): # copy the preset_default from pymodaq folder and create one in pymodad's local folder
@@ -137,469 +32,6 @@ def copy_preset(): # pragma: no cover
137
32
  path.write_text(file.read())
138
33
 
139
34
 
140
- def set_qt_backend():
141
- backend_present = True
142
- if config('qtbackend', 'backend').lower() not in [mod.lower() for mod in sys.modules]:
143
- backend_present = False
144
- logger.warning(f"The chosen Qt backend ({config('qtbackend', 'backend')}) has not been installed...\n"
145
- f"Trying another...")
146
- backends = config('qtbackend', 'backends')
147
- backends.pop(config('qtbackend', 'backend'))
148
- for backend in backends:
149
- if backend.lower() in [mod.lower() for mod in sys.modules]:
150
- backend_present = True
151
- break
152
-
153
- if backend_present:
154
- os.environ['QT_API'] = config('qtbackend', 'backend')
155
- logger.info('************************')
156
- logger.info(f"{config('qtbackend', 'backend')} Qt backend loaded")
157
- logger.info('************************')
158
- else:
159
- msg = f"No Qt backend could be found in your system, please install either pyqt5/6 or pyside2/6." \
160
- f"pyqt5 is still preferred, while pyqt6 should mostly work."
161
- logger.critical(msg)
162
- warnings.warn(msg, FutureWarning, 3)
163
- print(msg.upper())
164
-
165
-
166
- class JsonConverter:
167
- def __init__(self):
168
- super().__init__()
169
-
170
- @classmethod
171
- def trusted_types(cls):
172
- return ['float', 'int', 'str', 'datetime', 'date', 'time', 'tuple', 'list', 'bool', 'bytes',
173
- 'float64']
174
-
175
- @classmethod
176
- def istrusted(cls, type_name):
177
- return type_name in cls.trusted_types()
178
-
179
- @classmethod
180
- def object2json(cls, obj):
181
- dic = dict(module=type(obj).__module__, type=type(obj).__name__, data=repr(obj))
182
- return json.dumps(dic)
183
-
184
- @classmethod
185
- def json2object(cls, jsonstring):
186
- try:
187
- dic = json.loads(jsonstring)
188
- if isinstance(dic, dict):
189
- if dic['type'] in cls.trusted_types():
190
- return eval(dic['data'])
191
- else:
192
- return dic
193
- else: # pragma: no cover
194
- return dic
195
- except Exception:
196
- return jsonstring
197
-
198
-
199
- def decode_data(encoded_data):
200
- """
201
- Decode QbyteArrayData generated when drop items in table/tree/list view
202
- Parameters
203
- ----------
204
- encoded_data: QByteArray
205
- Encoded data of the mime data to be dropped
206
- Returns
207
- -------
208
- data: list
209
- list of dict whose key is the QtRole in the Model, and the value a QVariant
210
-
211
- """
212
- data = []
213
-
214
- ds = QtCore.QDataStream(encoded_data, QtCore.QIODevice.ReadOnly)
215
- while not ds.atEnd():
216
- row = ds.readInt32()
217
- col = ds.readInt32()
218
-
219
- map_items = ds.readInt32()
220
- item = {}
221
- for ind in range(map_items):
222
- key = ds.readInt32()
223
- #TODO check this is fine
224
- value = QVariant()
225
- #value = None
226
- ds >> value
227
- item[QtCore.Qt.ItemDataRole(key)] = value.value()
228
- data.append(item)
229
- return data
230
-
231
-
232
- #############################
233
-
234
- def capitalize(string, Nfirst=1):
235
- """
236
- Returns same string but with first Nfirst letters upper
237
- Parameters
238
- ----------
239
- string: (str)
240
- Nfirst: (int)
241
- Returns
242
- -------
243
- str
244
- """
245
- return string[:Nfirst].upper() + string[Nfirst:]
246
-
247
-
248
- def uncapitalize(string, Nfirst=1):
249
- return string[:Nfirst].lower() + string[Nfirst:]
250
-
251
-
252
- def getLineInfo():
253
- """get information about where the Exception has been triggered"""
254
- tb = sys.exc_info()[2]
255
- res = ''
256
- for t in traceback.format_tb(tb):
257
- res += t
258
- return res
259
-
260
-
261
- class ThreadCommand:
262
- """Generic object to pass info (command) and data (attribute) between thread or objects using signals
263
-
264
- Parameters
265
- ----------
266
- command: str
267
- The command to be analysed for further action
268
- attribute: any type
269
- the attribute related to the command. The actual type and value depend on the command and the situation
270
- attributes: deprecated, attribute should be used instead
271
-
272
- Attributes
273
- ----------
274
- command : str
275
- The command to be analysed for further action
276
- attribute : any type
277
- the attribute related to the command. The actual type and value depend on the command and the situation
278
- """
279
-
280
- def __init__(self, command: str, attribute=None, attributes=None):
281
- if not isinstance(command, str):
282
- raise TypeError(f'The command in a Threadcommand object should be a string, not a {type(command)}')
283
- self.command = command
284
- if attribute is None and attributes is not None:
285
- deprecation_msg('ThreadCommand signature changed, use attribute in place of attributes')
286
- self.attribute = attributes
287
- self.attributes = attributes
288
- self.attribute = attribute
289
-
290
- def __repr__(self):
291
- return f'Threadcommand: {self.command} with attribute {self.attribute}'
292
-
293
-
294
- def ensure_ndarray(data):
295
- """
296
- Make sure data is returned as a numpy array
297
- Parameters
298
- ----------
299
- data
300
-
301
- Returns
302
- -------
303
- ndarray
304
- """
305
- if not isinstance(data, np.ndarray):
306
- if isinstance(data, list):
307
- data = np.array(data)
308
- else:
309
- data = np.array([data])
310
- return data
311
-
312
-
313
- def setLocale():
314
- """
315
- defines the Locale to use to convert numbers to strings representation using language/country conventions
316
- Default is English and US
317
- """
318
- language = getattr(QLocale, config('style', 'language'))
319
- country = getattr(QLocale, config('style', 'country'))
320
- QLocale.setDefault(QLocale(language, country))
321
-
322
-
323
- def recursive_find_files_extension(ini_path, ext, paths=[]):
324
- with os.scandir(ini_path) as it:
325
- for entry in it:
326
- if os.path.splitext(entry.name)[1][1:] == ext and entry.is_file():
327
- paths.append(entry.path)
328
- elif entry.is_dir():
329
- recursive_find_files_extension(entry.path, ext, paths)
330
- return paths
331
-
332
-
333
- def recursive_find_files(ini_path, exp='make_enum', paths=[],
334
- filters=['build']):
335
- for child in Path(ini_path).iterdir():
336
- if child.is_dir():
337
- recursive_find_files(child, exp, paths, filters)
338
- else:
339
- if exp in child.stem:
340
- if not any([filt in str(child) for filt in filters]):
341
- paths.append(child)
342
- return paths
343
-
344
-
345
- def recursive_find_expr_in_files(ini_path, exp='make_enum', paths=[],
346
- filters=['.git', '.idea', '__pycache__', 'build', 'egg', 'documentation', '.tox'],
347
- replace=False, replace_str=''):
348
-
349
- for child in Path(ini_path).iterdir():
350
- if not any(filt in str(child) for filt in filters):
351
- if child.is_dir():
352
- recursive_find_expr_in_files(child, exp, paths, filters, replace=replace, replace_str=replace_str)
353
- else:
354
- try:
355
- found = False
356
- with child.open('r') as f:
357
- replacement = ''
358
- for ind, line in enumerate(f):
359
- if exp in line:
360
- found = True
361
- paths.append([child, ind, line])
362
- if replace:
363
- replacement += line.replace(exp, replace_str)
364
- else:
365
- if replace:
366
- replacement += line
367
- if replace and found:
368
- with child.open('w') as f:
369
- f.write(replacement)
370
- except Exception:
371
- pass
372
- return paths
373
-
374
-
375
- def count_lines(ini_path, count=0, filters=['lextab', 'yacctab','pycache', 'pyc']):
376
- # if Path(ini_path).is_file():
377
- # with Path(ini_path).open('r') as f:
378
- # count += len(f.readlines())
379
- # return count
380
- for child in Path(ini_path).iterdir():
381
- if child.is_dir():
382
- count = count_lines(child, count)
383
- else:
384
- try:
385
- if not any([filt in child.name for filt in filters]):
386
- if '.py' in child.name:
387
- with child.open('r') as f:
388
- count += len(f.readlines())
389
- else:
390
- print(child.stem)
391
- except Exception:
392
- pass
393
- return count
394
-
395
-
396
- def remove_spaces(string):
397
- """
398
- return a string without any white spaces in it
399
- Parameters
400
- ----------
401
- string
402
-
403
- Returns
404
- -------
405
-
406
- """
407
- return ''.join(string.split())
408
-
409
-
410
- def rint(x):
411
- """
412
- almost same as numpy rint function but return an integer
413
- Parameters
414
- ----------
415
- x: (float or integer)
416
-
417
- Returns
418
- -------
419
- nearest integer
420
- """
421
- return int(np.rint(x))
422
-
423
-
424
- def elt_as_first_element(elt_list, match_word='Mock'):
425
- if not hasattr(elt_list, '__iter__'):
426
- raise TypeError('elt_list must be an iterable')
427
- if elt_list:
428
- ind_elt = 0
429
- for ind, elt in enumerate(elt_list):
430
- if not isinstance(elt, str):
431
- raise TypeError('elt_list must be a list of str')
432
- if match_word in elt:
433
- ind_elt = ind
434
- break
435
- plugin_match = elt_list[ind_elt]
436
- elt_list.remove(plugin_match)
437
- plugins = [plugin_match]
438
- plugins.extend(elt_list)
439
- else:
440
- plugins = []
441
- return plugins
442
-
443
-
444
- def elt_as_first_element_dicts(elt_list, match_word='Mock', key='name'):
445
- if not hasattr(elt_list, '__iter__'):
446
- raise TypeError('elt_list must be an iterable')
447
- if elt_list:
448
- ind_elt = 0
449
- for ind, elt in enumerate(elt_list):
450
- if not isinstance(elt, dict):
451
- raise TypeError('elt_list must be a list of dicts')
452
- if match_word in elt[key]:
453
- ind_elt = ind
454
- break
455
- plugin_match = elt_list[ind_elt]
456
- elt_list.remove(plugin_match)
457
- plugins = [plugin_match]
458
- plugins.extend(elt_list)
459
- else:
460
- plugins = []
461
- return plugins
462
-
463
-
464
- def find_keys_from_val(dict_tmp: dict, val: object):
465
- """Returns the keys from a dict if its value is matching val"""
466
- return [k for k, v in dict_tmp.items() if v == val]
467
-
468
-
469
- def find_object_if_matched_attr_name_val(obj, attr_name, attr_value):
470
- """check if an attribute key/value pair match in a given object
471
-
472
- Parameters
473
- ----------
474
- obj: object
475
- attr_name: str
476
- attribute name to look for in the object
477
- attr_value: object
478
- value to match
479
-
480
- Returns
481
- -------
482
- bool: True if the key/value pair has been found in dict_tmp
483
-
484
- """
485
- if hasattr(obj, attr_name):
486
- if getattr(obj, attr_name) == attr_value:
487
- return True
488
- return False
489
-
490
-
491
- def find_objects_in_list_from_attr_name_val(objects: List[object], attr_name: str,
492
- attr_value: object, return_first=True):
493
- """ lookup within a list of objects. Look for the objects within the list which has the correct attribute name,
494
- value pair
495
-
496
- Parameters
497
- ----------
498
- objects: list
499
- list of objects
500
- attr_name: str
501
- attribute name to look for in the object
502
- attr_value: object
503
- value to match
504
- return_first: bool
505
- if True return the first objects found in the list else all the objects matching
506
-
507
- Returns
508
- -------
509
- list of tuple(object, int): object and index or list of object and indexes
510
- """
511
- selection = []
512
- obj = None
513
- for ind, obj_tmp in enumerate(objects):
514
- if find_object_if_matched_attr_name_val(obj_tmp, attr_name, attr_value):
515
- obj = obj_tmp
516
- if return_first:
517
- break
518
- else:
519
- selection.append((obj_tmp, ind))
520
-
521
- if obj is None:
522
- if return_first:
523
- return None, -1
524
- else:
525
- return []
526
- else:
527
- if return_first:
528
- return obj, ind
529
- else:
530
- return selection
531
-
532
-
533
- def find_dict_if_matched_key_val(dict_tmp, key, value):
534
- """
535
- check if a key/value pair match in a given dictionnary
536
- Parameters
537
- ----------
538
- dict_tmp: (dict) the dictionnary to be tested
539
- key: (str) a key string to look for in dict_tmp
540
- value: (object) any python object
541
-
542
- Returns
543
- -------
544
- bool: True if the key/value pair has been found in dict_tmp
545
-
546
- """
547
- if key in dict_tmp:
548
- if dict_tmp[key] == value:
549
- return True
550
- return False
551
-
552
-
553
- def find_dict_in_list_from_key_val(dicts, key, value, return_index=False):
554
- """ lookup within a list of dicts. Look for the dict within the list which has the correct key, value pair
555
-
556
- Parameters
557
- ----------
558
- dicts: (list) list of dictionnaries
559
- key: (str) specific key to look for in each dict
560
- value: value to match
561
-
562
- Returns
563
- -------
564
- dict: if found otherwise returns None
565
- """
566
- for ind, dict_tmp in enumerate(dicts):
567
- if find_dict_if_matched_key_val(dict_tmp, key, value):
568
- if return_index:
569
- return dict_tmp, ind
570
- else:
571
- return dict_tmp
572
- if return_index:
573
- return None, -1
574
- else:
575
- return None
576
-
577
-
578
- def get_entrypoints(group='pymodaq.plugins') -> List[metadata.EntryPoint]:
579
- """ Get the list of modules defined from a group entry point
580
-
581
- Because of evolution in the package, one or another of the forms below may be deprecated.
582
- We start from the newer way down to the older
583
-
584
- Parameters
585
- ----------
586
- group: str
587
- the name of the group
588
- """
589
- try:
590
- discovered_entrypoints = metadata.entry_points(group=group)
591
- except TypeError:
592
- try:
593
- discovered_entrypoints = metadata.entry_points().select(group=group)
594
- except AttributeError:
595
- discovered_entrypoints = metadata.entry_points().get(group, [])
596
- if isinstance(discovered_entrypoints, tuple): # API for python > 3.8
597
- discovered_entrypoints = list(discovered_entrypoints)
598
- if not isinstance(discovered_entrypoints, list):
599
- discovered_entrypoints = list(discovered_entrypoints)
600
- return discovered_entrypoints
601
-
602
-
603
35
  @cache
604
36
  def get_instrument_plugins(): # pragma: no cover
605
37
  """
@@ -692,6 +124,7 @@ def get_instrument_plugins(): # pragma: no cover
692
124
  except Exception as e:
693
125
  logger.debug(f'Impossible to import PID utility plugin: {str(e)}')
694
126
 
127
+ plugins_import.sort(key=lambda mod: mod['name'])
695
128
  return plugins_import
696
129
 
697
130
 
@@ -709,142 +142,3 @@ def get_plugins(plugin_type='daq_0Dviewer'): # pragma: no cover
709
142
  """
710
143
  return [plug for plug in get_instrument_plugins() if plug['type'] == plugin_type]
711
144
 
712
-
713
- def check_vals_in_iterable(iterable1, iterable2):
714
- assert len(iterable1) == len(iterable2)
715
- iterable1 = list(iterable1) # so the assertion below is valid for any kind of iterable, list, tuple, ndarray...
716
- iterable2 = list(iterable2)
717
- for val1, val2 in zip(iterable1, iterable2):
718
- assert val1 == val2
719
-
720
-
721
- def caller_name(skip=2):
722
- """Get a name of a caller in the format module.class.method
723
-
724
- `skip` specifies how many levels of stack to skip while getting caller
725
- name. skip=1 means "who calls me", skip=2 "who calls my caller" etc.
726
-
727
- An empty string is returned if skipped levels exceed stack height
728
- """
729
- stack = inspect.stack()
730
- start = 0 + skip
731
- if len(stack) < start + 1:
732
- return ''
733
- parentframe = stack[start][0]
734
-
735
- name = []
736
- module = inspect.getmodule(parentframe)
737
- # `modname` can be None when frame is executed directly in console
738
- # TODO(techtonik): consider using __main__
739
- if module:
740
- name.append(module.__name__)
741
- # detect classname
742
- if 'self' in parentframe.f_locals:
743
- # I don't know any way to detect call from the object method
744
- # XXX: there seems to be no way to detect static method call - it will
745
- # be just a function call
746
- name.append(parentframe.f_locals['self'].__class__.__name__)
747
- codename = parentframe.f_code.co_name
748
- if codename != '<module>': # top level usually
749
- name.append(codename) # function or a method
750
- del parentframe
751
- return ".".join(name)
752
-
753
-
754
- def zeros_aligned(n, align, dtype=np.uint32):
755
- """
756
- Get aligned memory array wih alignment align.
757
- Parameters
758
- ----------
759
- n: (int) length in dtype bytes of memory
760
- align: (int) memory alignment
761
- dtype: (numpy.dtype) type of the stored memory elements
762
-
763
- Returns
764
- -------
765
-
766
- """
767
- dtype = np.dtype(dtype)
768
- nbytes = n * dtype.itemsize
769
- buff = np.zeros(nbytes + align, dtype=np.uint8)
770
- start_index = -buff.ctypes.data % align
771
- return buff[start_index:start_index + nbytes].view(dtype)
772
-
773
-
774
- # ########################
775
- # #File management
776
-
777
- def get_new_file_name(base_path=Path(config('data_saving', 'h5file', 'save_path')), base_name='tttr_data'):
778
- if isinstance(base_path, str):
779
- base_path = Path(base_path)
780
-
781
- today = datetime.datetime.now()
782
-
783
- date = today.strftime('%Y%m%d')
784
- year = today.strftime('%Y')
785
- year_dir = base_path.joinpath(year)
786
- if not year_dir.is_dir():
787
- year_dir.mkdir()
788
- curr_dir = base_path.joinpath(year, date)
789
- if not curr_dir.is_dir():
790
- curr_dir.mkdir()
791
-
792
- files = []
793
- for entry in curr_dir.iterdir():
794
- if entry.name.startswith(base_name) and entry.is_file():
795
- files.append(entry.stem)
796
- files.sort()
797
- if not files:
798
- index = 0
799
- else:
800
- index = int(files[-1][-3:]) + 1
801
-
802
- file = f'{base_name}_{index:03d}'
803
- return file, curr_dir
804
-
805
-
806
- if __name__ == '__main__':
807
- #paths = recursive_find_expr_in_files('C:\\Users\\weber\\Labo\\Programmes Python\\PyMoDAQ_Git', 'visa')
808
- # for p in paths:
809
- # print(str(p))
810
- # v = get_version()
811
- # pass
812
- #plugins = get_plugins() # pragma: no cover
813
- #extensions = get_extension()
814
- #models = get_models()
815
- #count = count_lines('C:\\Users\\weber\\Labo\\Programmes Python\\PyMoDAQ_Git\\pymodaq\src')
816
-
817
-
818
- # import license
819
- # mit = license.find('MIT')
820
- #
821
-
822
- # paths = recursive_find_expr_in_files(r'C:\Users\weber\Labo\Programmes Python\PyMoDAQ_Git',
823
- # exp="cfunc",
824
- # paths=[],
825
- # filters=['.git', '.idea', '__pycache__', 'build', 'egg', 'documentation',
826
- # '.tox',],
827
- # replace=False,
828
- # replace_str="pymodaq.utils")
829
-
830
- #get_version()
831
- get_instrument_plugins()
832
- #get_plugins('daq_move')
833
- #get_plugins('daq_0Dviewer')
834
- pass
835
-
836
- # paths = recursive_find_files('C:\\Users\\weber\\Labo\\Programmes Python\\PyMoDAQ_Git',
837
- # exp='VERSION', paths=[])
838
- # import version
839
- # for file in paths:
840
- # with open(str(file), 'r') as f:
841
- # v = version.Version(f.read())
842
- # v.minor += 1
843
- # v.patch = 0
844
- # with open(str(file), 'w') as f:
845
- # f.write(str(v))
846
-
847
- # for file in paths:
848
- # with open(str(file), 'w') as f:
849
- # f.write(mit.render(name='Sebastien Weber', email='sebastien.weber@cemes.fr'))
850
-