-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from constantinpape/patch-1
Update reader.py to v0.3
- Loading branch information
Showing
12 changed files
with
141 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
[settings] | ||
known_third_party = cv2,dask,numpy,pytest,scipy,setuptools,skimage,zarr | ||
multi_line_output=6 | ||
include_trailing_comma=False | ||
force_grid_wrap=0 | ||
use_parentheses=True | ||
line_length=120 | ||
known_third_party = dask,numpy,pytest,scipy,setuptools,skimage,zarr | ||
multi_line_output = 3 | ||
include_trailing_comma = True | ||
force_grid_wrap = 0 | ||
use_parentheses = True | ||
ensure_newline_before_comments = True | ||
line_length = 88 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,9 +8,7 @@ dependencies: | |
- ipython | ||
- mypy | ||
- omero-py | ||
- opencv | ||
- pip | ||
- py-opencv | ||
- pytest | ||
- requests | ||
- s3fs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import numpy as np | ||
import pytest | ||
|
||
from ome_zarr.scale import Scaler | ||
|
||
|
||
class TestScaler: | ||
@pytest.fixture(params=((1, 2, 1, 256, 256),)) | ||
def shape(self, request): | ||
return request.param | ||
|
||
def create_data(self, shape, dtype=np.uint8, mean_val=10): | ||
rng = np.random.default_rng(0) | ||
return rng.poisson(mean_val, size=shape).astype(dtype) | ||
|
||
def check_downscaled(self, downscaled, shape, scale_factor=2): | ||
expected_shape = shape | ||
for data in downscaled: | ||
assert data.shape == expected_shape | ||
expected_shape = expected_shape[:-2] + tuple( | ||
sh // scale_factor for sh in expected_shape[-2:] | ||
) | ||
|
||
def test_nearest(self, shape): | ||
data = self.create_data(shape) | ||
scaler = Scaler() | ||
downscaled = scaler.nearest(data) | ||
self.check_downscaled(downscaled, shape) | ||
|
||
# this fails because of wrong channel dimension; need to fix in follow-up PR | ||
@pytest.mark.xfail | ||
def test_gaussian(self, shape): | ||
data = self.create_data(shape) | ||
scaler = Scaler() | ||
downscaled = scaler.gaussian(data) | ||
self.check_downscaled(downscaled, shape) | ||
|
||
# this fails because of wrong channel dimension; need to fix in follow-up PR | ||
@pytest.mark.xfail | ||
def test_laplacian(self, shape): | ||
data = self.create_data(shape) | ||
scaler = Scaler() | ||
downscaled = scaler.laplacian(data) | ||
self.check_downscaled(downscaled, shape) | ||
|
||
def test_local_mean(self, shape): | ||
data = self.create_data(shape) | ||
scaler = Scaler() | ||
downscaled = scaler.local_mean(data) | ||
self.check_downscaled(downscaled, shape) | ||
|
||
@pytest.mark.skip(reason="This test does not terminate") | ||
def test_zoom(self, shape): | ||
data = self.create_data(shape) | ||
scaler = Scaler() | ||
downscaled = scaler.zoom(data) | ||
self.check_downscaled(downscaled, shape) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters