moonshot-nagayama-pj / PnPQ

Python package for Controlling Optical Devices in Quantum Testbed
Other
0 stars 0 forks source link

Clean up package init #50

Closed auspicacious closed 1 month ago

auspicacious commented 1 month ago

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 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:

Tested by running unit tests and the example.py script.

auspicacious commented 1 month ago

@hhatpsi I'm going to merge this, but we can continue the discussion about utils if necessary.