Skip to content

Commit 032aa05

Browse files
authored
Merge pull request #230 from punch-mission/fix-226
fix-226
2 parents f4e0755 + b372160 commit 032aa05

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

regularizepsf/psf.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
import inspect
6+
import pathlib
67
from typing import TYPE_CHECKING, Any, cast
78
from functools import partial
89

@@ -17,7 +18,6 @@
1718
from regularizepsf.visualize import KERNEL_IMSHOW_ARGS_DEFAULT, PSF_IMSHOW_ARGS_DEFAULT, visualize_grid
1819

1920
if TYPE_CHECKING:
20-
import pathlib
2121
from numbers import Real
2222
from collections.abc import Callable
2323

@@ -272,6 +272,7 @@ def save(self, path: pathlib.Path) -> None:
272272
None
273273
274274
"""
275+
path = pathlib.Path(path)
275276
if path.suffix == ".h5":
276277
with h5py.File(path, "w") as f:
277278
f.create_dataset("coordinates", data=self.coordinates)
@@ -302,6 +303,7 @@ def load(cls, path: pathlib.Path) -> ArrayPSF:
302303
loaded model
303304
304305
"""
306+
path = pathlib.Path(path)
305307
if path.suffix == ".h5":
306308
with h5py.File(path, "r") as f:
307309
coordinates = [tuple(c) for c in f["coordinates"][:]]

regularizepsf/transform.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
import pathlib
56
from typing import TYPE_CHECKING
67

78
import h5py
@@ -15,7 +16,6 @@
1516
from regularizepsf.visualize import KERNEL_IMSHOW_ARGS_DEFAULT, visualize_grid
1617

1718
if TYPE_CHECKING:
18-
import pathlib
1919

2020
from regularizepsf.psf import ArrayPSF
2121

@@ -173,6 +173,7 @@ def save(self, path: pathlib.Path) -> None:
173173
None
174174
175175
"""
176+
path = pathlib.Path(path)
176177
if path.suffix == ".h5":
177178
with h5py.File(path, "w") as f:
178179
f.create_dataset("coordinates", data=self.coordinates)
@@ -201,6 +202,7 @@ def load(cls, path: pathlib.Path) -> ArrayPSFTransform:
201202
PSFTransform
202203
203204
"""
205+
path = pathlib.Path(path)
204206
if path.suffix == ".h5":
205207
with h5py.File(path, "r") as f:
206208
coordinates = [tuple(c) for c in f["coordinates"][:]]

0 commit comments

Comments
 (0)