Python numpy

seed

What does numpy.random.seed(0) do?

choice

numpy.random.choice vs random.choice

ndarray

Array objects
What is the difference between ndarray and array in numpy?

C Implementation

Python overriding class (not instance) special methods
Define Python class from C

NPY_NO_EXPORT PyTypeObject PyArray_Type = {
    PyObject_HEAD_INIT(NULL)
    0,                                          /* ob_size */
    "numpy.ndarray",                            /* tp_name */
    [...]
    (reprfunc)array_repr,                       /* tp_repr */
    [...]
    (reprfunc)array_str,                        /* tp_str */
    (getattrofunc)0,                            /* tp_getattro */
    (setattrofunc)0,                            /* tp_setattro */
    [...]
    (getiterfunc)array_iter,                    /* tp_iter */
    (iternextfunc)0,                            /* tp_iternext */
    array_methods,                              /* tp_methods */
    0,                                          /* tp_members */
    array_getsetlist,                           /* tp_getset */
    [...]
    (initproc)0,                                /* tp_init */
    (allocfunc)array_alloc,                     /* tp_alloc */
    (newfunc)array_new,                         /* tp_new */
    (freefunc)array_free,                       /* tp_free */
    [...]
};
NPY_NO_EXPORT PyObject *
array_str(PyArrayObject *self)
{
   [...]
}

static int
dump_data(...)
{
   [...]
}

String

Converting a numpy.ndarray to string
numpy.array2string

Leave a Reply

Your email address will not be published. Required fields are marked *