import numpy as np
import turicreate as tc
sf = tc.SFrame()
sf['data'] = [np.zeros((4,4,5))]
sf['data'].astype(tc.Image)
Expected:
Perhaps this should give an error, but the error message should be readable.
Actual:
Out[41]: ---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
/Users/zach/turicreate/deps/env/lib/python2.7/site-packages/IPython/core/formatters.pyc in __call__(self, obj)
697 type_pprinters=self.type_printers,
698 deferred_pprinters=self.deferred_printers)
--> 699 printer.pretty(obj)
700 printer.flush()
701 return stream.getvalue()
/Users/zach/turicreate/deps/env/lib/python2.7/site-packages/IPython/lib/pretty.pyc in pretty(self, obj)
401 if cls is not object \
402 and callable(cls.__dict__.get('__repr__')):
--> 403 return _repr_pprint(obj, self, cycle)
404
405 return _default_pprint(obj, self, cycle)
/Users/zach/turicreate/deps/env/lib/python2.7/site-packages/IPython/lib/pretty.pyc in _repr_pprint(obj, p, cycle)
701 """A pprint that just redirects to the normal repr function."""
702 # Find newlines and replace them with p.break_()
--> 703 output = repr(obj)
704 for idx,output_line in enumerate(output.splitlines()):
705 if idx:
/Users/zach/turicreate/release/src/unity/python/turicreate/data_structures/sarray.py in __repr__(self)
745 Returns a string description of the SArray.
746 """
--> 747 data_str = self.__str__()
748 ret = "dtype: " + str(self.dtype.__name__) + "\n"
749 if (self.__has_size__()):
/Users/zach/turicreate/release/src/unity/python/turicreate/data_structures/sarray.py in __str__(self)
761 # If sarray is image, take head of elements casted to string.
762 if self.dtype == _Image:
--> 763 headln = str(list(self.astype(str).head(100)))
764 else:
765 if sys.version_info.major < 3:
/Users/zach/turicreate/release/src/unity/python/turicreate/data_structures/sarray.py in head(self, n)
1364 [0, 1, 2, 3, 4]
1365 """
-> 1366 return SArray(_proxy=self.__proxy__.head(n))
1367
1368 def vector_slice(self, start, end=None):
/Users/zach/turicreate/release/src/unity/python/turicreate/cython/cy_sarray.pyx in turicreate.cython.cy_sarray.UnitySArrayProxy.head()
110 return self.thisptr.has_size()
111
--> 112 cpdef head(self, size_t length):
113 cdef unity_sarray_base_ptr proxy
114 with nogil:
/Users/zach/turicreate/release/src/unity/python/turicreate/cython/cy_sarray.pyx in turicreate.cython.cy_sarray.UnitySArrayProxy.head()
113 cdef unity_sarray_base_ptr proxy
114 with nogil:
--> 115 proxy = self.thisptr.head(length)
116 return create_proxy_wrapper_from_existing_proxy(proxy)
117
RuntimeError: AL��
Note:
If you modify the code so that the shape of the ndarray is 4,4,4 instead of 4,4,5, there is no error and instead an SArray is returned, containing a single 4x4 image. This seems like the correct behavior...?
The bad error message still reproduces with TuriCreate 6.4. I'm not sure what the correct behavior is here. I think it would be best to just error out, with an informative error message.
Repro steps:
Expected: Perhaps this should give an error, but the error message should be readable.
Actual:
Note:
If you modify the code so that the shape of the ndarray is 4,4,4 instead of 4,4,5, there is no error and instead an SArray is returned, containing a single 4x4 image. This seems like the correct behavior...?