Skip to content

Commit

Permalink
Avoid using qt in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
imagejan committed Jul 2, 2024
1 parent a47b386 commit 9ad2b0f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
6 changes: 0 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ napari-save-transformed = "napari_save_transformed:napari.yaml"
[tool.hatch.version]
source = "vcs"

[tool.hatch.envs.hatch-test]
extra-dependencies = [
"pytest-qt",
"pyqt5",
]

[tool.hatch.envs.types]
extra-dependencies = [
"mypy>=1.0.0",
Expand Down
6 changes: 5 additions & 1 deletion src/napari_save_transformed/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ def transform_arrays(arrays, affines):
translation = Affine(translate=-min_corner)
for arr, aff in zip(arrays, affines):
# Apply the transformation
output = affine_transform(arr, translation.compose(aff).inverse, output_shape=output_shape)
output = affine_transform(
input=arr,
matrix=translation.compose(aff).inverse,
output_shape=output_shape,
)
outputs.append(output)

return outputs, output_shape
11 changes: 6 additions & 5 deletions tests/test_napari_save_transformed.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import numpy as np
from napari.layers import Image

from napari_save_transformed import write_transformed_layers


def test_write_transformed_layers(make_napari_viewer_proxy, tmp_path):
viewer = make_napari_viewer_proxy()
def test_write_transformed_layers(tmp_path):
layers = []
shape = (100, 200)
image0 = np.ones(shape=shape)
viewer.add_image(image0)
layers.append(Image(image0))
image1 = image0.copy()
viewer.add_image(image1, affine=[[1, 0, 30], [0, 1, 10], [0, 0, 1]])
layers.append(Image(image1, affine=[[1, 0, 30], [0, 1, 10], [0, 0, 1]]))
out_path = tmp_path / "output.tif"
layer_data = [layer.as_layer_data_tuple() for layer in viewer.layers]
layer_data = [layer.as_layer_data_tuple() for layer in layers]
write_transformed_layers(path=out_path, layer_data=layer_data)

assert out_path.exists()

0 comments on commit 9ad2b0f

Please sign in to comment.