Skip to content

Commit df3d7d8

Browse files
authored
Merge pull request #383 from anntzer/update
Drop dependency on nose for tests; fix numpy and python deprecations.
2 parents a40fffe + 2d8c797 commit df3d7d8

18 files changed

+101
-105
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ install:
1919
# Append the conda-forge channel, instead of adding it. See:
2020
# https://github.com/conda-forge/conda-forge.github.io/issues/232)
2121
- conda config --append channels conda-forge
22-
- conda create -n testenv --yes $DEPS nose python=$TRAVIS_PYTHON_VERSION
22+
- conda create -n testenv --yes $DEPS python=$TRAVIS_PYTHON_VERSION
2323
- source activate testenv
2424
# only install pip if there are pip dependencies
2525
# - |
@@ -42,7 +42,7 @@ before_install:
4242
- export PATH=/home/travis/mc/bin:$PATH
4343

4444
script:
45-
- nosetests --nologcapture
45+
- python -munittest
4646
# Doc Build needs: pillow matplotlib ipython sphinx sphinx_rtd_theme numpydoc
4747
- if [ $BUILD_DOCS == true ]; then make html --directory=./doc; fi
4848

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
##
66
## docker build -t pims .
77
## docker run -ti --rm pims
8-
## nosetests --nologcapture
8+
## python -munittest
99
##
1010

1111
FROM continuumio/miniconda3

doc/source/pipelines.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,11 @@ unnamed lambda function in a single line:
135135

136136
.. ipython:: python
137137
138-
processed_video = pims.pipeline(lambda x: x.astype(np.float))(video)
138+
processed_video = pims.pipeline(lambda x: x.astype(float))(video)
139139
processed_frame = processed_video[0]
140140
print(processed_frame.shape)
141141
142142
.. ipython:: python
143143
:suppress:
144144
145-
clean_dummy_png('.', filenames)
145+
clean_dummy_png('.', filenames)

environment.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,4 @@ dependencies:
2020
- moviepy
2121
- imageio
2222
- imageio-ffmpeg
23-
- nose
2423
- openjdk

pims/cine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import hashlib
2727
import sys
2828
import warnings
29-
from collections import Iterable
29+
from collections.abc import Iterable
3030

3131
__all__ = ('Cine', )
3232

