From 4a48847630c1f429414e29ef4f47b92934632293 Mon Sep 17 00:00:00 2001 From: jim Date: Tue, 23 Feb 2016 15:23:52 -0600 Subject: [PATCH] resolves #152: images truly act like numpy arrays now and are also displayable --- Makefile | 2 +- functional_tests/FYLM141111001.py | 11 +++++++++++ nd2reader/__init__.py | 2 +- nd2reader/model/image.py | 4 ++-- setup.py | 2 +- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index b2301d6..2b090a3 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ test: build ftest: build xhost local:root; docker run --rm -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$(DISPLAY) -v $(CURDIR):/opt/nd2reader -v ~/nd2s:/var/nd2s -it jimrybarski/nd2reader python3.4 /opt/nd2reader/ftest.py - docker run --rm -v $(CURDIR):/opt/nd2reader -v ~/nd2s:/var/nd2s -it jimrybarski/nd2reader python2.7 /opt/nd2reader/ftest.py + xhost local:root; docker run --rm -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$(DISPLAY) -v $(CURDIR):/opt/nd2reader -v ~/nd2s:/var/nd2s -it jimrybarski/nd2reader python2.7 /opt/nd2reader/ftest.py publish: python setup.py sdist upload -r pypi diff --git a/functional_tests/FYLM141111001.py b/functional_tests/FYLM141111001.py index 9eaad52..d1e857a 100644 --- a/functional_tests/FYLM141111001.py +++ b/functional_tests/FYLM141111001.py @@ -4,6 +4,7 @@ run them unless you're Jim Rybarski. """ from nd2reader import Nd2 +from skimage import io import numpy as np from datetime import datetime import unittest @@ -227,3 +228,13 @@ class FYLM141111Tests(unittest.TestCase): mean = np.mean(self.nd2[0]) self.assertEqual(type(mean), np.float64) self.assertAlmostEqual(expected_mean, mean) + + def test_subtract_images(self): + # just to prove we can really treat Image like an array + diff = self.nd2[0] - self.nd2[2] + self.assertTrue(np.any(diff)) + + def test_show(self): + io.imshow(self.nd2[0]) + io.show() + self.assertTrue(True) diff --git a/nd2reader/__init__.py b/nd2reader/__init__.py index 5e6282a..6184c21 100644 --- a/nd2reader/__init__.py +++ b/nd2reader/__init__.py @@ -1,3 +1,3 @@ from nd2reader.main import Nd2 -__version__ = '2.1.2' +__version__ = '2.1.3' diff --git a/nd2reader/model/image.py b/nd2reader/model/image.py index 594b0b0..eea244e 100644 --- a/nd2reader/model/image.py +++ b/nd2reader/model/image.py @@ -19,11 +19,11 @@ class Image(np.ndarray): self._channel = None self._z_level = None - def __array_wrap__(self, obj): + def __array_wrap__(self, obj, *args): if len(obj.shape) == 0: return obj[()] else: - return np.ndarray.__array_wrap__(obj) + return obj def add_params(self, index, timestamp, frame_number, field_of_view, channel, z_level): """ diff --git a/setup.py b/setup.py index 0ae1b10..7782e75 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup -VERSION = '2.1.2' +VERSION = '2.1.3' if __name__ == '__main__': setup(