pymodaq 4.2.3__py3-none-any.whl → 5.0.0__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.
- pymodaq/__init__.py +30 -23
- pymodaq/control_modules/daq_move.py +27 -14
- pymodaq/control_modules/daq_move_ui.py +33 -16
- pymodaq/control_modules/daq_viewer.py +38 -28
- pymodaq/control_modules/daq_viewer_ui.py +6 -6
- pymodaq/control_modules/mocks.py +1 -1
- pymodaq/control_modules/move_utility_classes.py +19 -10
- pymodaq/control_modules/utils.py +18 -12
- pymodaq/control_modules/viewer_utility_classes.py +13 -4
- pymodaq/dashboard.py +166 -118
- pymodaq/examples/custom_app.py +13 -16
- pymodaq/examples/custom_viewer.py +7 -7
- pymodaq/examples/function_plotter.py +13 -12
- pymodaq/examples/parameter_ex.py +50 -25
- pymodaq/examples/tcp_client.py +1 -1
- pymodaq/extensions/__init__.py +1 -1
- pymodaq/extensions/bayesian/bayesian_optimisation.py +15 -12
- pymodaq/extensions/bayesian/utils.py +10 -10
- pymodaq/extensions/console.py +10 -13
- pymodaq/extensions/{daq_logger.py → daq_logger/daq_logger.py} +36 -56
- pymodaq/{utils/db/db_logger → extensions/daq_logger/db}/db_logger.py +16 -15
- pymodaq/{utils/db/db_logger → extensions/daq_logger/db}/db_logger_models.py +2 -0
- pymodaq/{utils/h5modules → extensions/daq_logger}/h5logging.py +7 -8
- pymodaq/extensions/daq_scan.py +153 -247
- pymodaq/extensions/daq_scan_ui.py +11 -9
- pymodaq/extensions/h5browser.py +8 -8
- pymodaq/extensions/pid/__init__.py +6 -3
- pymodaq/extensions/pid/daq_move_PID.py +4 -2
- pymodaq/extensions/pid/pid_controller.py +15 -12
- pymodaq/extensions/pid/utils.py +10 -5
- pymodaq/extensions/utils.py +5 -3
- pymodaq/post_treatment/load_and_plot.py +10 -7
- pymodaq/resources/preset_default.xml +1 -1
- pymodaq/utils/array_manipulation.py +4 -384
- pymodaq/utils/calibration_camera.py +12 -9
- pymodaq/utils/chrono_timer.py +7 -5
- pymodaq/utils/config.py +3 -450
- pymodaq/utils/daq_utils.py +6 -664
- pymodaq/utils/data.py +9 -2774
- pymodaq/utils/exceptions.py +0 -4
- pymodaq/utils/gui_utils/__init__.py +8 -8
- pymodaq/utils/gui_utils/loader_utils.py +38 -0
- pymodaq/utils/gui_utils/utils.py +6 -138
- pymodaq/utils/h5modules/__init__.py +0 -4
- pymodaq/utils/h5modules/module_saving.py +15 -8
- pymodaq/utils/leco/__init__.py +2 -2
- pymodaq/utils/leco/daq_move_LECODirector.py +2 -2
- pymodaq/utils/leco/daq_xDviewer_LECODirector.py +2 -2
- pymodaq/utils/leco/director_utils.py +2 -2
- pymodaq/utils/leco/leco_director.py +3 -3
- pymodaq/utils/leco/pymodaq_listener.py +2 -2
- pymodaq/utils/leco/utils.py +1 -1
- pymodaq/utils/logger.py +4 -76
- pymodaq/utils/managers/batchscan_manager.py +16 -19
- pymodaq/utils/managers/modules_manager.py +10 -7
- pymodaq/utils/managers/overshoot_manager.py +3 -5
- pymodaq/utils/managers/preset_manager.py +37 -15
- pymodaq/utils/managers/preset_manager_utils.py +11 -9
- pymodaq/utils/managers/remote_manager.py +12 -10
- pymodaq/utils/math_utils.py +4 -572
- pymodaq/utils/parameter/__init__.py +4 -11
- pymodaq/utils/parameter/utils.py +4 -299
- pymodaq/utils/scanner/scan_config.py +1 -1
- pymodaq/utils/scanner/scan_factory.py +16 -12
- pymodaq/utils/{plotting → scanner}/scan_selector.py +19 -20
- pymodaq/utils/scanner/scanner.py +10 -8
- pymodaq/utils/scanner/scanners/_1d_scanners.py +8 -5
- pymodaq/utils/scanner/scanners/_2d_scanners.py +5 -5
- pymodaq/utils/scanner/scanners/sequential.py +8 -8
- pymodaq/utils/scanner/scanners/tabular.py +9 -9
- pymodaq/utils/scanner/utils.py +6 -4
- pymodaq/utils/svg/svg_viewer2D.py +3 -4
- pymodaq/utils/tcp_ip/serializer.py +64 -16
- pymodaq/utils/tcp_ip/tcp_server_client.py +10 -8
- {pymodaq-4.2.3.dist-info → pymodaq-5.0.0.dist-info}/METADATA +5 -3
- pymodaq-5.0.0.dist-info/RECORD +123 -0
- {pymodaq-4.2.3.dist-info → pymodaq-5.0.0.dist-info}/WHEEL +1 -1
- pymodaq/post_treatment/process_to_scalar.py +0 -263
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/1d.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/2d.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/3d.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Add2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Add_Step.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Approve.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Approve_All.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Browse_Dir_Path.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Calculator.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/ChnGroup.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/ChnNum.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/ChnText.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/ChnTime.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/ChnWave.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Close3.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/CollapseAll.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/CollapseAll_32.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/ColorPicker.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Contract.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Create.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/DeleteLayer.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/EditOpen.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/EditRedo.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/EditUndo.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Ellipse.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/EllipseFilled.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Error.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/ErrorMessage.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Error_16.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Exit.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Expand.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/ExpandAll.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/ExpandAll_32.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/FFT.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/HLM.ico +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Help.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Help_32.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Histogram.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/LUT_LookUpTable.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/MagnifyingGlass.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/MagnifyingGlass_24.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Marker.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Math.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/MeasurementStudio_32.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Move.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/MoveDown.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/MoveUp.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Multiply.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/NewFile.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/NewLayer.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/New_File.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/New_Folder.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open_1D.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open_2D.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open_File.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open_File_32.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open_sim.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Options.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Oscilloscope.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Oscilloscope_16.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Pass.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/RGB.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Rectangle.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/RectangleFilled.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Redo.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Refresh.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Refresh2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Refresh_32.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Region.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Rendezvous.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/SELECT.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Save.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/SaveAll.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/SaveAll_32.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/SaveAs.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/SaveAs_32.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Save_24.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Save_32.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Search.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/SelectPolygon.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Select_24.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Settings.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Snap&Save.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Snapshot.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Snapshot2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Snapshot2_16.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Snapshot2_32.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Spreadsheet.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Statistics.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Statistics2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Status.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Subtract.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Vision.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Volts.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Wait2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Zoom_1_1.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Zoom_in.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Zoom_out.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/Zoom_to_Selection.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/abort.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/advanced2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/autoscale.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/b_icon.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/back.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/bg_icon.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/camera.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/camera_snap.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/cartesian.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/clear2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/clear_ROI.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/close2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/cluster2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/color.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/color2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/continuous.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/data.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/delay.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/download.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/download2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/error2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/ethernet.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/exit2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/fan.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/filter2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/g_icon.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/gear2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/go_to.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/go_to_1.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/go_to_2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/grab.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/graph.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/greenLight2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/greenLight2_32.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/green_light.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/grey_icon.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/greyscale.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/help1.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/help1_32.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/home2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/information2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/ini.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/integrator.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/joystick.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_green.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_green_16.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_red.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_red_16.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_yellow.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_yellow_16.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/limiter.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/load_ROI.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/meshPlot.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/meter.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/meter2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/meter_32.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/move_contour.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/move_straight_line.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/movie.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/multi_point.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/multiplexer.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/new.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/openArrow.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/openTree.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/oscilloscope2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/oscilloscope3.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/overlay.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/pass2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/pass2_16.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/pass_32.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/pause.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/permute.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/phase.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/play.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/polar.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/pole_zero.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/powerMeter.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/powerSwitch.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/powerSwitch_16.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/print2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/print2_32.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/properties.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/r_icon.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/radiocontrolbutton.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/read2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/red_light.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/remove.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/reset.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/rgb_icon.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/robot.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/rotation2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/run2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/run_all.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/saturation.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/saveTree.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/save_ROI.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/scale_horizontally.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/scale_vertically.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/search2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/select2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/select_all.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/select_all2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/select_none.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/sequence.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/sequence2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/snap.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/sort_ascend.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/spectrumAnalyzer.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/start.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/status_cancelled.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/stop.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/stop2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/stop3.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/stop_all.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/sum.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/surfacePlot.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/tree.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/updateTree.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/utility2.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/utility_small.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/vector.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/verify.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/video.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/wait.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/waterfallPlot.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/watershed.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/yellow_light.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/zip_file.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/zoomAuto.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/Icon_Library/zoomReset.png +0 -0
- pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources.bat +0 -2
- pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources.qrc +0 -234
- pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources_rc.py +0 -127150
- pymodaq/resources/QtDesigner_Ressources/icons.svg +0 -142
- pymodaq/resources/VERSION +0 -1
- pymodaq/resources/config_template.toml +0 -90
- pymodaq/resources/triangulation_data.npy +0 -0
- pymodaq/utils/abstract/__init__.py +0 -48
- pymodaq/utils/db/__init__.py +0 -0
- pymodaq/utils/db/db_logger/__init__.py +0 -0
- pymodaq/utils/enums.py +0 -76
- pymodaq/utils/factory.py +0 -82
- pymodaq/utils/gui_utils/custom_app.py +0 -133
- pymodaq/utils/gui_utils/dock.py +0 -107
- pymodaq/utils/gui_utils/file_io.py +0 -93
- pymodaq/utils/gui_utils/layout.py +0 -34
- pymodaq/utils/gui_utils/list_picker.py +0 -38
- pymodaq/utils/gui_utils/widgets/__init__.py +0 -5
- pymodaq/utils/gui_utils/widgets/label.py +0 -24
- pymodaq/utils/gui_utils/widgets/lcd.py +0 -111
- pymodaq/utils/gui_utils/widgets/push.py +0 -149
- pymodaq/utils/gui_utils/widgets/qled.py +0 -62
- pymodaq/utils/gui_utils/widgets/spinbox.py +0 -24
- pymodaq/utils/gui_utils/widgets/table.py +0 -263
- pymodaq/utils/gui_utils/widgets/tree_layout.py +0 -188
- pymodaq/utils/gui_utils/widgets/tree_toml.py +0 -102
- pymodaq/utils/h5modules/backends.py +0 -1022
- pymodaq/utils/h5modules/browsing.py +0 -625
- pymodaq/utils/h5modules/data_saving.py +0 -1101
- pymodaq/utils/h5modules/exporter.py +0 -119
- pymodaq/utils/h5modules/exporters/__init__.py +0 -0
- pymodaq/utils/h5modules/exporters/base.py +0 -111
- pymodaq/utils/h5modules/exporters/flimj.py +0 -63
- pymodaq/utils/h5modules/exporters/hyperspy.py +0 -143
- pymodaq/utils/h5modules/saving.py +0 -866
- pymodaq/utils/h5modules/utils.py +0 -115
- pymodaq/utils/managers/action_manager.py +0 -489
- pymodaq/utils/managers/parameter_manager.py +0 -282
- pymodaq/utils/managers/roi_manager.py +0 -726
- pymodaq/utils/messenger.py +0 -66
- pymodaq/utils/parameter/ioxml.py +0 -542
- pymodaq/utils/parameter/pymodaq_ptypes/__init__.py +0 -38
- pymodaq/utils/parameter/pymodaq_ptypes/bool.py +0 -31
- pymodaq/utils/parameter/pymodaq_ptypes/date.py +0 -126
- pymodaq/utils/parameter/pymodaq_ptypes/filedir.py +0 -143
- pymodaq/utils/parameter/pymodaq_ptypes/itemselect.py +0 -265
- pymodaq/utils/parameter/pymodaq_ptypes/led.py +0 -44
- pymodaq/utils/parameter/pymodaq_ptypes/list.py +0 -150
- pymodaq/utils/parameter/pymodaq_ptypes/numeric.py +0 -18
- pymodaq/utils/parameter/pymodaq_ptypes/pixmap.py +0 -175
- pymodaq/utils/parameter/pymodaq_ptypes/slide.py +0 -145
- pymodaq/utils/parameter/pymodaq_ptypes/table.py +0 -135
- pymodaq/utils/parameter/pymodaq_ptypes/tableview.py +0 -149
- pymodaq/utils/parameter/pymodaq_ptypes/text.py +0 -142
- pymodaq/utils/plotting/__init__.py +0 -0
- pymodaq/utils/plotting/data_viewers/__init__.py +0 -10
- pymodaq/utils/plotting/data_viewers/base.py +0 -286
- pymodaq/utils/plotting/data_viewers/viewer.py +0 -274
- pymodaq/utils/plotting/data_viewers/viewer0D.py +0 -298
- pymodaq/utils/plotting/data_viewers/viewer1D.py +0 -820
- pymodaq/utils/plotting/data_viewers/viewer1Dbasic.py +0 -231
- pymodaq/utils/plotting/data_viewers/viewer2D.py +0 -1118
- pymodaq/utils/plotting/data_viewers/viewer2D_basic.py +0 -146
- pymodaq/utils/plotting/data_viewers/viewerND.py +0 -800
- pymodaq/utils/plotting/gant_chart.py +0 -123
- pymodaq/utils/plotting/image_viewer.py +0 -97
- pymodaq/utils/plotting/items/__init__.py +0 -0
- pymodaq/utils/plotting/items/axis_scaled.py +0 -93
- pymodaq/utils/plotting/items/crosshair.py +0 -94
- pymodaq/utils/plotting/items/image.py +0 -388
- pymodaq/utils/plotting/navigator.py +0 -353
- pymodaq/utils/plotting/plotter/plotter.py +0 -94
- pymodaq/utils/plotting/plotter/plotters/__init__.py +0 -0
- pymodaq/utils/plotting/plotter/plotters/matplotlib_plotters.py +0 -134
- pymodaq/utils/plotting/plotter/plotters/qt_plotters.py +0 -78
- pymodaq/utils/plotting/utils/__init__.py +0 -0
- pymodaq/utils/plotting/utils/axes_viewer.py +0 -88
- pymodaq/utils/plotting/utils/filter.py +0 -585
- pymodaq/utils/plotting/utils/lineout.py +0 -226
- pymodaq/utils/plotting/utils/plot_utils.py +0 -579
- pymodaq/utils/plotting/utils/signalND.py +0 -1347
- pymodaq/utils/plotting/widgets.py +0 -76
- pymodaq/utils/qvariant.py +0 -12
- pymodaq/utils/slicing.py +0 -63
- pymodaq/utils/units.py +0 -216
- pymodaq-4.2.3.dist-info/RECORD +0 -438
- /pymodaq/{post_treatment/daq_analysis → extensions/daq_logger}/__init__.py +0 -0
- /pymodaq/{utils/abstract/logger.py → extensions/daq_logger/abstract.py} +0 -0
- /pymodaq/{resources/QtDesigner_Ressources → extensions/daq_logger/db}/__init__.py +0 -0
- {pymodaq-4.2.3.dist-info → pymodaq-5.0.0.dist-info}/entry_points.txt +0 -0
- {pymodaq-4.2.3.dist-info → pymodaq-5.0.0.dist-info}/licenses/LICENSE +0 -0
pymodaq/utils/daq_utils.py
CHANGED
|
@@ -1,37 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
import sys
|
|
3
|
-
import datetime
|
|
1
|
+
|
|
4
2
|
import importlib
|
|
5
|
-
import inspect
|
|
6
|
-
import json
|
|
7
|
-
import functools
|
|
8
|
-
import platform
|
|
9
|
-
import re
|
|
10
|
-
import time
|
|
11
|
-
import warnings
|
|
12
3
|
from packaging import version as version_mod
|
|
13
|
-
from pathlib import Path
|
|
14
4
|
import pkgutil
|
|
15
|
-
import traceback
|
|
16
5
|
import platform
|
|
17
|
-
from
|
|
18
|
-
from typing import Iterable as IterableType
|
|
19
|
-
from collections.abc import Iterable
|
|
20
|
-
|
|
21
|
-
import numpy as np
|
|
22
|
-
from qtpy import QtCore
|
|
23
|
-
from qtpy.QtCore import QLocale
|
|
6
|
+
from pathlib import Path
|
|
24
7
|
|
|
25
|
-
from
|
|
26
|
-
from
|
|
27
|
-
from
|
|
28
|
-
from pymodaq.utils.qvariant import QVariant
|
|
8
|
+
from pymodaq_utils import logger as logger_module
|
|
9
|
+
from pymodaq_utils.config import Config
|
|
10
|
+
from pymodaq_utils.utils import get_entrypoints, ThreadCommand, getLineInfo
|
|
29
11
|
|
|
30
|
-
|
|
31
|
-
# standard lib
|
|
32
|
-
from importlib import metadata
|
|
33
|
-
else:
|
|
34
|
-
import importlib_metadata as metadata
|
|
12
|
+
from pymodaq.utils.config import get_set_preset_path
|
|
35
13
|
|
|
36
14
|
if version_mod.parse(platform.python_version()) >= version_mod.parse('3.9'):
|
|
37
15
|
# from version 3.9 the cache decorator is available
|
|
@@ -42,43 +20,9 @@ else:
|
|
|
42
20
|
|
|
43
21
|
logger = logger_module.set_logger(logger_module.get_module_name(__file__))
|
|
44
22
|
|
|
45
|
-
plot_colors = [(255, 255, 255), (255, 0, 0), (0, 255, 0), (0, 0, 255), (14, 207, 189), (207, 14, 166), (207, 204, 14)]
|
|
46
23
|
config = Config()
|
|
47
24
|
|
|
48
25
|
|
|
49
|
-
def is_64bits():
|
|
50
|
-
return sys.maxsize > 2**32
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
def timer(func):
|
|
54
|
-
"""Print the runtime of the decorated function"""
|
|
55
|
-
@functools.wraps(func)
|
|
56
|
-
def wrapper_timer(*args, **kwargs):
|
|
57
|
-
start_time = time.perf_counter() # 1
|
|
58
|
-
value = func(*args, **kwargs)
|
|
59
|
-
end_time = time.perf_counter() # 2
|
|
60
|
-
run_time = end_time - start_time # 3
|
|
61
|
-
print(f"Finished {func.__name__!r} in {run_time:.4f} secs")
|
|
62
|
-
return value
|
|
63
|
-
return wrapper_timer
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
def get_version():
|
|
67
|
-
"""Obtain pymodaq version from the VERSION file
|
|
68
|
-
|
|
69
|
-
Follows the layout from the packaging tool hatch, hatchling
|
|
70
|
-
"""
|
|
71
|
-
DEFAULT_PATTERN = r'(?i)^(__version__|VERSION) *= *([\'"])v?(?P<version>.+?)\2'
|
|
72
|
-
|
|
73
|
-
with open(str(Path(__file__).parent.parent.joinpath('resources/VERSION')), 'r') as fvers:
|
|
74
|
-
contents = fvers.read().strip()
|
|
75
|
-
match = re.search(DEFAULT_PATTERN, contents, flags=re.MULTILINE)
|
|
76
|
-
groups = match.groupdict()
|
|
77
|
-
if 'version' not in groups:
|
|
78
|
-
raise ValueError('no group named `version` was defined in the pattern')
|
|
79
|
-
return groups['version']
|
|
80
|
-
|
|
81
|
-
|
|
82
26
|
def copy_preset(): # pragma: no cover
|
|
83
27
|
path = get_set_preset_path().joinpath('preset_default.xml')
|
|
84
28
|
if not path.exists(): # copy the preset_default from pymodaq folder and create one in pymodad's local folder
|
|
@@ -86,469 +30,6 @@ def copy_preset(): # pragma: no cover
|
|
|
86
30
|
path.write_text(file.read())
|
|
87
31
|
|
|
88
32
|
|
|
89
|
-
def set_qt_backend():
|
|
90
|
-
backend_present = True
|
|
91
|
-
if config('qtbackend', 'backend').lower() not in [mod.lower() for mod in sys.modules]:
|
|
92
|
-
backend_present = False
|
|
93
|
-
logger.warning(f"The chosen Qt backend ({config('qtbackend', 'backend')}) has not been installed...\n"
|
|
94
|
-
f"Trying another...")
|
|
95
|
-
backends = config('qtbackend', 'backends')
|
|
96
|
-
backends.pop(config('qtbackend', 'backend'))
|
|
97
|
-
for backend in backends:
|
|
98
|
-
if backend.lower() in [mod.lower() for mod in sys.modules]:
|
|
99
|
-
backend_present = True
|
|
100
|
-
break
|
|
101
|
-
|
|
102
|
-
if backend_present:
|
|
103
|
-
os.environ['QT_API'] = config('qtbackend', 'backend')
|
|
104
|
-
logger.info('************************')
|
|
105
|
-
logger.info(f"{config('qtbackend', 'backend')} Qt backend loaded")
|
|
106
|
-
logger.info('************************')
|
|
107
|
-
else:
|
|
108
|
-
msg = f"No Qt backend could be found in your system, please install either pyqt5/6 or pyside2/6." \
|
|
109
|
-
f"pyqt5 is still preferred, while pyqt6 should mostly work."
|
|
110
|
-
logger.critical(msg)
|
|
111
|
-
warnings.warn(msg, FutureWarning, 3)
|
|
112
|
-
print(msg.upper())
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
class JsonConverter:
|
|
116
|
-
def __init__(self):
|
|
117
|
-
super().__init__()
|
|
118
|
-
|
|
119
|
-
@classmethod
|
|
120
|
-
def trusted_types(cls):
|
|
121
|
-
return ['float', 'int', 'str', 'datetime', 'date', 'time', 'tuple', 'list', 'bool', 'bytes',
|
|
122
|
-
'float64']
|
|
123
|
-
|
|
124
|
-
@classmethod
|
|
125
|
-
def istrusted(cls, type_name):
|
|
126
|
-
return type_name in cls.trusted_types()
|
|
127
|
-
|
|
128
|
-
@classmethod
|
|
129
|
-
def object2json(cls, obj):
|
|
130
|
-
dic = dict(module=type(obj).__module__, type=type(obj).__name__, data=repr(obj))
|
|
131
|
-
return json.dumps(dic)
|
|
132
|
-
|
|
133
|
-
@classmethod
|
|
134
|
-
def json2object(cls, jsonstring):
|
|
135
|
-
try:
|
|
136
|
-
dic = json.loads(jsonstring)
|
|
137
|
-
if isinstance(dic, dict):
|
|
138
|
-
if dic['type'] in cls.trusted_types():
|
|
139
|
-
return eval(dic['data'])
|
|
140
|
-
else:
|
|
141
|
-
return dic
|
|
142
|
-
else: # pragma: no cover
|
|
143
|
-
return dic
|
|
144
|
-
except Exception:
|
|
145
|
-
return jsonstring
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
def decode_data(encoded_data):
|
|
149
|
-
"""
|
|
150
|
-
Decode QbyteArrayData generated when drop items in table/tree/list view
|
|
151
|
-
Parameters
|
|
152
|
-
----------
|
|
153
|
-
encoded_data: QByteArray
|
|
154
|
-
Encoded data of the mime data to be dropped
|
|
155
|
-
Returns
|
|
156
|
-
-------
|
|
157
|
-
data: list
|
|
158
|
-
list of dict whose key is the QtRole in the Model, and the value a QVariant
|
|
159
|
-
|
|
160
|
-
"""
|
|
161
|
-
data = []
|
|
162
|
-
|
|
163
|
-
ds = QtCore.QDataStream(encoded_data, QtCore.QIODevice.ReadOnly)
|
|
164
|
-
while not ds.atEnd():
|
|
165
|
-
row = ds.readInt32()
|
|
166
|
-
col = ds.readInt32()
|
|
167
|
-
|
|
168
|
-
map_items = ds.readInt32()
|
|
169
|
-
item = {}
|
|
170
|
-
for ind in range(map_items):
|
|
171
|
-
key = ds.readInt32()
|
|
172
|
-
#TODO check this is fine
|
|
173
|
-
value = QVariant()
|
|
174
|
-
#value = None
|
|
175
|
-
ds >> value
|
|
176
|
-
item[QtCore.Qt.ItemDataRole(key)] = value.value()
|
|
177
|
-
data.append(item)
|
|
178
|
-
return data
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
#############################
|
|
182
|
-
|
|
183
|
-
def capitalize(string, Nfirst=1):
|
|
184
|
-
"""
|
|
185
|
-
Returns same string but with first Nfirst letters upper
|
|
186
|
-
Parameters
|
|
187
|
-
----------
|
|
188
|
-
string: (str)
|
|
189
|
-
Nfirst: (int)
|
|
190
|
-
Returns
|
|
191
|
-
-------
|
|
192
|
-
str
|
|
193
|
-
"""
|
|
194
|
-
return string[:Nfirst].upper() + string[Nfirst:]
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
def uncapitalize(string, Nfirst=1):
|
|
198
|
-
return string[:Nfirst].lower() + string[Nfirst:]
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
def getLineInfo():
|
|
202
|
-
"""get information about where the Exception has been triggered"""
|
|
203
|
-
tb = sys.exc_info()[2]
|
|
204
|
-
res = ''
|
|
205
|
-
for t in traceback.format_tb(tb):
|
|
206
|
-
res += t
|
|
207
|
-
return res
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
class ThreadCommand:
|
|
211
|
-
"""Generic object to pass info (command) and data (attribute) between thread or objects using signals
|
|
212
|
-
|
|
213
|
-
Parameters
|
|
214
|
-
----------
|
|
215
|
-
command: str
|
|
216
|
-
The command to be analysed for further action
|
|
217
|
-
attribute: any type
|
|
218
|
-
the attribute related to the command. The actual type and value depend on the command and the situation
|
|
219
|
-
attributes: deprecated, attribute should be used instead
|
|
220
|
-
|
|
221
|
-
Attributes
|
|
222
|
-
----------
|
|
223
|
-
command : str
|
|
224
|
-
The command to be analysed for further action
|
|
225
|
-
attribute : any type
|
|
226
|
-
the attribute related to the command. The actual type and value depend on the command and the situation
|
|
227
|
-
"""
|
|
228
|
-
|
|
229
|
-
def __init__(self, command: str, attribute=None, attributes=None):
|
|
230
|
-
if not isinstance(command, str):
|
|
231
|
-
raise TypeError(f'The command in a Threadcommand object should be a string, not a {type(command)}')
|
|
232
|
-
self.command = command
|
|
233
|
-
if attribute is None and attributes is not None:
|
|
234
|
-
deprecation_msg('ThreadCommand signature changed, use attribute in place of attributes')
|
|
235
|
-
self.attribute = attributes
|
|
236
|
-
self.attributes = attributes
|
|
237
|
-
self.attribute = attribute
|
|
238
|
-
|
|
239
|
-
def __repr__(self):
|
|
240
|
-
return f'Threadcommand: {self.command} with attribute {self.attribute}'
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
def ensure_ndarray(data):
|
|
244
|
-
"""
|
|
245
|
-
Make sure data is returned as a numpy array
|
|
246
|
-
Parameters
|
|
247
|
-
----------
|
|
248
|
-
data
|
|
249
|
-
|
|
250
|
-
Returns
|
|
251
|
-
-------
|
|
252
|
-
ndarray
|
|
253
|
-
"""
|
|
254
|
-
if not isinstance(data, np.ndarray):
|
|
255
|
-
if isinstance(data, list):
|
|
256
|
-
data = np.array(data)
|
|
257
|
-
else:
|
|
258
|
-
data = np.array([data])
|
|
259
|
-
return data
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
def setLocale():
|
|
263
|
-
"""
|
|
264
|
-
defines the Locale to use to convert numbers to strings representation using language/country conventions
|
|
265
|
-
Default is English and US
|
|
266
|
-
"""
|
|
267
|
-
language = getattr(QLocale, config('style', 'language'))
|
|
268
|
-
country = getattr(QLocale, config('style', 'country'))
|
|
269
|
-
QLocale.setDefault(QLocale(language, country))
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
def recursive_find_files_extension(ini_path, ext, paths=[]):
|
|
273
|
-
with os.scandir(ini_path) as it:
|
|
274
|
-
for entry in it:
|
|
275
|
-
if os.path.splitext(entry.name)[1][1:] == ext and entry.is_file():
|
|
276
|
-
paths.append(entry.path)
|
|
277
|
-
elif entry.is_dir():
|
|
278
|
-
recursive_find_files_extension(entry.path, ext, paths)
|
|
279
|
-
return paths
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
def recursive_find_files(ini_path, exp='make_enum', paths=[],
|
|
283
|
-
filters=['build']):
|
|
284
|
-
for child in Path(ini_path).iterdir():
|
|
285
|
-
if child.is_dir():
|
|
286
|
-
recursive_find_files(child, exp, paths, filters)
|
|
287
|
-
else:
|
|
288
|
-
if exp in child.stem:
|
|
289
|
-
if not any([filt in str(child) for filt in filters]):
|
|
290
|
-
paths.append(child)
|
|
291
|
-
return paths
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
def recursive_find_expr_in_files(ini_path, exp='make_enum', paths=[],
|
|
295
|
-
filters=['.git', '.idea', '__pycache__', 'build', 'egg', 'documentation', '.tox'],
|
|
296
|
-
replace=False, replace_str=''):
|
|
297
|
-
|
|
298
|
-
for child in Path(ini_path).iterdir():
|
|
299
|
-
if not any(filt in str(child) for filt in filters):
|
|
300
|
-
if child.is_dir():
|
|
301
|
-
recursive_find_expr_in_files(child, exp, paths, filters, replace=replace, replace_str=replace_str)
|
|
302
|
-
else:
|
|
303
|
-
try:
|
|
304
|
-
found = False
|
|
305
|
-
with child.open('r') as f:
|
|
306
|
-
replacement = ''
|
|
307
|
-
for ind, line in enumerate(f):
|
|
308
|
-
if exp in line:
|
|
309
|
-
found = True
|
|
310
|
-
paths.append([child, ind, line])
|
|
311
|
-
if replace:
|
|
312
|
-
replacement += line.replace(exp, replace_str)
|
|
313
|
-
else:
|
|
314
|
-
if replace:
|
|
315
|
-
replacement += line
|
|
316
|
-
if replace and found:
|
|
317
|
-
with child.open('w') as f:
|
|
318
|
-
f.write(replacement)
|
|
319
|
-
except Exception:
|
|
320
|
-
pass
|
|
321
|
-
return paths
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
def count_lines(ini_path, count=0, filters=['lextab', 'yacctab','pycache', 'pyc']):
|
|
325
|
-
# if Path(ini_path).is_file():
|
|
326
|
-
# with Path(ini_path).open('r') as f:
|
|
327
|
-
# count += len(f.readlines())
|
|
328
|
-
# return count
|
|
329
|
-
for child in Path(ini_path).iterdir():
|
|
330
|
-
if child.is_dir():
|
|
331
|
-
count = count_lines(child, count)
|
|
332
|
-
else:
|
|
333
|
-
try:
|
|
334
|
-
if not any([filt in child.name for filt in filters]):
|
|
335
|
-
if '.py' in child.name:
|
|
336
|
-
with child.open('r') as f:
|
|
337
|
-
count += len(f.readlines())
|
|
338
|
-
else:
|
|
339
|
-
print(child.stem)
|
|
340
|
-
except Exception:
|
|
341
|
-
pass
|
|
342
|
-
return count
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
def remove_spaces(string):
|
|
346
|
-
"""
|
|
347
|
-
return a string without any white spaces in it
|
|
348
|
-
Parameters
|
|
349
|
-
----------
|
|
350
|
-
string
|
|
351
|
-
|
|
352
|
-
Returns
|
|
353
|
-
-------
|
|
354
|
-
|
|
355
|
-
"""
|
|
356
|
-
return ''.join(string.split())
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
def rint(x):
|
|
360
|
-
"""
|
|
361
|
-
almost same as numpy rint function but return an integer
|
|
362
|
-
Parameters
|
|
363
|
-
----------
|
|
364
|
-
x: (float or integer)
|
|
365
|
-
|
|
366
|
-
Returns
|
|
367
|
-
-------
|
|
368
|
-
nearest integer
|
|
369
|
-
"""
|
|
370
|
-
return int(np.rint(x))
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
def elt_as_first_element(elt_list, match_word='Mock'):
|
|
374
|
-
if not hasattr(elt_list, '__iter__'):
|
|
375
|
-
raise TypeError('elt_list must be an iterable')
|
|
376
|
-
if elt_list:
|
|
377
|
-
ind_elt = 0
|
|
378
|
-
for ind, elt in enumerate(elt_list):
|
|
379
|
-
if not isinstance(elt, str):
|
|
380
|
-
raise TypeError('elt_list must be a list of str')
|
|
381
|
-
if match_word in elt:
|
|
382
|
-
ind_elt = ind
|
|
383
|
-
break
|
|
384
|
-
plugin_match = elt_list[ind_elt]
|
|
385
|
-
elt_list.remove(plugin_match)
|
|
386
|
-
plugins = [plugin_match]
|
|
387
|
-
plugins.extend(elt_list)
|
|
388
|
-
else:
|
|
389
|
-
plugins = []
|
|
390
|
-
return plugins
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
def elt_as_first_element_dicts(elt_list, match_word='Mock', key='name'):
|
|
394
|
-
if not hasattr(elt_list, '__iter__'):
|
|
395
|
-
raise TypeError('elt_list must be an iterable')
|
|
396
|
-
if elt_list:
|
|
397
|
-
ind_elt = 0
|
|
398
|
-
for ind, elt in enumerate(elt_list):
|
|
399
|
-
if not isinstance(elt, dict):
|
|
400
|
-
raise TypeError('elt_list must be a list of dicts')
|
|
401
|
-
if match_word in elt[key]:
|
|
402
|
-
ind_elt = ind
|
|
403
|
-
break
|
|
404
|
-
plugin_match = elt_list[ind_elt]
|
|
405
|
-
elt_list.remove(plugin_match)
|
|
406
|
-
plugins = [plugin_match]
|
|
407
|
-
plugins.extend(elt_list)
|
|
408
|
-
else:
|
|
409
|
-
plugins = []
|
|
410
|
-
return plugins
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
def find_keys_from_val(dict_tmp: dict, val: object):
|
|
414
|
-
"""Returns the keys from a dict if its value is matching val"""
|
|
415
|
-
return [k for k, v in dict_tmp.items() if v == val]
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
def find_object_if_matched_attr_name_val(obj, attr_name, attr_value):
|
|
419
|
-
"""check if an attribute key/value pair match in a given object
|
|
420
|
-
|
|
421
|
-
Parameters
|
|
422
|
-
----------
|
|
423
|
-
obj: object
|
|
424
|
-
attr_name: str
|
|
425
|
-
attribute name to look for in the object
|
|
426
|
-
attr_value: object
|
|
427
|
-
value to match
|
|
428
|
-
|
|
429
|
-
Returns
|
|
430
|
-
-------
|
|
431
|
-
bool: True if the key/value pair has been found in dict_tmp
|
|
432
|
-
|
|
433
|
-
"""
|
|
434
|
-
if hasattr(obj, attr_name):
|
|
435
|
-
if getattr(obj, attr_name) == attr_value:
|
|
436
|
-
return True
|
|
437
|
-
return False
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
def find_objects_in_list_from_attr_name_val(objects: List[object], attr_name: str,
|
|
441
|
-
attr_value: object, return_first=True):
|
|
442
|
-
""" lookup within a list of objects. Look for the objects within the list which has the correct attribute name,
|
|
443
|
-
value pair
|
|
444
|
-
|
|
445
|
-
Parameters
|
|
446
|
-
----------
|
|
447
|
-
objects: list
|
|
448
|
-
list of objects
|
|
449
|
-
attr_name: str
|
|
450
|
-
attribute name to look for in the object
|
|
451
|
-
attr_value: object
|
|
452
|
-
value to match
|
|
453
|
-
return_first: bool
|
|
454
|
-
if True return the first objects found in the list else all the objects matching
|
|
455
|
-
|
|
456
|
-
Returns
|
|
457
|
-
-------
|
|
458
|
-
list of tuple(object, int): object and index or list of object and indexes
|
|
459
|
-
"""
|
|
460
|
-
selection = []
|
|
461
|
-
obj = None
|
|
462
|
-
for ind, obj_tmp in enumerate(objects):
|
|
463
|
-
if find_object_if_matched_attr_name_val(obj_tmp, attr_name, attr_value):
|
|
464
|
-
obj = obj_tmp
|
|
465
|
-
if return_first:
|
|
466
|
-
break
|
|
467
|
-
else:
|
|
468
|
-
selection.append((obj_tmp, ind))
|
|
469
|
-
|
|
470
|
-
if obj is None:
|
|
471
|
-
if return_first:
|
|
472
|
-
return None, -1
|
|
473
|
-
else:
|
|
474
|
-
return []
|
|
475
|
-
else:
|
|
476
|
-
if return_first:
|
|
477
|
-
return obj, ind
|
|
478
|
-
else:
|
|
479
|
-
return selection
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
def find_dict_if_matched_key_val(dict_tmp, key, value):
|
|
483
|
-
"""
|
|
484
|
-
check if a key/value pair match in a given dictionnary
|
|
485
|
-
Parameters
|
|
486
|
-
----------
|
|
487
|
-
dict_tmp: (dict) the dictionnary to be tested
|
|
488
|
-
key: (str) a key string to look for in dict_tmp
|
|
489
|
-
value: (object) any python object
|
|
490
|
-
|
|
491
|
-
Returns
|
|
492
|
-
-------
|
|
493
|
-
bool: True if the key/value pair has been found in dict_tmp
|
|
494
|
-
|
|
495
|
-
"""
|
|
496
|
-
if key in dict_tmp:
|
|
497
|
-
if dict_tmp[key] == value:
|
|
498
|
-
return True
|
|
499
|
-
return False
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
def find_dict_in_list_from_key_val(dicts, key, value, return_index=False):
|
|
503
|
-
""" lookup within a list of dicts. Look for the dict within the list which has the correct key, value pair
|
|
504
|
-
|
|
505
|
-
Parameters
|
|
506
|
-
----------
|
|
507
|
-
dicts: (list) list of dictionnaries
|
|
508
|
-
key: (str) specific key to look for in each dict
|
|
509
|
-
value: value to match
|
|
510
|
-
|
|
511
|
-
Returns
|
|
512
|
-
-------
|
|
513
|
-
dict: if found otherwise returns None
|
|
514
|
-
"""
|
|
515
|
-
for ind, dict_tmp in enumerate(dicts):
|
|
516
|
-
if find_dict_if_matched_key_val(dict_tmp, key, value):
|
|
517
|
-
if return_index:
|
|
518
|
-
return dict_tmp, ind
|
|
519
|
-
else:
|
|
520
|
-
return dict_tmp
|
|
521
|
-
if return_index:
|
|
522
|
-
return None, -1
|
|
523
|
-
else:
|
|
524
|
-
return None
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
def get_entrypoints(group='pymodaq.plugins') -> List[metadata.EntryPoint]:
|
|
528
|
-
""" Get the list of modules defined from a group entry point
|
|
529
|
-
|
|
530
|
-
Because of evolution in the package, one or another of the forms below may be deprecated.
|
|
531
|
-
We start from the newer way down to the older
|
|
532
|
-
|
|
533
|
-
Parameters
|
|
534
|
-
----------
|
|
535
|
-
group: str
|
|
536
|
-
the name of the group
|
|
537
|
-
"""
|
|
538
|
-
try:
|
|
539
|
-
discovered_entrypoints = metadata.entry_points(group=group)
|
|
540
|
-
except TypeError:
|
|
541
|
-
try:
|
|
542
|
-
discovered_entrypoints = metadata.entry_points().select(group=group)
|
|
543
|
-
except AttributeError:
|
|
544
|
-
discovered_entrypoints = metadata.entry_points().get(group, [])
|
|
545
|
-
if isinstance(discovered_entrypoints, tuple): # API for python > 3.8
|
|
546
|
-
discovered_entrypoints = list(discovered_entrypoints)
|
|
547
|
-
if not isinstance(discovered_entrypoints, list):
|
|
548
|
-
discovered_entrypoints = list(discovered_entrypoints)
|
|
549
|
-
return discovered_entrypoints
|
|
550
|
-
|
|
551
|
-
|
|
552
33
|
@cache
|
|
553
34
|
def get_instrument_plugins(): # pragma: no cover
|
|
554
35
|
"""
|
|
@@ -658,142 +139,3 @@ def get_plugins(plugin_type='daq_0Dviewer'): # pragma: no cover
|
|
|
658
139
|
"""
|
|
659
140
|
return [plug for plug in get_instrument_plugins() if plug['type'] == plugin_type]
|
|
660
141
|
|
|
661
|
-
|
|
662
|
-
def check_vals_in_iterable(iterable1, iterable2):
|
|
663
|
-
assert len(iterable1) == len(iterable2)
|
|
664
|
-
iterable1 = list(iterable1) # so the assertion below is valid for any kind of iterable, list, tuple, ndarray...
|
|
665
|
-
iterable2 = list(iterable2)
|
|
666
|
-
for val1, val2 in zip(iterable1, iterable2):
|
|
667
|
-
assert val1 == val2
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
def caller_name(skip=2):
|
|
671
|
-
"""Get a name of a caller in the format module.class.method
|
|
672
|
-
|
|
673
|
-
`skip` specifies how many levels of stack to skip while getting caller
|
|
674
|
-
name. skip=1 means "who calls me", skip=2 "who calls my caller" etc.
|
|
675
|
-
|
|
676
|
-
An empty string is returned if skipped levels exceed stack height
|
|
677
|
-
"""
|
|
678
|
-
stack = inspect.stack()
|
|
679
|
-
start = 0 + skip
|
|
680
|
-
if len(stack) < start + 1:
|
|
681
|
-
return ''
|
|
682
|
-
parentframe = stack[start][0]
|
|
683
|
-
|
|
684
|
-
name = []
|
|
685
|
-
module = inspect.getmodule(parentframe)
|
|
686
|
-
# `modname` can be None when frame is executed directly in console
|
|
687
|
-
# TODO(techtonik): consider using __main__
|
|
688
|
-
if module:
|
|
689
|
-
name.append(module.__name__)
|
|
690
|
-
# detect classname
|
|
691
|
-
if 'self' in parentframe.f_locals:
|
|
692
|
-
# I don't know any way to detect call from the object method
|
|
693
|
-
# XXX: there seems to be no way to detect static method call - it will
|
|
694
|
-
# be just a function call
|
|
695
|
-
name.append(parentframe.f_locals['self'].__class__.__name__)
|
|
696
|
-
codename = parentframe.f_code.co_name
|
|
697
|
-
if codename != '<module>': # top level usually
|
|
698
|
-
name.append(codename) # function or a method
|
|
699
|
-
del parentframe
|
|
700
|
-
return ".".join(name)
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
def zeros_aligned(n, align, dtype=np.uint32):
|
|
704
|
-
"""
|
|
705
|
-
Get aligned memory array wih alignment align.
|
|
706
|
-
Parameters
|
|
707
|
-
----------
|
|
708
|
-
n: (int) length in dtype bytes of memory
|
|
709
|
-
align: (int) memory alignment
|
|
710
|
-
dtype: (numpy.dtype) type of the stored memory elements
|
|
711
|
-
|
|
712
|
-
Returns
|
|
713
|
-
-------
|
|
714
|
-
|
|
715
|
-
"""
|
|
716
|
-
dtype = np.dtype(dtype)
|
|
717
|
-
nbytes = n * dtype.itemsize
|
|
718
|
-
buff = np.zeros(nbytes + align, dtype=np.uint8)
|
|
719
|
-
start_index = -buff.ctypes.data % align
|
|
720
|
-
return buff[start_index:start_index + nbytes].view(dtype)
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
# ########################
|
|
724
|
-
# #File management
|
|
725
|
-
|
|
726
|
-
def get_new_file_name(base_path=Path(config('data_saving', 'h5file', 'save_path')), base_name='tttr_data'):
|
|
727
|
-
if isinstance(base_path, str):
|
|
728
|
-
base_path = Path(base_path)
|
|
729
|
-
|
|
730
|
-
today = datetime.datetime.now()
|
|
731
|
-
|
|
732
|
-
date = today.strftime('%Y%m%d')
|
|
733
|
-
year = today.strftime('%Y')
|
|
734
|
-
year_dir = base_path.joinpath(year)
|
|
735
|
-
if not year_dir.is_dir():
|
|
736
|
-
year_dir.mkdir()
|
|
737
|
-
curr_dir = base_path.joinpath(year, date)
|
|
738
|
-
if not curr_dir.is_dir():
|
|
739
|
-
curr_dir.mkdir()
|
|
740
|
-
|
|
741
|
-
files = []
|
|
742
|
-
for entry in curr_dir.iterdir():
|
|
743
|
-
if entry.name.startswith(base_name) and entry.is_file():
|
|
744
|
-
files.append(entry.stem)
|
|
745
|
-
files.sort()
|
|
746
|
-
if not files:
|
|
747
|
-
index = 0
|
|
748
|
-
else:
|
|
749
|
-
index = int(files[-1][-3:]) + 1
|
|
750
|
-
|
|
751
|
-
file = f'{base_name}_{index:03d}'
|
|
752
|
-
return file, curr_dir
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
if __name__ == '__main__':
|
|
756
|
-
#paths = recursive_find_expr_in_files('C:\\Users\\weber\\Labo\\Programmes Python\\PyMoDAQ_Git', 'visa')
|
|
757
|
-
# for p in paths:
|
|
758
|
-
# print(str(p))
|
|
759
|
-
# v = get_version()
|
|
760
|
-
# pass
|
|
761
|
-
#plugins = get_plugins() # pragma: no cover
|
|
762
|
-
#extensions = get_extension()
|
|
763
|
-
#models = get_models()
|
|
764
|
-
#count = count_lines('C:\\Users\\weber\\Labo\\Programmes Python\\PyMoDAQ_Git\\pymodaq\src')
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
# import license
|
|
768
|
-
# mit = license.find('MIT')
|
|
769
|
-
#
|
|
770
|
-
|
|
771
|
-
# paths = recursive_find_expr_in_files(r'C:\Users\weber\Labo\Programmes Python\PyMoDAQ_Git',
|
|
772
|
-
# exp="cfunc",
|
|
773
|
-
# paths=[],
|
|
774
|
-
# filters=['.git', '.idea', '__pycache__', 'build', 'egg', 'documentation',
|
|
775
|
-
# '.tox',],
|
|
776
|
-
# replace=False,
|
|
777
|
-
# replace_str="pymodaq.utils")
|
|
778
|
-
|
|
779
|
-
#get_version()
|
|
780
|
-
get_instrument_plugins()
|
|
781
|
-
#get_plugins('daq_move')
|
|
782
|
-
#get_plugins('daq_0Dviewer')
|
|
783
|
-
pass
|
|
784
|
-
|
|
785
|
-
# paths = recursive_find_files('C:\\Users\\weber\\Labo\\Programmes Python\\PyMoDAQ_Git',
|
|
786
|
-
# exp='VERSION', paths=[])
|
|
787
|
-
# import version
|
|
788
|
-
# for file in paths:
|
|
789
|
-
# with open(str(file), 'r') as f:
|
|
790
|
-
# v = version.Version(f.read())
|
|
791
|
-
# v.minor += 1
|
|
792
|
-
# v.patch = 0
|
|
793
|
-
# with open(str(file), 'w') as f:
|
|
794
|
-
# f.write(str(v))
|
|
795
|
-
|
|
796
|
-
# for file in paths:
|
|
797
|
-
# with open(str(file), 'w') as f:
|
|
798
|
-
# f.write(mit.render(name='Sebastien Weber', email='sebastien.weber@cemes.fr'))
|
|
799
|
-
|