Skip to content

Commit 9f03de9

Browse files
committed
Merge pull request #111 from toddrjen/cleanups
Various Cleanups
2 parents ad332bb + 1d637e2 commit 9f03de9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+705
-942
lines changed

doc/source/developers_guide.rst

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ a GitHub account and then set to watch the repository at `GitHub Repository`_
3838
Requirements
3939
------------
4040

41-
* Python_ 2.6, 2.7, 3.1 or 3.2
41+
* Python_ 2.6, 2.7, or 3.3
4242
* numpy_ >= 1.3.0
4343
* quantities_ >= 0.9.0
44-
* if using Python 2.6 or 3.1, unittest2_ >= 0.5.1
44+
* if using Python 2.6, unittest2_ >= 0.5.1
4545
* Setuptools >= 0.7
4646
* nose_ >= 0.11.1 (for running tests)
4747
* Sphinx_ >= 0.6.4 (for building documentation)
@@ -96,7 +96,7 @@ on your system::
9696

9797
$ cd neo/test
9898

99-
With Python 2.7 or 3.2::
99+
With Python 2.7 or 3.3::
100100

101101
$ python -m unittest discover
102102
$ python3 -m unittest discover
@@ -195,9 +195,10 @@ open a pull request on GitHub
195195
Python 3
196196
--------
197197

198-
Neo core should work with both recent versions of Python 2 (versions 2.6 and 2.7)
199-
and Python 3. Neo IO modules should ideally work with both Python 2 and 3, but
200-
certain modules may only work with one or the other (see :doc:`install`).
198+
Neo core should work with both recent versions of Python 2 (versions 2.6 and
199+
2.7) and Python 3 (version 3.3). Neo IO modules should ideally work with both
200+
Python 2 and 3, but certain modules may only work with one or the other
201+
(see :doc:`install`).
201202

202203
So far, we have managed to write code that works with both Python 2 and 3.
203204
Mainly this involves avoiding the ``print`` statement (use ``logging.info``
@@ -218,7 +219,7 @@ Coding standards and style
218219
--------------------------
219220

220221
All code should conform as much as possible to `PEP 8`_, and should run with
221-
Python 2.6, 2.7, 3.1, 3.2, and 3.3.
222+
Python 2.6, 2.7, and 3.3.
222223

223224
You can use the `pep8`_ program to check the code for PEP 8 conformity.
224225
You can also use `flake8`_, which combines pep8 and pyflakes.

examples/read_files.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@
1515

1616
#create a reader
1717
reader = neo.io.PlexonIO(filename='File_plexon_3.plx')
18-
# read the block
19-
bl = reader.read(cascade=True, lazy=False)
20-
print bl
18+
# read the blocks
19+
blks = reader.read(cascade=True, lazy=False)
20+
print blks
2121
# acces to segments
22-
for seg in bl.segments:
23-
print seg
24-
for asig in seg.analogsignals:
25-
print asig
26-
for st in seg.spiketrains:
27-
print st
22+
for blk in blks:
23+
for seg in blk.segments:
24+
print seg
25+
for asig in seg.analogsignals:
26+
print asig
27+
for st in seg.spiketrains:
28+
print st
2829

2930

3031
# CED Spike2 files

examples/simple_plot_with_matplotlib.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import urllib
77

88
import numpy as np
9+
import quantities as pq
910
from matplotlib import pyplot
1011

1112
import neo
@@ -21,12 +22,17 @@
2122
for seg in bl.segments:
2223
fig = pyplot.figure()
2324
ax1 = fig.add_subplot(2, 1, 1)
24-
ax2 = fig.add_subplot(2, 1, 2, sharex=ax1)
25+
ax2 = fig.add_subplot(2, 1, 2)
2526
ax1.set_title(seg.file_origin)
26-
for asig in seg.analogsignals:
27-
ax1.plot(asig.times, asig)
28-
for s, st in enumerate(seg.spiketrains):
29-
print st.units
30-
ax2.plot(st, s*np.ones(st.size), linestyle='None',
31-
marker='|', color='k')
27+
mint = 0 * pq.s
28+
maxt = np.inf * pq.s
29+
for i, asig in enumerate(seg.analogsignals):
30+
times = asig.times.rescale('s').magnitude
31+
asig = asig.rescale('mV').magnitude
32+
ax1.plot(times, asig)
33+
34+
trains = [st.rescale('s').magnitude for st in seg.spiketrains]
35+
colors = pyplot.cm.jet(np.linspace(0, 1, len(seg.spiketrains)))
36+
ax2.eventplot(trains, colors=colors)
37+
3238
pyplot.show()

neo/core/analogsignal.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -365,55 +365,55 @@ def _copy_data_complement(self, other):
365365
"description", "channel_index", "annotations"):
366366
setattr(self, attr, getattr(other, attr, None))
367367

