osPlanning / omx

Open Matrix (OMX)
https://github.com/osPlanning/omx/wiki
Apache License 2.0
49 stars 18 forks source link

CArray not supported in creation, must convert to numpyarray #6

Closed e-lo closed 11 years ago

e-lo commented 11 years ago

It would be nice to wrap this feature since we are going from h5-->h5 and it should be seamless.

Traceback of error when trying to write CArray"

>>> myfile = omx.openFile(TEST_FILE, 'r')
>>> outFile = omx.openFile(r"testData/sfptam2.omx",'w')
>>> m1in=myfile["1"]
>>> m1in
/1 (CArray(3693, 3693), shuffle, zlib(7)) ''
  atom := Float64Atom(shape=(), dflt=0.0)
  maindim := 0
  flavor := 'numpy'
  byteorder := 'little'
  chunkshape := (8, 3693)
>>> outFile["test1"]=m1in
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "omx\File.py", line 178, in __setitem__
    return self.createMatrix(key, atom, shape, obj=dataset)
  File "omx\File.py", line 35, in createMatrix
    matrix[:] = obj
  File "C:\Python27\Lib\site-packages\tables\array.py", line 672, in __setitem__

    nparr = convertToNPAtom2(value, self.atom)
  File "C:\Python27\Lib\site-packages\tables\utils.py", line 114, in convertToNP
Atom2
    nparr = convertToNPAtom(object, atom, copy)
  File "C:\Python27\Lib\site-packages\tables\utils.py", line 83, in convertToNPA
tom
    nparr = array_of_flavor(arr, 'numpy')
  File "C:\Python27\Lib\site-packages\tables\flavor.py", line 213, in array_of_f
lavor
    return array_of_flavor2(array, flavor_of(array), dst_flavor)
  File "C:\Python27\Lib\site-packages\tables\flavor.py", line 202, in flavor_of
    "supported objects are: %s" % (type_name, supported_descs) )
TypeError: objects of type ``CArray`` are not supported in this context, sorry;
supported objects are: NumPy array, record or scalar; homogeneous list or tuple,
 integer, float, complex or string

Solution:

outFile["test"] = numpy.array((m1in))