xman/numpy-posit

np.load cannot properly interpret the dtype as posit8

arnabsanyal opened this issue · 1 comments

After saving a numpy array of dtype 'posit8' using numpy.savez, I am having trouble loading it back up using numpy.load. I get the following error,

Traceback (most recent call last):
  File "/home/neo/src/numpyposit/numpy/lib/format.py", line 527, in _read_array_header
    dtype = numpy.dtype(d['descr'])
TypeError: data type "<f1" not understood

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neo/src/numpyposit/numpy/lib/npyio.py", line 251, in __getitem__
    pickle_kwargs=self.pickle_kwargs)
  File "/home/neo/src/numpyposit/numpy/lib/format.py", line 642, in read_array
    shape, fortran_order, dtype = _read_array_header(fp, version)
  File "/home/neo/src/numpyposit/numpy/lib/format.py", line 530, in _read_array_header
    raise ValueError(msg % (d['descr'],))
ValueError: descr is not a valid dtype descriptor: '<f1'

There is a workaround that I am currently using. Converting numpy.positx to numpy.uintx and then storing it as a npz pickle file. After loading I convert it back to dtype numpy.positx