margoliashlab / bark

A timeseries data format
GNU General Public License v2.0
1 stars 2 forks source link

dat-segment fails under python 3.7 #53

Closed gfetterman closed 3 years ago

gfetterman commented 6 years ago

Offending command (run on a .dat file generated from an ARF file, normal in every respect): $ dat-segment -o test.csv -t 5 --timedomain pcm_000.dat

Stack trace:

Traceback (most recent call last):
  File "c:\miniconda3\envs\bark-test-py37\lib\site-packages\bark\stream.py", line 18, in array_iterator
    raise StopIteration
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "c:\miniconda3\envs\bark-test-py37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\miniconda3\envs\bark-test-py37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Miniconda3\envs\bark-test-py37\Scripts\dat-segment.exe\__main__.py", line 9, in <module>
  File "c:\miniconda3\envs\bark-test-py37\lib\site-packages\bark\tools\datsegment.py", line 207, in _run
    args.timedomain, args.label)
  File "c:\miniconda3\envs\bark-test-py37\lib\site-packages\bark\tools\datsegment.py", line 123, in main
    start, stop = first_pass(amp_stream, thresh)
  File "c:\miniconda3\envs\bark-test-py37\lib\site-packages\bark\tools\datsegment.py", line 48, in first_pass
    for time, amp in amp_stream:
  File "c:\miniconda3\envs\bark-test-py37\lib\site-packages\bark\tools\datsegment.py", line 38, in amplitude_stream_td
    for buffer in amplitude:
  File "c:\miniconda3\envs\bark-test-py37\lib\site-packages\bark\stream.py", line 58, in __next__
    return next(self.data)
  File "c:\miniconda3\envs\bark-test-py37\lib\site-packages\bark\stream.py", line 365, in rechunk
    for x in stream:
  File "c:\miniconda3\envs\bark-test-py37\lib\site-packages\bark\stream.py", line 58, in __next__
    return next(self.data)
  File "c:\miniconda3\envs\bark-test-py37\lib\site-packages\bark\stream.py", line 58, in __next__
    return next(self.data)
  File "c:\miniconda3\envs\bark-test-py37\lib\site-packages\bark\stream.py", line 365, in rechunk
    for x in stream:
  File "c:\miniconda3\envs\bark-test-py37\lib\site-packages\bark\stream.py", line 58, in __next__
    return next(self.data)
  File "c:\miniconda3\envs\bark-test-py37\lib\site-packages\bark\stream.py", line 189, in _vector_map
    for x in self:
  File "c:\miniconda3\envs\bark-test-py37\lib\site-packages\bark\stream.py", line 58, in __next__
    return next(self.data)
  File "c:\miniconda3\envs\bark-test-py37\lib\site-packages\bark\stream.py", line 136, in <genexpr>
    newdata = (func(x) for x in self)
  File "c:\miniconda3\envs\bark-test-py37\lib\site-packages\bark\stream.py", line 58, in __next__
    return next(self.data)
  File "c:\miniconda3\envs\bark-test-py37\lib\site-packages\bark\stream.py", line 58, in __next__
    return next(self.data)
  File "c:\miniconda3\envs\bark-test-py37\lib\site-packages\bark\stream.py", line 365, in rechunk
    for x in stream:
  File "c:\miniconda3\envs\bark-test-py37\lib\site-packages\bark\stream.py", line 58, in __next__
    return next(self.data)
  File "c:\miniconda3\envs\bark-test-py37\lib\site-packages\bark\stream.py", line 189, in _vector_map
    for x in self:
  File "c:\miniconda3\envs\bark-test-py37\lib\site-packages\bark\stream.py", line 58, in __next__
    return next(self.data)
RuntimeError: generator raised StopIteration

This behavior occurs under both Windows and Linux. The above environment includes:

This behavior does not occur when Python 3.6 is used (with Numpy and Scipy versions identical to the above); however, the following deprecation warning is emitted (and so I suspect they're related):

c:\miniconda3\envs\bark-test-py36\lib\site-packages\scipy\signal\_arraytools.py:45: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use 'arr[tuple(seq)]' instead of 'arr[seq]'. In the future this will be interpreted as an array index, 'arr[np.array(seq)]', which will result either in an error or a different result. b = a[a_slice]

I think this is an easy fix, and will try to get to it soon; until then, use Python <= 3.6

gfetterman commented 3 years ago

Several faults were overlapping in this issue, confusing things.

  1. The original RuntimeError arose from the problem mentioned in #64 and resolved in #65 . The fixes in #65 also resolved this dat-segment error; it no longer occurs under python 3.7 or python 3.8 (regardless of numpy or scipy version).
  2. The DeprecationWarningmentioned under python 3.6 arose from a bug in scipy versions prior to 1.2 interacting with changes to numpy indexing behavior sometime around numpy 1.15 or so. It can be resolved simply by upgrading scipy to 1.2+.

Thus, the problems described in this issue have been resolved.

(Disregard issue renamings just prior.)