368-
def _apply_operator(self, other, op):
368+
def _apply_operator(self, other, op, *args):
369369
'''
370370
Handle copying metadata to the new :class:`BaseAnalogSignal`
371371
after a mathematical operation.
372372
'''
373373
self._check_consistency(other)
374374
f = getattr(super(BaseAnalogSignal, self), op)
375-
new_signal = f(other)
375+
new_signal = f(other, *args)
376376
new_signal._copy_data_complement(self)
377377
return new_signal
378378

379-
def __add__(self, other):
379+
def __add__(self, other, *args):
380380
'''
381381
Addition (+)
382382
'''
383-
return self._apply_operator(other, "__add__")
383+
return self._apply_operator(other, "__add__", *args)
384384

385-
def __sub__(self, other):
385+
def __sub__(self, other, *args):
386386
'''
387387
Subtraction (-)
388388
'''
389-
return self._apply_operator(other, "__sub__")
389+
return self._apply_operator(other, "__sub__", *args)
390390

391-
def __mul__(self, other):
391+
def __mul__(self, other, *args):
392392
'''
393393
Multiplication (*)
394394
'''
395-
return self._apply_operator(other, "__mul__")
395+
return self._apply_operator(other, "__mul__", *args)
396396

397-
def __truediv__(self, other):
397+
def __truediv__(self, other, *args):
398398
'''
399399
Float division (/)
400400
'''
401-
return self._apply_operator(other, "__truediv__")
401+
return self._apply_operator(other, "__truediv__", *args)
402402

403-
def __div__(self, other):
403+
def __div__(self, other, *args):
404404
'''
405405
Integer division (//)
406406
'''
407-
return self._apply_operator(other, "__div__")
407+
return self._apply_operator(other, "__div__", *args)
408408

409409
__radd__ = __add__
410410
__rmul__ = __sub__
411411

412-
def __rsub__(self, other):
412+
def __rsub__(self, other, *args):
413413
'''
414414
Backwards subtraction (other-self)
415415
'''
416-
return self.__mul__(-1) + other
416+
return self.__mul__(-1, *args) + other
417417

418418
def _repr_pretty_(self, pp, cycle):
419419
'''
@@ -437,8 +437,6 @@ def _pp(line):
437437
pp.text(line)
438438
if hasattr(self, "channel_index"):
439439
_pp("channel index: {0}".format(self.channel_index))
440-
elif hasattr(self, "channel_indexes"):
441-
_pp("channel indices: %s" % self.channel_indexes)
442440
for line in ["sampling rate: {0}".format(self.sampling_rate),
443441
"time: {0} to {1}".format(self.t_start, self.t_stop)
444442
]:

neo/core/irregularlysampledsignal.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,14 @@ def __ne__(self, other):
229229
'''
230230
return not self.__eq__(other)
231231

232-
def _apply_operator(self, other, op):
232+
def _apply_operator(self, other, op, *args):
233233
'''
234234
Handle copying metadata to the new :class:`IrregularlySampledSignal`
235235
after a mathematical operation.
236236
'''
237237
self._check_consistency(other)
238238
f = getattr(super(IrregularlySampledSignal, self), op)
239-
new_signal = f(other)
239+
new_signal = f(other, *args)
240240
new_signal._copy_data_complement(self)
241241
return new_signal
242242

@@ -273,40 +273,40 @@ def _copy_data_complement(self, other):
273273
"description", "channel_index", "annotations"):
274274
setattr(self, attr, getattr(other, attr, None))
275275

276-
def __add__(self, other):
276+
def __add__(self, other, *args):
277277
'''
278278
Addition (+)
279279
'''
280-
return self._apply_operator(other, "__add__")
280+
return self._apply_operator(other, "__add__", *args)
281281

282-
def __sub__(self, other):
282+
def __sub__(self, other, *args):
283283
'''
284284
Subtraction (-)
285285
'''
286-
return self._apply_operator(other, "__sub__")
286+
return self._apply_operator(other, "__sub__", *args)
287287

288-
def __mul__(self, other):
288+
def __mul__(self, other, *args):
289289
'''
290290
Multiplication (*)
291291
'''
292-
return self._apply_operator(other, "__mul__")
292+
return self._apply_operator(other, "__mul__", *args)
293293

294-
def __truediv__(self, other):
294+
def __truediv__(self, other, *args):
295295
'''
296296
Float division (/)
297297
'''
298-
return self._apply_operator(other, "__truediv__")
298+
return self._apply_operator(other, "__truediv__", *args)
299299

300-
def __div__(self, other):
300+
def __div__(self, other, *args):
301301
'''
302302
Integer division (//)
303303
'''
304-
return self._apply_operator(other, "__div__")
304+
return self._apply_operator(other, "__div__", *args)
305305

306306
__radd__ = __add__
307307
__rmul__ = __sub__
308308

309-
def __rsub__(self, other):
309+
def __rsub__(self, other, *args):
310310
'''
311311
Backwards subtraction (other-self)
312312
'''

0 commit comments

Comments
 (0)