Coder Social home page Coder Social logo

benediktburger / pymeasure Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pymeasure/pymeasure

0.0 0.0 0.0 8.1 MB

Scientific measurement library for instruments, experiments, and live-plotting

Home Page: http://pymeasure.readthedocs.io/en/latest/

License: MIT License

Python 100.00%

pymeasure's People

Contributors

ashokbruno avatar benediktburger avatar bilderbuchi avatar bleykauf avatar casperschippers avatar cjermain avatar cm-dynamic avatar codingmarco avatar daivesd avatar dennisfeng2 avatar dkriegner avatar fwutw avatar grahamrow avatar jmittelstaedt avatar laststardust avatar longnoserob avatar maederan201 avatar mcdo0486 avatar md12g12 avatar minhhaiphys avatar moritzj29 avatar mroeleke avatar msmttchr avatar neuschs avatar optimisticbeliever avatar robert-demcon avatar samcondon4 avatar sansanda avatar seb5g avatar stephanino avatar

Watchers

 avatar

pymeasure's Issues

Adapter rework ideas and notes

Ideas and notes about Adapter rework.

Phases

  1. Adding tests for instruments
  2. Reworking official adapters, Instrument class and adjust tests, documentation, and all instruments to these changes. (not here)
  3. Add a Test Generator
  4. Rework some adapters proper to some instruments and maybe some official adapters

Open questions

Adapter rework

General

  • Include a test generator which generates tests out of device communication (code written)
  • Test generator documentation
  • add a BaseChannel with dynamic properties (initial code written)
  • Instrument may ask in the setter instead of write only (initial code written)
  • Make a SCPI Instrument?

Instruments and special adapters

Special Adapters move, if possible, to default adapters

  • attocube and anc300 pymeasure#835
  • danfysik and danfysik8500: should be removable, verify, that it works as expected.
  • lakeshore: could be moved to pyvisa, I guess (code written)
  • Oxford Adapter: move it to its own superclass between Instrument and the specific instrument itself.
  • Toptica: move to instrument itself. (code already written. For new PR)
  • Remove these instruments from the "test_all_instruments" exception for proper adapters.

Test special adapters change

  • attocube
  • danfysik
  • lakeshore
  • Oxford
  • Toptica

Test Generator

  • handle testing several times the same property/setter but with different values: keep the same name (what does pytest do?) or numerate them? Possibility to give a list of values to test for a parametrized test?
  • handle the byte value b"\n" correctly

Instruments overhaul

  • TC038D move to pymeasure properties (code written)

Clean up

Issues and discussions

feedback on generator for instrument tests

As mentioned in pymeasure#752 I tried pymeasure/tests/generator.py with the HP3478A multimeter conencted by GPIB.
The file I used for creating the tests is TG_HP3478A.txt
the result file is test_hp3478a.txt
As is now with some lines commented-out works and pytest passes without issues.

Items noted:

  1. the test-file is opened but not automatically written if following your example. to get it working in my spyder-IDE, I added the line 57 g.__del__() (The lines following are only to properly close the log)
  2. test_method() does not work on calls with methods which does not return anything or only return a non-callable
  • example 1 (method without return value): g.test_method("display_text", "ABCDEFGHIJKL") will trhow a LookupError:
    11:50:49 AM: Test method display_text. (generator, INFO)
    []
    [b'WRITE:B\n', b'READ:\xc5\x1f\x00\x00%\n']
    Traceback (most recent call last):
    
      File /usr/lib/python3.10/site-packages/spyder_kernels/py3compat.py:356 in compat_exec
        exec(code, globals, locals)
    
      File ~/builds/pymeasure/tests/TG_HP3478A.py:27
        g.test_method("display_text", "ABCDEFGHIJKL")
    
      File ~/builds/pymeasure/tests/generator.py:195 in test_method
        value = getattr(self.instr, method)(*args, **kwargs)
    
      File ~/builds/pymeasure/pymeasure/instruments/instrument.py:211 in __getattribute__
        return super().__getattribute__(name)
    
      File ~/builds/pymeasure/pymeasure/instruments/instrument.py:429 in fget
        raise LookupError("Instrument property can not be read.")
    
    LookupError: Instrument property can not be read.
    
  • example 2 (method with non-callable return): g.test_method("measure_ACI")will throw the following TypeError:
    11:45:07 AM: Test method measure_ACI. (generator, INFO)
    11:45:07 AM: WRITE:F6 (Adapter, DEBUG)
    11:45:07 AM: GPIB.write b'F6\r\n' (pyvisa, DEBUG)
    11:45:07 AM: GPIB0::23::INSTR - reading 20480 bytes (last status <StatusCode.success_max_count_read: 1073676294>) (pyvisa, DEBUG)
    []
    [b'WRITE:B\n', b'READ:-\x1f\x00\x00%\n']
    11:45:10 AM: READ:+000.425E-3
     (Adapter, DEBUG)
    Traceback (most recent call last):
    
      File /usr/lib/python3.10/site-packages/spyder_kernels/py3compat.py:356 in compat_exec
        exec(code, globals, locals)
    
      File ~/builds/pymeasure/tests/TG_HP3478A.py:29
        g.test_method("measure_ACI")
    
      File ~/builds/pymeasure/tests/generator.py:195 in test_method
        value = getattr(self.instr, method)(*args, **kwargs)
    
    TypeError: 'float' object is not callable
    
  • other methods (like hp3478a.reset(), .GPIB_trigger fail because of the use of calls to adapter.-methods (Corner case for non-SCPI instruments?)
  1. Would it be possible and make sense to implement something like
    g.test_property_setter(bool_property, [True, False]) or
    g.test_property_setter(numerical_property, [0, 1, 2 .71, 3.14, 6.28, 23, 42] ?
    Or did I just overlook something and this is already possible?
  2. flake8 has some feedback on test_hp3478a.py:
$ flake8 test_hp3478a.py 
test_hp3478a.py:26:41: E712 comparison to True should be 'if cond is True:' or 'if cond:'
test_hp3478a.py:34:40: E712 comparison to True should be 'if cond is True:' or 'if cond:'
test_hp3478a.py:45:1: F811 redefinition of unused 'test_auto_zero_enabled_setter' from line 37
test_hp3478a.py:58:42: E712 comparison to False should be 'if cond is False:' or 'if not cond:'
test_hp3478a.py:74:38: E711 comparison to None should be 'if cond is None:'

Good work and please let me know if you need further details or want me to try other things.

Ideas for the Test Generator

Agenda

  • Improve (see below)
  • write documentation

Ideas / issues

  • handle testing several times the same property/setter but with different values: keep the same name (what does pytest do?) or numerate them? Possibility to give a list of values to test for a parametrized test?
  • handle the byte value b"\n" correctly
  • see #3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.