[vtk-developers] numpy_to_vtk - contiguous array error
Randy Heiland
heiland at indiana.edu
Mon Nov 8 14:27:26 EST 2010
Can someone shed light on the following error?
>>> teMtx
array([[ 0.00000000e+00, 2.21433476e-07, 1.29724158e-06, ...,
1.13706443e-06, 1.22732023e-06, 1.80498142e-06],
[ 3.49344691e-07, -1.63000845e-07, 4.27805878e-06, ...,
5.69157035e-07, 1.44623813e-07, 1.07077057e-07],
[ 1.12878051e-08, 7.65250526e-06, -3.56727587e-09, ...,
4.44896483e-08, 5.03697289e-07, 2.19654679e-07],
...,
[ 9.13691496e-08, 8.34874369e-08, 6.68844738e-07, ...,
0.00000000e+00, 4.14336786e-06, 1.54018126e-07],
[ 1.56768727e-06, 1.26927141e-07, 1.86173239e-06, ...,
1.76178961e-06, -2.94978281e-06, 2.25371326e-06],
[ 2.13822621e-06, 2.01947558e-08, 6.85551555e-07, ...,
3.93482720e-07, 8.21207577e-07, 0.00000000e+00]])
>>> type(teMtx)
<type 'numpy.ndarray'>
>>> teMtx.size
106929
>>> teMtx.shape
(327, 327)
>>> vtk_arr2 = numpy_to_vtk(teMtx)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<my-path>/Wrapping/Python/vtk/util/numpy_support.py", line 132, in numpy_to_vtk
assert z.flags.contiguous, 'Only contiguous arrays are supported.'
AssertionError: Only contiguous arrays are supported.
However, the following works fine:
>>> m2 = numpy.array([[1.0,2.0],[3.0,4.0]])
>>> type(m2)
<type 'numpy.ndarray'>
>>> m2.size
4
>>> m2.shape
(2, 2)
>>> vtk_arr_m2 = numpy_to_vtk(m2)
>>>
>>> vtk.vtkVersion.GetVTKVersion()
'5.7.0'
teMtx happens to come from a 'scipy.io.loadmat', however, via inspection, it appears to be the same as the simpler m2 array.
thanks, Randy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20101108/aa2dd307/attachment.html>
More information about the vtk-developers
mailing list