The OpenD Programming Language

fromPythonBuffer

Fills the slice (structure) from the python view. The view should be created by $(PGB) that was called with pythonBufferFlags.

nothrow @nogc @trusted
fromPythonBuffer
(
T
size_t N
SliceKind kind
)
(
ref Slice!(T*, N, kind) slice
,
ref const Py_buffer view
)

Parameters

slice Slice!(T*, N, kind)

output ndslice

view Py_buffer

Py_buffer requested

Return Value

one of the input_buffer_* PythonBufferErrorCode on failure and success otherwise.

Examples

import mir.ndslice.slice: Slice;
auto bar(ref const Py_buffer view)
{
    Slice!(const(double)*, 2) mat;
    if (auto error = mat.fromPythonBuffer(view))
    {
        // has null pointer
    }
    return mat;
}

Meta