pyobs-asi 2.0.0.dev4__tar.gz → 2.0.0.dev5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyobs_asi-2.0.0.dev5/.github/dependabot.yml +15 -0
- pyobs_asi-2.0.0.dev5/.github/workflows/pyrefly.yml +23 -0
- pyobs_asi-2.0.0.dev5/.github/workflows/pytest.yml +25 -0
- {pyobs_asi-2.0.0.dev4 → pyobs_asi-2.0.0.dev5}/PKG-INFO +4 -4
- {pyobs_asi-2.0.0.dev4 → pyobs_asi-2.0.0.dev5}/pyobs_asi/asicamera.py +2 -1
- {pyobs_asi-2.0.0.dev4 → pyobs_asi-2.0.0.dev5}/pyproject.toml +10 -4
- pyobs_asi-2.0.0.dev5/tests/test_asicamera.py +145 -0
- pyobs_asi-2.0.0.dev5/tests/test_import.py +27 -0
- pyobs_asi-2.0.0.dev5/uv.lock +3160 -0
- pyobs_asi-2.0.0.dev4/uv.lock +0 -2700
- {pyobs_asi-2.0.0.dev4 → pyobs_asi-2.0.0.dev5}/.github/workflows/pypi.yml +0 -0
- {pyobs_asi-2.0.0.dev4 → pyobs_asi-2.0.0.dev5}/.github/workflows/ruff.yml +0 -0
- {pyobs_asi-2.0.0.dev4 → pyobs_asi-2.0.0.dev5}/.pre-commit-config.yaml +0 -0
- {pyobs_asi-2.0.0.dev4 → pyobs_asi-2.0.0.dev5}/.readthedocs.yml +0 -0
- {pyobs_asi-2.0.0.dev4 → pyobs_asi-2.0.0.dev5}/CHANGELOG.rst +0 -0
- {pyobs_asi-2.0.0.dev4 → pyobs_asi-2.0.0.dev5}/LICENSE +0 -0
- {pyobs_asi-2.0.0.dev4 → pyobs_asi-2.0.0.dev5}/README.md +0 -0
- {pyobs_asi-2.0.0.dev4 → pyobs_asi-2.0.0.dev5}/docs/Makefile +0 -0
- {pyobs_asi-2.0.0.dev4 → pyobs_asi-2.0.0.dev5}/docs/make.bat +0 -0
- {pyobs_asi-2.0.0.dev4 → pyobs_asi-2.0.0.dev5}/docs/requirements.txt +0 -0
- {pyobs_asi-2.0.0.dev4 → pyobs_asi-2.0.0.dev5}/docs/source/_static/pyobs.gif +0 -0
- {pyobs_asi-2.0.0.dev4 → pyobs_asi-2.0.0.dev5}/docs/source/conf.py +0 -0
- {pyobs_asi-2.0.0.dev4 → pyobs_asi-2.0.0.dev5}/docs/source/index.rst +0 -0
- {pyobs_asi-2.0.0.dev4 → pyobs_asi-2.0.0.dev5}/pyobs_asi/__init__.py +0 -0
- {pyobs_asi-2.0.0.dev4 → pyobs_asi-2.0.0.dev5}/pyobs_asi/gui.py +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
name: pyrefly
|
|
2
|
+
on: push
|
|
3
|
+
|
|
4
|
+
jobs:
|
|
5
|
+
pyrefly:
|
|
6
|
+
runs-on: ubuntu-latest
|
|
7
|
+
timeout-minutes: 10
|
|
8
|
+
|
|
9
|
+
steps:
|
|
10
|
+
- name: Check out repository code
|
|
11
|
+
uses: actions/checkout@v4
|
|
12
|
+
|
|
13
|
+
- name: Set up Python
|
|
14
|
+
uses: astral-sh/setup-uv@v5
|
|
15
|
+
with:
|
|
16
|
+
enable-cache: true
|
|
17
|
+
python-version: "3.13"
|
|
18
|
+
|
|
19
|
+
- name: Install packages
|
|
20
|
+
run: uv sync --all-extras --dev
|
|
21
|
+
|
|
22
|
+
- name: Run pyrefly
|
|
23
|
+
run: uv run pyrefly check
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name: PyTest
|
|
2
|
+
on: push
|
|
3
|
+
|
|
4
|
+
jobs:
|
|
5
|
+
test:
|
|
6
|
+
runs-on: ubuntu-latest
|
|
7
|
+
timeout-minutes: 10
|
|
8
|
+
|
|
9
|
+
steps:
|
|
10
|
+
- name: Check out repository code
|
|
11
|
+
uses: actions/checkout@v4
|
|
12
|
+
|
|
13
|
+
- name: Set up Python
|
|
14
|
+
uses: astral-sh/setup-uv@v5
|
|
15
|
+
with:
|
|
16
|
+
enable-cache: true
|
|
17
|
+
python-version: "3.13"
|
|
18
|
+
|
|
19
|
+
- name: Install packages
|
|
20
|
+
run: uv sync --all-extras --dev
|
|
21
|
+
|
|
22
|
+
- name: Run tests
|
|
23
|
+
run: uv run pytest tests
|
|
24
|
+
env:
|
|
25
|
+
CI: true
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: pyobs-asi
|
|
3
|
-
Version: 2.0.0.
|
|
3
|
+
Version: 2.0.0.dev5
|
|
4
4
|
Summary: pyobs model for ASI cameras
|
|
5
5
|
Author-email: Tim-Oliver Husser <thusser@uni-goettingen.de>
|
|
6
6
|
License-Expression: MIT
|
|
7
7
|
License-File: LICENSE
|
|
8
8
|
Requires-Python: >=3.11
|
|
9
9
|
Requires-Dist: numpy<3,>=2.2.5
|
|
10
|
-
Requires-Dist: pyobs-core<3,>=2.0.0.
|
|
10
|
+
Requires-Dist: pyobs-core<3,>=2.0.0.dev48
|
|
11
11
|
Requires-Dist: zwoasi>=0.2.0
|
|
12
12
|
Provides-Extra: gui
|
|
13
|
-
Requires-Dist: pyobs-core[gui]<3,>=2.0.0.
|
|
13
|
+
Requires-Dist: pyobs-core[gui]<3,>=2.0.0.dev48; extra == 'gui'
|
|
14
14
|
Requires-Dist: qasync>=0.28.0; extra == 'gui'
|
|
@@ -12,6 +12,7 @@ import zwoasi as asi # type: ignore
|
|
|
12
12
|
from numpy.typing import NDArray
|
|
13
13
|
from pyobs.images import Image
|
|
14
14
|
from pyobs.interfaces import (
|
|
15
|
+
Binning,
|
|
15
16
|
BinningCapabilities,
|
|
16
17
|
BinningState,
|
|
17
18
|
CoolingState,
|
|
@@ -188,7 +189,7 @@ class AsiCamera(BaseCamera, IWindow, IBinning, IImageFormat, IGain, ITemperature
|
|
|
188
189
|
if "SupportedBins" in self._camera_info:
|
|
189
190
|
await self.comm.set_capabilities(
|
|
190
191
|
IBinning,
|
|
191
|
-
BinningCapabilities(binnings=[
|
|
192
|
+
BinningCapabilities(binnings=[Binning(x=b, y=b) for b in self._camera_info["SupportedBins"]]),
|
|
192
193
|
)
|
|
193
194
|
await self.comm.set_capabilities(IImageFormat, ImageFormatCapabilities(image_formats=list(FORMATS.keys())))
|
|
194
195
|
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "pyobs-asi"
|
|
3
|
-
version = "2.0.0.
|
|
3
|
+
version = "2.0.0.dev5"
|
|
4
4
|
description = "pyobs model for ASI cameras"
|
|
5
5
|
authors = [{ name = "Tim-Oliver Husser", email = "thusser@uni-goettingen.de" }]
|
|
6
6
|
requires-python = ">=3.11"
|
|
7
7
|
license = "MIT"
|
|
8
8
|
dependencies = [
|
|
9
9
|
"numpy>=2.2.5,<3",
|
|
10
|
-
"pyobs-core>=2.0.0.
|
|
10
|
+
"pyobs-core>=2.0.0.dev48,<3",
|
|
11
11
|
"zwoasi>=0.2.0",
|
|
12
12
|
]
|
|
13
13
|
|
|
14
14
|
[project.optional-dependencies]
|
|
15
15
|
gui = [
|
|
16
|
-
"pyobs-core[gui]>=2.0.0.
|
|
16
|
+
"pyobs-core[gui]>=2.0.0.dev48,<3",
|
|
17
17
|
"qasync>=0.28.0",
|
|
18
18
|
]
|
|
19
19
|
|
|
@@ -22,10 +22,12 @@ asi-gui = 'pyobs_asi.gui:main'
|
|
|
22
22
|
|
|
23
23
|
[dependency-groups]
|
|
24
24
|
dev = [
|
|
25
|
-
"black>=25.1.0,<
|
|
25
|
+
"black>=25.1.0,<27",
|
|
26
26
|
"ruff>=0.9.0",
|
|
27
27
|
"pyrefly>=1.1.1",
|
|
28
28
|
"pre-commit>=4.2.0,<5",
|
|
29
|
+
"pytest>=8.0.0",
|
|
30
|
+
"pytest-asyncio>=0.24.0",
|
|
29
31
|
]
|
|
30
32
|
|
|
31
33
|
[build-system]
|
|
@@ -45,3 +47,7 @@ select = ["E", "F", "W", "I", "UP", "G"]
|
|
|
45
47
|
|
|
46
48
|
[tool.pyrefly]
|
|
47
49
|
python-version = "3.11"
|
|
50
|
+
project-excludes = ["pyobs_asi/gui.py"]
|
|
51
|
+
|
|
52
|
+
[tool.pytest.ini_options]
|
|
53
|
+
asyncio_mode = "strict"
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"""Unit tests for the non-hardware logic in AsiCamera: constructor defaults, the
|
|
2
|
+
state-setting methods (window/binning/gain/offset/image format), and the
|
|
3
|
+
_run_blocking/_run_blocking_or_raise thread wrappers.
|
|
4
|
+
|
|
5
|
+
Hardware I/O (opening a camera, exposing, reading out) is out of scope here.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import asyncio
|
|
9
|
+
import threading
|
|
10
|
+
from unittest.mock import AsyncMock
|
|
11
|
+
|
|
12
|
+
import pytest
|
|
13
|
+
from pyobs.interfaces import IBinning, IGain, IWindow
|
|
14
|
+
from pyobs.utils.enums import ImageFormat
|
|
15
|
+
|
|
16
|
+
from pyobs_asi import AsiCamera, AsiCoolCamera
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def test_constructor_defaults() -> None:
|
|
20
|
+
camera = AsiCamera(camera="test")
|
|
21
|
+
assert camera._camera_name == "test"
|
|
22
|
+
assert camera._sdk_path == "/usr/local/lib/libASICamera2.so"
|
|
23
|
+
assert camera._camera is None
|
|
24
|
+
assert camera._window == (0, 0, 0, 0)
|
|
25
|
+
assert camera._binning == 1
|
|
26
|
+
assert camera._image_format == ImageFormat.INT16
|
|
27
|
+
assert camera._gain == 1.0
|
|
28
|
+
assert camera._gain_offset == 50.0
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def test_cool_camera_default_setpoint() -> None:
|
|
32
|
+
camera = AsiCoolCamera(camera="test")
|
|
33
|
+
assert camera._temp_setpoint == -20
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@pytest.mark.asyncio
|
|
37
|
+
async def test_set_window() -> None:
|
|
38
|
+
camera = AsiCamera(camera="test")
|
|
39
|
+
camera.comm.set_state = AsyncMock() # type: ignore[method-assign]
|
|
40
|
+
|
|
41
|
+
await camera.set_window(10, 20, 100, 200)
|
|
42
|
+
|
|
43
|
+
assert camera._window == (10, 20, 100, 200)
|
|
44
|
+
assert camera.comm.set_state.await_args is not None
|
|
45
|
+
interface, state = camera.comm.set_state.await_args.args
|
|
46
|
+
assert interface is IWindow
|
|
47
|
+
assert (state.x, state.y, state.width, state.height) == (10, 20, 100, 200)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@pytest.mark.asyncio
|
|
51
|
+
async def test_set_binning() -> None:
|
|
52
|
+
camera = AsiCamera(camera="test")
|
|
53
|
+
camera.comm.set_state = AsyncMock() # type: ignore[method-assign]
|
|
54
|
+
|
|
55
|
+
await camera.set_binning(2, 3)
|
|
56
|
+
|
|
57
|
+
# only x is tracked as the scalar binning factor; both axes still go out in the state
|
|
58
|
+
assert camera._binning == 2
|
|
59
|
+
assert camera.comm.set_state.await_args is not None
|
|
60
|
+
interface, state = camera.comm.set_state.await_args.args
|
|
61
|
+
assert interface is IBinning
|
|
62
|
+
assert (state.x, state.y) == (2, 3)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
@pytest.mark.asyncio
|
|
66
|
+
async def test_set_gain() -> None:
|
|
67
|
+
camera = AsiCamera(camera="test")
|
|
68
|
+
camera.comm.set_state = AsyncMock() # type: ignore[method-assign]
|
|
69
|
+
|
|
70
|
+
await camera.set_gain(5.0)
|
|
71
|
+
|
|
72
|
+
# offset is untouched, but the published state still carries the last-known offset
|
|
73
|
+
assert camera._gain == 5.0
|
|
74
|
+
assert camera.comm.set_state.await_args is not None
|
|
75
|
+
interface, state = camera.comm.set_state.await_args.args
|
|
76
|
+
assert interface is IGain
|
|
77
|
+
assert (state.gain, state.offset) == (5.0, camera._gain_offset)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
@pytest.mark.asyncio
|
|
81
|
+
async def test_set_offset() -> None:
|
|
82
|
+
camera = AsiCamera(camera="test")
|
|
83
|
+
camera.comm.set_state = AsyncMock() # type: ignore[method-assign]
|
|
84
|
+
|
|
85
|
+
await camera.set_offset(25.0)
|
|
86
|
+
|
|
87
|
+
assert camera._gain_offset == 25.0
|
|
88
|
+
assert camera.comm.set_state.await_args is not None
|
|
89
|
+
interface, state = camera.comm.set_state.await_args.args
|
|
90
|
+
assert interface is IGain
|
|
91
|
+
assert (state.gain, state.offset) == (camera._gain, 25.0)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@pytest.mark.asyncio
|
|
95
|
+
async def test_set_image_format() -> None:
|
|
96
|
+
camera = AsiCamera(camera="test")
|
|
97
|
+
await camera.set_image_format(ImageFormat.RGB24)
|
|
98
|
+
assert camera._image_format == ImageFormat.RGB24
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
@pytest.mark.asyncio
|
|
102
|
+
async def test_set_image_format_invalid() -> None:
|
|
103
|
+
camera = AsiCamera(camera="test")
|
|
104
|
+
with pytest.raises(ValueError):
|
|
105
|
+
await camera.set_image_format("bogus") # type: ignore[arg-type]
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
@pytest.mark.asyncio
|
|
109
|
+
async def test_run_blocking_runs_func_and_returns_true() -> None:
|
|
110
|
+
ran: list[bool] = []
|
|
111
|
+
|
|
112
|
+
def fast() -> None:
|
|
113
|
+
ran.append(True)
|
|
114
|
+
|
|
115
|
+
assert await AsiCamera._run_blocking(fast) is True
|
|
116
|
+
assert ran == [True]
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
@pytest.mark.asyncio
|
|
120
|
+
async def test_run_blocking_times_out() -> None:
|
|
121
|
+
done = threading.Event()
|
|
122
|
+
|
|
123
|
+
def slow() -> None:
|
|
124
|
+
done.wait()
|
|
125
|
+
|
|
126
|
+
assert await AsiCamera._run_blocking(slow, timeout=0.01) is False
|
|
127
|
+
done.set()
|
|
128
|
+
await asyncio.sleep(0.05)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
@pytest.mark.asyncio
|
|
132
|
+
async def test_run_blocking_or_raise_returns_value() -> None:
|
|
133
|
+
camera = AsiCamera(camera="test")
|
|
134
|
+
assert await camera._run_blocking_or_raise(lambda: 42) == 42
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
@pytest.mark.asyncio
|
|
138
|
+
async def test_run_blocking_or_raise_reraises() -> None:
|
|
139
|
+
camera = AsiCamera(camera="test")
|
|
140
|
+
|
|
141
|
+
def boom() -> int:
|
|
142
|
+
raise ValueError("boom")
|
|
143
|
+
|
|
144
|
+
with pytest.raises(ValueError):
|
|
145
|
+
await camera._run_blocking_or_raise(boom)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""Smoke tests: import the drivers and instantiate them without hardware, asserting
|
|
2
|
+
the interfaces they claim.
|
|
3
|
+
|
|
4
|
+
zwoasi imports cleanly with no SDK present (it logs "ASI SDK library not found" and
|
|
5
|
+
degrades), so no camera is needed at import/instantiate time.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from pyobs.interfaces import IBinning, ICooling, IGain, IImageFormat, ITemperatures, IWindow
|
|
9
|
+
from pyobs.modules import Module
|
|
10
|
+
|
|
11
|
+
from pyobs_asi import AsiCamera, AsiCoolCamera
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def test_instantiate_asicamera() -> None:
|
|
15
|
+
camera = AsiCamera(camera="ZWO ASI1600MM Pro")
|
|
16
|
+
assert isinstance(camera, Module)
|
|
17
|
+
assert isinstance(camera, IWindow)
|
|
18
|
+
assert isinstance(camera, IBinning)
|
|
19
|
+
assert isinstance(camera, IImageFormat)
|
|
20
|
+
assert isinstance(camera, IGain)
|
|
21
|
+
assert isinstance(camera, ITemperatures)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def test_instantiate_asicoolcamera() -> None:
|
|
25
|
+
camera = AsiCoolCamera(camera="ZWO ASI1600MM Pro")
|
|
26
|
+
assert isinstance(camera, ICooling)
|
|
27
|
+
assert isinstance(camera, ITemperatures)
|