diff --git a/changes/292.apichange.rst b/changes/292.apichange.rst new file mode 100644 index 00000000..63c63b16 --- /dev/null +++ b/changes/292.apichange.rst @@ -0,0 +1 @@ +Add `outlier_detection` median calculators from jwst. \ No newline at end of file diff --git a/src/stcal/outlier_detection/median.py b/src/stcal/outlier_detection/median.py index ed8da2f3..2ca6b7c2 100644 --- a/src/stcal/outlier_detection/median.py +++ b/src/stcal/outlier_detection/median.py @@ -6,6 +6,7 @@ import tempfile import warnings from pathlib import Path +from typing import Any import numpy as np @@ -74,11 +75,12 @@ def __init__(self: MedianComputer, self.buffer_size = buffer_size self.dtype = dtype if self.in_memory: - self._median_computer = np.empty(full_shape, dtype=dtype) + computer: Any = np.empty(full_shape, dtype=dtype) else: - self._median_computer = OnDiskMedian(full_shape, - dtype=dtype, - buffer_size=buffer_size) + computer = OnDiskMedian(full_shape, + dtype=dtype, + buffer_size=buffer_size) + self._median_computer: Any = computer def append(self: MedianComputer, data: np.ndarray, diff --git a/tests/outlier_detection/test_median.py b/tests/outlier_detection/test_median.py index 3de71a87..48009475 100644 --- a/tests/outlier_detection/test_median.py +++ b/tests/outlier_detection/test_median.py @@ -16,7 +16,7 @@ def test_disk_appendable_array(tmpdir): slice_shape = (8,7) dtype = "float32" - tempdir = tmpdir / Path("tmptest") + tempdir = Path(tmpdir) / Path("tmptest") Path.mkdir(tempdir) fname = tempdir / "test.bin" @@ -58,7 +58,7 @@ def test_disk_appendable_array_bad_inputs(tmpdir): slice_shape = (8, 7) dtype = "float32" - tempdir = tmpdir / Path("tmptest") + tempdir = Path(tmpdir) / Path("tmptest") fname = "test.bin" # test input directory does not exist @@ -92,7 +92,7 @@ def test_on_disk_median(tmpdir): library_length = 3 frame_shape = (21, 20) dtype = "float32" - tempdir = tmpdir / Path("tmptest") + tempdir = Path(tmpdir) / Path("tmptest") Path.mkdir(tempdir) shape = (library_length, *frame_shape) @@ -171,7 +171,7 @@ def test_on_disk_median_bad_inputs(tmpdir): library_length = 3 frame_shape = (21, 20) dtype = "float32" - tempdir = tmpdir / Path("tmptest") + tempdir = Path(tmpdir) / Path("tmptest") Path.mkdir(tempdir) shape = (library_length, *frame_shape)