G-Node/nixpy

DataArray with polynom_coefficients throws numpy error when data type is smaller than 64 bit

plodocus opened this issue · 3 comments

import nixio as nix

f = nix.File.open('/tmp/nix_test', 'w')
b = f.create_block('block', 'block')
intarray = b.create_data_array('intarray', 'data', nix.DataType.Int16, data=[10, 29, 33])
intarray.polynom_coefficients = (0.0, 0.1)

intarray[:]
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-207-19d1bcf43643> in <module>
----> 1 intarray[:]

~/miniconda3/envs/nix/lib/python3.8/site-packages/nixio/data_array.py in __getitem__(self, index)
    137             # if there are coefficients, convert the dtype of the returned data
    138             # array to double
--> 139             raw.dtype = np.float64
    140         self._read_data(raw, count, offset)
    141

ValueError: When changing to a larger dtype, its size must be a divisor of the total size in bytes of the last axis of the array.

I will provide a fix for this shortly.

OK, just realised that this has been fixed in the current master 😄

It is? Well that's good to know 😆
Thanks for the update!

Haha, yes. In 1.4.9 that raw ndarray was first created with the dtype of the DataArray and then later the dtype of raw would be changed... Now that's not necessary anymore because no target array is needed for _read_data.