This code may require refactoring of any other code using PnPQ, depending on how it was importing PnPQ classes. It is likely that more refactoring will eventually follow these changes.
The __init__ files were being used to expose some of the device implementation classes as members of pnpq, and, confusingly, sometimes, also pnpq.devices.
By removing the import statements and __all__ variables from __init__.py, we ensure that by default nothing will be imported into any module that calls import pnpq or from pnpq import *.
Instead, we should simply use fully-qualified imports, such as from pnpq.devices.waveplate_stub import WaveplateStub.
I also found and fixed a few other things along the way.
Full list of changes:
pnpq.utils has been deleted. It duplicated the functionality in pnpq.devices.utils and appears to be unused.
Unit tests have been renamed to begin with test_ rather than end with _test. This follows common pytest form.
Very basic unit tests have been added for all device modules and the utils module. These tests only validate that when no device is physically connected, an exception is thrown.
The __version__ variable now works. See changes in pyproject.toml.
An issue in optical_delay_line where a non-existent serial module was being referenced is fixed.
Tested by running unit tests and the example.py script.
This code may require refactoring of any other code using PnPQ, depending on how it was
import
ing PnPQ classes. It is likely that more refactoring will eventually follow these changes.The
__init__
files were being used to expose some of the device implementation classes as members ofpnpq
, and, confusingly, sometimes, alsopnpq.devices
.By removing the
import
statements and__all__
variables from__init__.py
, we ensure that by default nothing will be imported into any module that callsimport pnpq
orfrom pnpq import *
.Instead, we should simply use fully-qualified imports, such as
from pnpq.devices.waveplate_stub import WaveplateStub
.I think that this is in line with the advice in the Python tutorial, and it makes the code structure much easier to understand.
I also found and fixed a few other things along the way.
Full list of changes:
pnpq.utils
has been deleted. It duplicated the functionality inpnpq.devices.utils
and appears to be unused.test_
rather than end with_test
. This follows common pytest form.__version__
variable now works. See changes inpyproject.toml
.optical_delay_line
where a non-existentserial
module was being referenced is fixed.Tested by running unit tests and the
example.py
script.