summaryrefslogtreecommitdiff
path: root/python/gras/GRAS_Block.i
diff options
context:
space:
mode:
Diffstat (limited to 'python/gras/GRAS_Block.i')
-rw-r--r--python/gras/GRAS_Block.i21
1 files changed, 1 insertions, 20 deletions
diff --git a/python/gras/GRAS_Block.i b/python/gras/GRAS_Block.i
index e5d112a..5093f10 100644
--- a/python/gras/GRAS_Block.i
+++ b/python/gras/GRAS_Block.i
@@ -179,32 +179,13 @@ struct BlockPython : Block
%}
////////////////////////////////////////////////////////////////////////
-// Conversion to the numpy array
-////////////////////////////////////////////////////////////////////////
-%pythoncode %{
-
-import numpy
-
-def pointer_to_ndarray(addr, dtype, nitems, readonly=False):
- class array_like:
- __array_interface__ = {
- 'data' : (addr, readonly),
- 'typestr' : dtype.base.str,
- 'descr' : dtype.base.descr,
- 'shape' : (nitems,) + dtype.shape,
- 'strides' : None,
- 'version' : 3,
- }
- return numpy.asarray(array_like()).view(dtype.base)
-%}
-
-////////////////////////////////////////////////////////////////////////
// Python overload for adding pythonic interfaces
////////////////////////////////////////////////////////////////////////
%pythoncode %{
import numpy
import traceback
+from GRAS_Utils import pointer_to_ndarray
def sig_to_dtype_sig(sig):
if sig is None: sig = ()