Skip to content

Commit

Permalink
Expand backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
viljarjf committed Nov 7, 2024
1 parent 3f68f1e commit bcd687f
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 17 deletions.
3 changes: 3 additions & 0 deletions src/instamatic/TEMController/TEMController.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from __future__ import annotations

from instamatic.controller import TEMController
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ruff: noqa: E402
from __future__ import annotations

# ruff: noqa: E402
import warnings

from instamatic.utils.deprecated import VisibleDeprecationWarning, deprecated
Expand All @@ -10,6 +10,7 @@
VisibleDeprecationWarning,
)


from instamatic.controller import get_instance, initialize
from instamatic.microscope.base import MicroscopeBase

Expand All @@ -19,10 +20,3 @@ def Microscope(name: str = None, use_server: bool = False) -> MicroscopeBase:
from instamatic.microscope import get_microscope

return get_microscope(name=name, use_server=use_server)


@deprecated(since='2.0.6', alternative='instamatic.microscope.get_microscope_class')
def get_tem(interface: str) -> 'type[MicroscopeBase]':
from instamatic.microscope import get_microscope_class

return get_microscope_class(interface=interface)
10 changes: 10 additions & 0 deletions src/instamatic/TEMController/microscope.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from __future__ import annotations

from instamatic.utils.deprecated import deprecated


@deprecated(since='2.0.6', alternative='instamatic.microscope.get_microscope_class')
def get_tem(interface: str) -> 'type[MicroscopeBase]':
from instamatic.microscope import get_microscope_class

return get_microscope_class(interface=interface)
3 changes: 3 additions & 0 deletions src/instamatic/TEMController/microscope_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from __future__ import annotations

from instamatic.microscope.client import MicroscopeClient
6 changes: 3 additions & 3 deletions src/instamatic/config/autoconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ def main():
cam_name = None

from instamatic.camera.camera import get_cam
from instamatic.controller import TEMController
from instamatic.microscope.microscope import get_microscope_class
from instamatic.TEMController.microscope import get_tem
from instamatic.TEMController.TEMController import TEMController

if cam_connect:
cam = get_cam(cam_name)() if cam_name else None
else:
cam = None

tem = get_microscope_class(tem_name)()
tem = get_tem(tem_name)()

ctrl = TEMController(tem=tem, cam=cam)

Expand Down
2 changes: 1 addition & 1 deletion src/instamatic/server/tem_client.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from instamatic import config
from instamatic.microscope.client import MicroscopeClient
from instamatic.TEMController.microscope_client import MicroscopeClient

microscope_id = config.microscope.name

Expand Down
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# Actually importing the controller class breaks the tests
if TYPE_CHECKING:
from instamatic.controller import TEMController
from instamatic.TEMController.TEMController import TEMController


base_drc = Path(__file__).parent
Expand All @@ -21,9 +21,9 @@ def pytest_configure():

@pytest.fixture(scope='module')
def ctrl() -> 'TEMController':
from instamatic import controller
from instamatic import TEMController

ctrl = controller.initialize()
ctrl = TEMController.initialize()

# set instant stage movement for testing
ctrl.tem._set_instant_stage_movement()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_ctrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@


def test_setup(ctrl):
from instamatic import controller
from instamatic import TEMController

ctrl2 = controller.get_instance()
ctrl2 = TEMController.get_instance()
assert ctrl2 is ctrl


Expand Down

0 comments on commit bcd687f

Please sign in to comment.