uwmadison-chm / bioread

Utilities to work with files from BIOPAC's AcqKnowlege software
MIT License
66 stars 23 forks source link

NumPy 1.7 - ValueError when reading uncompressed data #1

Closed naegelejd closed 10 years ago

naegelejd commented 11 years ago

From SHA: b957a03815c0f68f3e1d471cd6766d586bcce8e7, line 251 of readers.py, __running_counts method of AcqReader class.

counts[sample_indexes == i] = my_range

is invalid in NumPy 1.7 because my_range is not the same shape as an element of counts.

With an input of sample_indexes = np.array([0, 1, 2]) to the __running_counts method, in version of NumPy < 1.7, counts = np.array([0, 0, 0]). In NumPy 1.7, assigning to counts results in:

ValueError: NumPy boolean array indexing assignment cannot assign 3 input values to the 1 output values where the mask is true

I'm not actually sure, but should it be

counts[sample_indexes == i] = my_range[i]

? With the same input for sample_indexes, counts = np.array([0, 1, 2]), which would be different behavior.

njvack commented 11 years ago

Hm! Thanks for reporting this -- I'm a bit swamped with other projects at the moment but I'll try to look at it soon.

njvack commented 11 years ago

In my initial testing, my_range[i] does seem to fix it. Why did I ever use my_range?

I'll need to think a little more before I push this one out.

njvack commented 10 years ago

I've finally come back to this, and merged this change in 43dedbefc08fe86d5e7d98e8346ed091c6f750e1.

Thanks!