From 0930eab569aa5c91037c80f316dff6ade11f3a39 Mon Sep 17 00:00:00 2001 From: Andrew Davison Date: Fri, 16 Nov 2018 09:05:15 +0100 Subject: [PATCH] Fix some bugs which I see on my laptop, although apparently they are not caught by Travis or CircleCI? My env: conda list # packages in environment at /Users/andrew/anaconda/envs/neo: # alabaster 0.7.6 py27_0 http://repo.continuum.io/pkgs/free/osx-64/alabaster-0.7.6-py27_0.tar.bz2 allensdk 0.12.0 babel 2.1.1 py27_0 http://repo.continuum.io/pkgs/free/osx-64/babel-2.1.1-py27_0.tar.bz2 certifi 2016.2.28 py27_0 defaults chardet 3.0.4 coverage 3.7.1 py27_0 http://repo.continuum.io/pkgs/free/osx-64/coverage-3.7.1-py27_0.tar.bz2 cython 0.27 dateutil 2.1 py27_2 docutils 0.12 py27_0 http://repo.continuum.io/pkgs/free/osx-64/docutils-0.12-py27_0.tar.bz2 enum34 1.1.6 freetype 2.4.10 1 funcsigs 1.0.2 py27_0 defaults future 0.16.0 h5py 2.5.0 np110py27_4 http://repo.continuum.io/pkgs/free/osx-64/h5py-2.5.0-np110py27_4.tar.bz2 hdf5 1.8.15.1 2 http://repo.continuum.io/pkgs/free/osx-64/hdf5-1.8.15.1-2.tar.bz2 idna 2.7 igor 0.2 ipython 2.3.0 py27_0 http://repo.continuum.io/pkgs/free/osx-64/ipython-2.3.0-py27_0.tar.bz2 jinja2 2.8 py27_0 http://repo.continuum.io/pkgs/free/osx-64/jinja2-2.8-py27_0.tar.bz2 klusta 3.0.16 libpng 1.5.13 1 markupsafe 0.23 py27_0 http://repo.continuum.io/pkgs/free/osx-64/markupsafe-0.23-py27_0.tar.bz2 matplotlib 1.4.2 np19py27_0 http://repo.continuum.io/pkgs/free/osx-64/matplotlib-1.4.2-np19py27_0.tar.bz2 mkl 11.3.1 0 http://repo.continuum.io/pkgs/free/osx-64/mkl-11.3.1-0.tar.bz2 mock 2.0.0 py27_0 defaults neo (/Users/andrew/dev/analysis/neo) 0.7.0.dev0 neurom 1.4.8 nixio 1.4.2 nose 1.3.4 py27_0 http://repo.continuum.io/pkgs/free/osx-64/nose-1.3.4-py27_0.tar.bz2 nsdf 0.1 numexpr 2.3.1 np19py27_0 http://repo.continuum.io/pkgs/free/osx-64/numexpr-2.3.1-np19py27_0.tar.bz2 numpy 1.10.4 py27_0 http://repo.continuum.io/pkgs/free/osx-64/numpy-1.10.4-py27_0.tar.bz2 nwb (/Users/andrew/packages/nwb_api-python) 1.0.4b0 openssl 1.0.2l 0 defaults pandas 0.18.1 pbr 1.10.0 py27_0 defaults pip 9.0.1 py27_1 defaults pkginfo 1.4.2 pygments 2.0.2 py27_0 http://repo.continuum.io/pkgs/free/osx-64/pygments-2.0.2-py27_0.tar.bz2 pylru 1.1.0 pynrrd 0.2.1 pyparsing 2.0.1 py27_0 pytables 3.1.1 np19py27_0 http://repo.continuum.io/pkgs/free/osx-64/pytables-3.1.1-np19py27_0.tar.bz2 python 2.7.13 0 defaults python-dateutil 1.5 python.app 1.2 py27_3 http://repo.continuum.io/pkgs/free/osx-64/python.app-1.2-py27_3.tar.bz2 pytz 2015.7 py27_0 http://repo.continuum.io/pkgs/free/osx-64/pytz-2015.7-py27_0.tar.bz2 pyyaml 3.12 quantities (/Users/andrew/anaconda/envs/neo/lib/python2.7/site-packages) 0.12.1 readline 6.2 2 requests 2.19.1 requests-toolbelt 0.8.0 scipy 0.14.0 np19py27_0 http://repo.continuum.io/pkgs/free/osx-64/scipy-0.14.0-np19py27_0.tar.bz2 setuptools 36.4.0 py27_0 defaults six 1.10.0 py27_0 http://repo.continuum.io/pkgs/free/osx-64/six-1.10.0-py27_0.tar.bz2 snowballstemmer 1.2.0 py27_0 http://repo.continuum.io/pkgs/free/osx-64/snowballstemmer-1.2.0-py27_0.tar.bz2 sphinx 1.3.1 py27_0 http://repo.continuum.io/pkgs/free/osx-64/sphinx-1.3.1-py27_0.tar.bz2 sphinx-rtd-theme 0.1.7 sphinx_rtd_theme 0.1.7 py27_0 http://repo.continuum.io/pkgs/free/osx-64/sphinx_rtd_theme-0.1.7-py27_0.tar.bz2 sqlite 3.13.0 0 defaults tables 3.1.1 tk 8.5.18 0 http://repo.continuum.io/pkgs/free/osx-64/tk-8.5.18-0.tar.bz2 tqdm 4.19.5 twine 1.11.0 urllib3 1.23 wheel 0.29.0 py27_0 http://repo.continuum.io/pkgs/free/osx-64/wheel-0.29.0-py27_0.tar.bz2 zlib 1.2.11 0 defaults --- neo/core/epoch.py | 8 ++++++++ neo/test/coretest/test_analogsignal.py | 4 ++-- neo/test/coretest/test_irregularysampledsignal.py | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/neo/core/epoch.py b/neo/core/epoch.py index df3354578..b4aa1eb1a 100644 --- a/neo/core/epoch.py +++ b/neo/core/epoch.py @@ -179,6 +179,14 @@ def __getitem__(self, i): obj.labels = self.labels[i] return obj + def __getslice__(self, i, j): + ''' + Get a slice from :attr:`i` to :attr:`j`.attr[0] + + Doesn't get called in Python 3, :meth:`__getitem__` is called instead + ''' + return self.__getitem__(slice(i, j)) + @property def times(self): return pq.Quantity(self) diff --git a/neo/test/coretest/test_analogsignal.py b/neo/test/coretest/test_analogsignal.py index 56dd67870..c0f9e543e 100644 --- a/neo/test/coretest/test_analogsignal.py +++ b/neo/test/coretest/test_analogsignal.py @@ -431,7 +431,7 @@ def test__comparison_as_indexing_double_trace(self): def test__indexing_keeps_order_across_channels(self): # AnalogSignals with 10 traces each having 5 samples (eg. data[0] = [0,10,20,30,40]) data = np.array([range(10), range(10, 20), range(20, 30), range(30, 40), range(40, 50)]) - mask = np.full((5, 10), fill_value=False) + mask = np.full((5, 10), fill_value=False, dtype=bool) # selecting one entry per trace mask[[0, 1, 0, 3, 0, 2, 4, 3, 1, 4], range(10)] = True @@ -441,7 +441,7 @@ def test__indexing_keeps_order_across_channels(self): def test__indexing_keeps_order_across_time(self): # AnalogSignals with 10 traces each having 5 samples (eg. data[0] = [0,10,20,30,40]) data = np.array([range(10), range(10, 20), range(20, 30), range(30, 40), range(40, 50)]) - mask = np.full((5, 10), fill_value=False) + mask = np.full((5, 10), fill_value=False, dtype=bool) # selecting two entries per trace temporal_ids = [0, 1, 0, 3, 1, 2, 4, 2, 1, 4] + [4, 3, 2, 1, 0, 1, 2, 3, 2, 1] mask[temporal_ids, list(range(10)) + list(range(10))] = True diff --git a/neo/test/coretest/test_irregularysampledsignal.py b/neo/test/coretest/test_irregularysampledsignal.py index 89717c745..17e5d43c7 100644 --- a/neo/test/coretest/test_irregularysampledsignal.py +++ b/neo/test/coretest/test_irregularysampledsignal.py @@ -292,7 +292,7 @@ def test__comparison_as_indexing_multi_trace(self): def test__indexing_keeps_order_across_channels(self): # AnalogSignals with 10 traces each having 5 samples (eg. data[0] = [0,10,20,30,40]) data = np.array([range(10), range(10, 20), range(20, 30), range(30, 40), range(40, 50)]) - mask = np.full((5, 10), fill_value=False) + mask = np.full((5, 10), fill_value=False, dtype=bool) # selecting one entry per trace mask[[0, 1, 0, 3, 0, 2, 4, 3, 1, 4], range(10)] = True @@ -302,7 +302,7 @@ def test__indexing_keeps_order_across_channels(self): def test__indexing_keeps_order_across_time(self): # AnalogSignals with 10 traces each having 5 samples (eg. data[0] = [0,10,20,30,40]) data = np.array([range(10), range(10, 20), range(20, 30), range(30, 40), range(40, 50)]) - mask = np.full((5, 10), fill_value=False) + mask = np.full((5, 10), fill_value=False, dtype=bool) # selecting two entries per trace temporal_ids = [0, 1, 0, 3, 1, 2, 4, 2, 1, 4] + [4, 3, 2, 1, 0, 1, 2, 3, 2, 1] mask[temporal_ids, list(range(10)) + list(range(10))] = True