pims/display.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ def plot_to_frame(fig, width=512, close_fig=False, fig_size_inches=None,
716716
fig.savefig(buf, format='rgba', dpi=dpi)
717717
buf.seek(0)
718718
buf_shape = (int(height_in * dpi), int(width_in * dpi), 4)
719-
image = np.fromstring(buf.read(),
719+
image = np.frombuffer(buf.read(),
720720
dtype='uint8').reshape(*buf_shape)
721721

722722
if close_fig:

pims/ffmpeg_reader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def get_frame(self, j):
216216
self.data_buffer.seek(self._stride*j)
217217
s = self.data_buffer.read(self._stride)
218218
w, h = self._size
219-
result = np.fromstring(s,
219+
result = np.frombuffer(s,
220220
dtype='uint8').reshape((h, w, self.depth))
221221
return Frame(result, frame_no=j)
222222

pims/process.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def __init__(self, reader, crop_width, order='K'):
7373
# We have to know the frame shape that is returned by the reader.
7474
try: # In case the reader is a FramesSequence, there is an attribute
7575
shape = reader.frame_shape
76-
first_frame = np.empty(shape, dtype=np.bool)
76+
first_frame = np.empty(shape, dtype=bool)
7777
except AttributeError:
7878
first_frame = reader[0]
7979
shape = first_frame.shape

pims/spe_stack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def __init__(self, filename, char_encoding=None, check_filesize=True):
174174
if cnt == 1:
175175
#for convenience, if the array contains only one single entry,
176176
#return this entry itself.
177-
v = np.asscalar(v)
177+
v = v.item()
178178
self.metadata[name] = v
179179

180180
### Some metadata is "special", deal with it

pims/tests/test_bioformats.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import os
1010
import unittest
11-
import nose
1211
import numpy as np
1312
from numpy.testing import (assert_equal, assert_almost_equal, assert_allclose)
1413

@@ -20,7 +19,7 @@
2019

2120
def _skip_if_no_bioformats():
2221
if not pims.bioformats.available():
23-
raise nose.SkipTest('JPype is not installed. Skipping.')
22+
raise unittest.SkipTest('JPype is not installed. Skipping.')
2423

2524

2625
def assert_image_equal(actual, expected):
@@ -187,7 +186,7 @@ class TestBioformatsMOV(_image_series, unittest.TestCase):
187186
def check_skip(self):
188187
_skip_if_no_bioformats()
189188
if not os.path.isfile(self.filename):
190-
raise nose.SkipTest('File missing. Skipping.')
189+
raise unittest.SkipTest('File missing. Skipping.')
191190

192191
def setUp(self):
193192
self.filename = os.path.join(path, 'bioformats', 'wtembryo.mov')
@@ -212,7 +211,7 @@ class TestBioformatsIPW(_image_series, _image_stack, _image_multichannel,
212211
def check_skip(self):
213212
_skip_if_no_bioformats()
214213
if not os.path.isfile(self.filename):
215-
raise nose.SkipTest('File missing. Skipping.')
214+
raise unittest.SkipTest('File missing. Skipping.')
216215

217216
def setUp(self):
218217
self.filename = os.path.join(path, 'bioformats', 'mitosis-test.ipw')
@@ -236,7 +235,7 @@ class TestBioformatsDM3(_image_single, unittest.TestCase):
236235
def check_skip(self):
237236
_skip_if_no_bioformats()
238237
if not os.path.isfile(self.filename):
239-
raise nose.SkipTest('File missing. Skipping.')
238+
raise unittest.SkipTest('File missing. Skipping.')
240239

241240
def setUp(self):
242241
self.filename = os.path.join(path, 'bioformats', 'dnasample1.dm3')
@@ -259,7 +258,7 @@ class TestBioformatsLSM(_image_series, _image_stack, _image_multichannel,
259258
def check_skip(self):
260259
_skip_if_no_bioformats()
261260
if not os.path.isfile(self.filename):
262-
raise nose.SkipTest('File missing. Skipping.')
261+
raise unittest.SkipTest('File missing. Skipping.')
263262

264263
def setUp(self):
265264
self.filename = os.path.join(path, 'bioformats', '2chZT.lsm')
@@ -284,7 +283,7 @@ class TestBioformatsAndorTiff(_image_series, _image_stack, _image_multichannel,
284283
def check_skip(self):
285284
_skip_if_no_bioformats()
286285
if not os.path.isfile(self.filename):
287-
raise nose.SkipTest('File missing. Skipping.')
286+
raise unittest.SkipTest('File missing. Skipping.')
288287

289288
def setUp(self):
290289
self.filename = os.path.join(path, 'bioformats', 'MF-2CH-Z-T.tif')
@@ -309,7 +308,7 @@ class TestBioformatsOlympusTiff(_image_series, _image_stack, unittest.TestCase):
309308
def check_skip(self):
310309
_skip_if_no_bioformats()
311310
if not os.path.isfile(self.filename):
312-
raise nose.SkipTest('File missing. Skipping.')
311+
raise unittest.SkipTest('File missing. Skipping.')
313312

314313
def setUp(self):
315314
self.filename = os.path.join(path, 'bioformats', '10-31 E1.tif')
@@ -337,7 +336,7 @@ class TestBioformatsLIFseries1(_image_single, _image_stack, _image_multichannel,
337336
def check_skip(self):
338337
_skip_if_no_bioformats()
339338
if not os.path.isfile(self.filename):
340-
raise nose.SkipTest('File missing. Skipping.')
339+
raise unittest.SkipTest('File missing. Skipping.')
341340

342341
def setUp(self):
343342
self.filename = os.path.join(path, 'bioformats', 'mouse-kidney.lif')
@@ -367,7 +366,7 @@ class TestBioformatsLIFseries2(_image_single, _image_stack, _image_multichannel,
367366
def check_skip(self):
368367
_skip_if_no_bioformats()
369368
if not os.path.isfile(self.filename):
370-
raise nose.SkipTest('File missing. Skipping.')
369+
raise unittest.SkipTest('File missing. Skipping.')
371370

372371
def setUp(self):
373372
self.filename = os.path.join(path, 'bioformats', 'mouse-kidney.lif')
@@ -390,7 +389,7 @@ class TestBioformatsIPL(_image_single, unittest.TestCase):
390389
def check_skip(self):
391390
_skip_if_no_bioformats()
392391
if not os.path.isfile(self.filename):
393-
raise nose.SkipTest('File missing. Skipping.')
392+
raise unittest.SkipTest('File missing. Skipping.')
394393

395394
def setUp(self):
396395
self.filename = os.path.join(path, 'bioformats', 'Blend_Final.IPL')
@@ -411,7 +410,7 @@ class TestBioformatsSEQ(_image_single, _image_stack, unittest.TestCase):
411410
def check_skip(self):
412411
_skip_if_no_bioformats()
413412
if not os.path.isfile(self.filename):
414-
raise nose.SkipTest('File missing. Skipping.')
413+
raise unittest.SkipTest('File missing. Skipping.')
415414

416415
def setUp(self):
417416
self.filename = os.path.join(path, 'bioformats', 'HEART.SEQ')
@@ -435,7 +434,7 @@ class TestBioformatsLEI(_image_single, _image_stack, unittest.TestCase):
435434
def check_skip(self):
436435
_skip_if_no_bioformats()
437436
if not os.path.isfile(self.filename):
438-
raise nose.SkipTest('File missing. Skipping.')
437+
raise unittest.SkipTest('File missing. Skipping.')
439438

440439
def setUp(self):
441440
self.filename = os.path.join(path, 'bioformats', 'leica_stack.lei')
@@ -460,7 +459,7 @@ class TestBioformatsICS(_image_single, unittest.TestCase):
460459
def check_skip(self):
461460
_skip_if_no_bioformats()
462461
if not os.path.isfile(self.filename):
463-
raise nose.SkipTest('File missing. Skipping.')
462+
raise unittest.SkipTest('File missing. Skipping.')
464463

465464
def setUp(self):
466465
self.filename = os.path.join(path, 'bioformats', 'qdna1.ics')
@@ -483,7 +482,7 @@ class TestBioformatsZPO(_image_stack, _image_multichannel, unittest.TestCase):
483482
def check_skip(self):
484483
_skip_if_no_bioformats()
485484
if not os.path.isfile(self.filename):
486-
raise nose.SkipTest('File missing. Skipping.')
485+
raise unittest.SkipTest('File missing. Skipping.')
487486

488487
def setUp(self):
489488
self.filename = os.path.join(path, 'bioformats', 'KEVIN2-3.zpo')
@@ -547,5 +546,5 @@ def test_metadata_tags(self):
547546
assert 'PixelsPhysicalSizeX' in fields
548547

549548
if __name__ == '__main__':
550-
nose.runmodule(argv=[__file__, '-vvs'],
549+
unittest.runmodule(argv=[__file__, '-vvs'],
551550
exit=False)

0 commit comments

Comments
 (0)