bh107 / bohrium

Automatic parallelization of Python/NumPy, C, and C++ codes on Linux and MacOSX
http://www.bh107.org
Apache License 2.0
220 stars 31 forks source link

"the base object isn't a bohrium array" when reading from HDF5 #615

Open dionhaefner opened 5 years ago

dionhaefner commented 5 years ago

Test script:

import tempfile

import numpy as np
import bohrium as bh
import h5py

if __name__ == '__main__':
    with tempfile.NamedTemporaryFile() as tmp:
        data = np.random.rand(100, 100)

        with h5py.File(tmp, 'w') as f:
            f['test'] = data

        out = bh.empty((100, 100))
        with h5py.File(tmp) as f:
            out[...] = f['test'][...]

        assert np.array_equal(out.copy2numpy(), data)

Output:

$ python bh_bug.py
bh_bug.py:17: UserWarning: Bohrium does not support the dtype 'float64', the new array will be a regular NumPy array.
  out[...] = f['test']
Traceback (most recent call last):
  File "bh_bug.py", line 17, in <module>
    out[...] = f['test']
  File "bohrium/ufuncs.pyx", line 55, in bohrium.ufuncs.setitem
  File "bohrium/bhary.pyx", line 95, in bohrium.bhary.fix_biclass_wrapper.inner
  File "bohrium/ufuncs.pyx", line 103, in bohrium.ufuncs.assign
ValueError: get_base() -  the base object isn't a bohrium array!

Works fine if I do

-         out[...] = f['test'][...]
+         out[...] = f['test'][...].astype(out.dtype)