Start fixing some issues found by MyPy
This commit is contained in:
parent
ff976e7187
commit
99f3d2d311
4 changed files with 99 additions and 57 deletions
|
|
@ -20,7 +20,6 @@ from typing import Any, Literal, Mapping, Optional, Tuple
|
|||
import numpy as np
|
||||
import piexif
|
||||
from PIL import Image
|
||||
from pydantic import RootModel
|
||||
|
||||
import labthings_fastapi as lt
|
||||
from labthings_fastapi.types.numpy import NDArray
|
||||
|
|
@ -46,12 +45,6 @@ class PNGBlob(lt.blob.Blob):
|
|||
media_type: str = "image/png"
|
||||
|
||||
|
||||
class ArrayModel(RootModel):
|
||||
"""A model for an array."""
|
||||
|
||||
root: NDArray
|
||||
|
||||
|
||||
class CaptureError(RuntimeError):
|
||||
"""An error trying to capture from a CameraThing."""
|
||||
|
||||
|
|
@ -255,7 +248,7 @@ class BaseCamera(lt.Thing):
|
|||
self,
|
||||
stream_name: Literal["main", "lores", "raw", "full"] = "main",
|
||||
wait: Optional[float] = 5,
|
||||
) -> ArrayModel:
|
||||
) -> NDArray:
|
||||
"""Acquire one image from the camera and return as an array."""
|
||||
raise NotImplementedError(
|
||||
"CameraThings must define their own capture_array method"
|
||||
|
|
@ -265,7 +258,7 @@ class BaseCamera(lt.Thing):
|
|||
"""The downsampling factor when calling capture_downsampled_array."""
|
||||
|
||||
@lt.action
|
||||
def capture_downsampled_array(self) -> ArrayModel:
|
||||
def capture_downsampled_array(self) -> NDArray:
|
||||
"""Acquire one image from the camera, downsample, and return as an array.
|
||||
|
||||
* The array is downsamples by the thing property `downsampled_array_factor`.
|
||||
|
|
@ -334,7 +327,7 @@ class BaseCamera(lt.Thing):
|
|||
def grab_as_array(
|
||||
self,
|
||||
stream_name: Literal["main", "lores"] = "main",
|
||||
) -> ArrayModel:
|
||||
) -> NDArray:
|
||||
"""Acquire one image from the preview stream and return as an array.
|
||||
|
||||
It works like ``grab_jpeg`` but reliably handles broken streams. Prefer using
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ from pydantic import BaseModel, BeforeValidator
|
|||
|
||||
import labthings_fastapi as lt
|
||||
from labthings_fastapi.exceptions import ServerNotRunningError
|
||||
from labthings_fastapi.types.numpy import NDArray
|
||||
|
||||
from openflexure_microscope_server.background_detect import ChannelBlankError
|
||||
from openflexure_microscope_server.ui import (
|
||||
|
|
@ -45,7 +46,7 @@ from openflexure_microscope_server.ui import (
|
|||
property_control_for,
|
||||
)
|
||||
|
||||
from . import ArrayModel, BaseCamera
|
||||
from . import BaseCamera
|
||||
from . import picamera_recalibrate_utils as recalibrate_utils
|
||||
from . import picamera_tuning_file_utils as tf_utils
|
||||
|
||||
|
|
@ -573,7 +574,7 @@ class StreamingPiCamera2(BaseCamera):
|
|||
self,
|
||||
stream_name: Literal["main", "lores", "raw", "full"] = "main",
|
||||
wait: Optional[float] = 0.9,
|
||||
) -> ArrayModel:
|
||||
) -> NDArray:
|
||||
"""Acquire one image from the camera and return as an array.
|
||||
|
||||
This function will produce a nested list containing an uncompressed RGB image.
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import numpy as np
|
|||
from PIL import Image, ImageFilter
|
||||
|
||||
import labthings_fastapi as lt
|
||||
from labthings_fastapi.types.numpy import NDArray
|
||||
|
||||
from openflexure_microscope_server.ui import (
|
||||
ActionButton,
|
||||
|
|
@ -28,7 +29,7 @@ from openflexure_microscope_server.ui import (
|
|||
)
|
||||
|
||||
from ..stage.dummy import DummyStage
|
||||
from . import ArrayModel, BaseCamera
|
||||
from . import BaseCamera
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -317,7 +318,7 @@ class SimulatedCamera(BaseCamera):
|
|||
self,
|
||||
stream_name: Literal["main", "full"] = "full",
|
||||
wait: Optional[float] = None,
|
||||
) -> ArrayModel:
|
||||
) -> NDArray:
|
||||
"""Acquire one image from the camera and return as an array.
|
||||
|
||||
This function will produce a nested list containing an uncompressed RGB image.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue