%{
#include <pygobject.h>
+#include <numpy/arrayobject.h>
PyObject *GLib;
PyTypeObject *IOChannel;
GLib = PyImport_ImportModule("gi.repository.GLib");
IOChannel = (PyTypeObject *) PyObject_GetAttrString(GLib, "IOChannel");
PollFD = (PyTypeObject *) PyObject_GetAttrString(GLib, "PollFD");
+ import_array();
%}
/* Map file objects to file descriptors. */
%}
/* Ignore these methods, we will override them below. */
+%ignore sigrok::Analog::data;
%ignore sigrok::Driver::scan;
%ignore sigrok::InputFormat::create_input;
%ignore sigrok::OutputFormat::create_output;
$self->config_set(key, python_to_variant_by_key(input, key));
}
}
+
+/* Return NumPy array from Analog::data(). */
+%extend sigrok::Analog
+{
+ PyObject * _data()
+ {
+ int nd = 2;
+ npy_intp dims[2];
+ dims[0] = $self->channels().size();
+ dims[1] = $self->num_samples();
+ int typenum = NPY_FLOAT;
+ void *data = $self->data_pointer();
+ return PyArray_SimpleNewFromData(nd, dims, typenum, data);
+ }
+
+%pythoncode
+{
+ data = property(_data)
+}
+}