|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | 3 | from abc import ABC, abstractmethod |
4 | | -from typing import List, Tuple |
| 4 | +from typing import List, Optional, Tuple |
5 | 5 |
|
6 | | -from numpy import ndarray |
| 6 | +import numpy as np |
7 | 7 |
|
8 | 8 | from instamatic import config |
9 | 9 |
|
@@ -37,33 +37,45 @@ def release_connection(self): |
37 | 37 | pass |
38 | 38 |
|
39 | 39 | @abstractmethod |
40 | | - def get_image(self, exposure: float = None, binsize: int = None, **kwargs) -> ndarray: |
| 40 | + def get_image( |
| 41 | + self, |
| 42 | + exposure: Optional[float] = None, |
| 43 | + binsize: Optional[int] = None, |
| 44 | + **kwargs, |
| 45 | + ) -> np.ndarray: |
41 | 46 | pass |
42 | 47 |
|
43 | 48 | def get_movie( |
44 | | - self, n_frames: int, exposure: float = None, binsize: int = None, **kwargs |
45 | | - ) -> List[ndarray]: |
| 49 | + self, |
| 50 | + n_frames: int, |
| 51 | + exposure: Optional[float] = None, |
| 52 | + binsize: Optional[int] = None, |
| 53 | + **kwargs, |
| 54 | + ) -> List[np.ndarray]: |
46 | 55 | """Basic implementation, subclasses should override with appropriate |
47 | 56 | optimization.""" |
48 | 57 | return [ |
49 | 58 | self.get_image(exposure=exposure, binsize=binsize, **kwargs) |
50 | 59 | for _ in range(n_frames) |
51 | 60 | ] |
52 | 61 |
|
53 | | - def __enter__(self): |
| 62 | + def __enter__(self) -> CameraBase: |
54 | 63 | self.establish_connection() |
55 | 64 | return self |
56 | 65 |
|
57 | | - def __exit__(self, kind, value, traceback): |
| 66 | + def __exit__(self, kind, value, traceback) -> None: |
58 | 67 | self.release_connection() |
59 | 68 |
|
| 69 | + def get_binning(self) -> int: |
| 70 | + return self.default_binsize |
| 71 | + |
60 | 72 | def get_camera_dimensions(self) -> Tuple[int, int]: |
61 | 73 | return self.dimensions |
62 | 74 |
|
63 | 75 | def get_name(self) -> str: |
64 | 76 | return self.name |
65 | 77 |
|
66 | | - def load_defaults(self): |
| 78 | + def load_defaults(self) -> None: |
67 | 79 | if self.name != config.settings.camera: |
68 | 80 | config.load_camera_config(camera_name=self.name) |
69 | 81 | for key, val in config.camera.mapping.items(): |
|
0 commit comments