numpy 2.0.0
|
#include <Python.h>
#include "structmember.h"
#include "numpy/arrayobject.h"
#include "numpy/arrayscalars.h"
#include "npy_config.h"
#include "numpy/npy_3kcompat.h"
#include "_datetime.h"
#include "common.h"
#include "descriptor.h"
Defines | |
#define | PY_SSIZE_T_CLEAN |
#define | NPY_NO_DEPRECATED_API |
#define | _MULTIARRAYMODULE |
#define | NPY_NO_PREFIX |
#define | NPY_NEXT_ALIGNED_OFFSET(offset, alignment) (((offset) + (alignment) - 1) & (-(alignment))) |
#define | _chk_byteorder(arg) |
#define | _ARGSTR_ "(icOOOiiiO)" |
#define | _ARGSTR_ "(icOOOiii)" |
#define | _ARGSTR_ "(icOOOii)" |
#define | _ARGSTR_ "(icOOii)" |
#define | _ARGSTR_ "(cOOii)" |
Functions | |
static PyArray_Descr * | _use_inherit (PyArray_Descr *type, PyObject *newobj, int *errflag) |
NPY_NO_EXPORT PyArray_Descr * | _arraydescr_fromobj (PyObject *obj) |
NPY_NO_EXPORT PyObject * | array_set_typeDict (PyObject *NPY_UNUSED(ignored), PyObject *args) |
static int | _check_for_commastring (char *type, Py_ssize_t len) |
static int | is_datetime_typestr (char *type, Py_ssize_t len) |
static PyArray_Descr * | _convert_from_tuple (PyObject *obj) |
static PyArray_Descr * | _convert_from_array_descr (PyObject *obj, int align) |
static PyArray_Descr * | _convert_from_list (PyObject *obj, int align) |
static PyArray_Descr * | _convert_from_commastring (PyObject *obj, int align) |
static int | _is_tuple_of_integers (PyObject *obj) |
static int | validate_object_field_overlap (PyArray_Descr *dtype) |
static PyArray_Descr * | _use_fields_dict (PyObject *obj, int align) |
static PyArray_Descr * | _convert_from_dict (PyObject *obj, int align) |
NPY_NO_EXPORT PyArray_Descr * | PyArray_DescrNewFromType (int type_num) |
NPY_NO_EXPORT int | PyArray_DescrConverter2 (PyObject *obj, PyArray_Descr **at) |
NPY_NO_EXPORT int | PyArray_DescrConverter (PyObject *obj, PyArray_Descr **at) |
NPY_NO_EXPORT PyArray_Descr * | PyArray_DescrNew (PyArray_Descr *base) |
static void | arraydescr_dealloc (PyArray_Descr *self) |
static PyObject * | arraydescr_subdescr_get (PyArray_Descr *self) |
NPY_NO_EXPORT PyObject * | arraydescr_protocol_typestr_get (PyArray_Descr *self) |
static PyObject * | arraydescr_typename_get (PyArray_Descr *self) |
static PyObject * | arraydescr_base_get (PyArray_Descr *self) |
static PyObject * | arraydescr_shape_get (PyArray_Descr *self) |
NPY_NO_EXPORT PyObject * | arraydescr_protocol_descr_get (PyArray_Descr *self) |
static PyObject * | arraydescr_isbuiltin_get (PyArray_Descr *self) |
static int | _arraydescr_isnative (PyArray_Descr *self) |
static PyObject * | arraydescr_isnative_get (PyArray_Descr *self) |
static PyObject * | arraydescr_isalignedstruct_get (PyArray_Descr *self) |
static PyObject * | arraydescr_fields_get (PyArray_Descr *self) |
static PyObject * | arraydescr_metadata_get (PyArray_Descr *self) |
static PyObject * | arraydescr_hasobject_get (PyArray_Descr *self) |
static PyObject * | arraydescr_names_get (PyArray_Descr *self) |
static int | arraydescr_names_set (PyArray_Descr *self, PyObject *val) |
static int | _invalid_metadata_check (PyObject *metadata) |
static PyObject * | arraydescr_new (PyTypeObject *NPY_UNUSED(subtype), PyObject *args, PyObject *kwds) |
static PyObject * | _get_pickleabletype_from_datetime_metadata (PyArray_Descr *dtype) |
static PyObject * | arraydescr_reduce (PyArray_Descr *self, PyObject *NPY_UNUSED(args)) |
static int | _descr_find_object (PyArray_Descr *self) |
static PyObject * | arraydescr_setstate (PyArray_Descr *self, PyObject *args) |
NPY_NO_EXPORT int | PyArray_DescrAlignConverter (PyObject *obj, PyArray_Descr **at) |
NPY_NO_EXPORT int | PyArray_DescrAlignConverter2 (PyObject *obj, PyArray_Descr **at) |
NPY_NO_EXPORT PyArray_Descr * | PyArray_DescrNewByteorder (PyArray_Descr *self, char newendian) |
static PyObject * | arraydescr_newbyteorder (PyArray_Descr *self, PyObject *args) |
static int | is_dtype_struct_simple_unaligned_layout (PyArray_Descr *dtype) |
static PyObject * | arraydescr_struct_list_str (PyArray_Descr *dtype) |
static PyObject * | arraydescr_struct_dict_str (PyArray_Descr *dtype) |
static PyObject * | arraydescr_struct_str (PyArray_Descr *dtype) |
static PyObject * | arraydescr_subarray_str (PyArray_Descr *dtype) |
static PyObject * | arraydescr_str (PyArray_Descr *dtype) |
static PyObject * | arraydescr_struct_repr (PyArray_Descr *dtype) |
NPY_NO_EXPORT PyObject * | arraydescr_short_construction_repr (PyArray_Descr *dtype) |
static PyObject * | arraydescr_repr (PyArray_Descr *dtype) |
static PyObject * | arraydescr_richcompare (PyArray_Descr *self, PyObject *other, int cmp_op) |
static Py_ssize_t | descr_length (PyObject *self0) |
static PyObject * | descr_repeat (PyObject *self, Py_ssize_t length) |
static PyObject * | descr_subscript (PyArray_Descr *self, PyObject *op) |
Variables | |
static PyObject * | typeDict = NULL |
static PyMemberDef | arraydescr_members [] |
static PyGetSetDef | arraydescr_getsets [] |
static PyMethodDef | arraydescr_methods [] |
static PySequenceMethods | descr_as_sequence |
static PyMappingMethods | descr_as_mapping |
NPY_NO_EXPORT PyTypeObject | PyArrayDescr_Type |
#define _ARGSTR_ "(icOOOiiiO)" |
#define _ARGSTR_ "(cOOii)" |
#define _ARGSTR_ "(icOOOiii)" |
#define _ARGSTR_ "(icOOOii)" |
#define _ARGSTR_ "(icOOii)" |
#define _chk_byteorder | ( | arg | ) |
(arg == '>' || arg == '<' || \ arg == '|' || arg == '=')
#define _MULTIARRAYMODULE |
#define NPY_NEXT_ALIGNED_OFFSET | ( | offset, | |
alignment | |||
) | (((offset) + (alignment) - 1) & (-(alignment))) |
#define NPY_NO_DEPRECATED_API |
#define NPY_NO_PREFIX |
#define PY_SSIZE_T_CLEAN |
NPY_NO_EXPORT PyArray_Descr* _arraydescr_fromobj | ( | PyObject * | obj | ) |
static int _arraydescr_isnative | ( | PyArray_Descr * | self | ) | [static] |
References arraydescr_base_get(), arraydescr_fields_get(), arraydescr_isalignedstruct_get(), arraydescr_isbuiltin_get(), arraydescr_isnative_get(), arraydescr_metadata_get(), arraydescr_protocol_descr_get(), arraydescr_protocol_typestr_get(), arraydescr_shape_get(), arraydescr_subdescr_get(), and arraydescr_typename_get().
Referenced by arraydescr_protocol_typestr_get(), and arraydescr_typename_get().
static int _check_for_commastring | ( | char * | type, |
Py_ssize_t | len | ||
) | [static] |
static PyArray_Descr* _convert_from_array_descr | ( | PyObject * | obj, |
int | align | ||
) | [static] |
static PyArray_Descr* _convert_from_commastring | ( | PyObject * | obj, |
int | align | ||
) | [static] |
References _is_tuple_of_integers(), _PyArray_Descr::elsize, _PyArray_Descr::fields, _PyArray_Descr::flags, _PyArray_Descr::names, PyArray_DescrConverter(), PyArray_DescrNew(), PyArray_IsScalar, and PyDataType_HASFIELDS.
static PyArray_Descr* _convert_from_dict | ( | PyObject * | obj, |
int | align | ||
) | [static] |
static PyArray_Descr* _convert_from_list | ( | PyObject * | obj, |
int | align | ||
) | [static] |
static PyArray_Descr* _convert_from_tuple | ( | PyObject * | obj | ) | [static] |
References _PyArray_Descr::elsize, error_converting, PyArray_DESCR_REPLACE, PyArray_PyIntAsInt(), PyArray_UNICODE, and _PyArray_Descr::type_num.
static int _descr_find_object | ( | PyArray_Descr * | self | ) | [static] |
static PyObject* _get_pickleabletype_from_datetime_metadata | ( | PyArray_Descr * | dtype | ) | [static] |
static int _invalid_metadata_check | ( | PyObject * | metadata | ) | [static] |
static int _is_tuple_of_integers | ( | PyObject * | obj | ) | [static] |
Referenced by _convert_from_commastring().
static PyArray_Descr* _use_fields_dict | ( | PyObject * | obj, |
int | align | ||
) | [static] |
static PyArray_Descr * _use_inherit | ( | PyArray_Descr * | type, |
PyObject * | newobj, | ||
int * | errflag | ||
) | [static] |
References PyDataType_REFCHK.
NPY_NO_EXPORT PyObject* array_set_typeDict | ( | PyObject * | NPY_UNUSEDignored, |
PyObject * | args | ||
) |
static PyObject* arraydescr_base_get | ( | PyArray_Descr * | self | ) | [static] |
References PyDataType_HASFIELDS.
Referenced by _arraydescr_isnative().
static void arraydescr_dealloc | ( | PyArray_Descr * | self | ) | [static] |
static PyObject* arraydescr_fields_get | ( | PyArray_Descr * | self | ) | [static] |
Referenced by _arraydescr_isnative().
static PyObject* arraydescr_hasobject_get | ( | PyArray_Descr * | self | ) | [static] |
static PyObject* arraydescr_isalignedstruct_get | ( | PyArray_Descr * | self | ) | [static] |
Referenced by _arraydescr_isnative().
static PyObject* arraydescr_isbuiltin_get | ( | PyArray_Descr * | self | ) | [static] |
Referenced by _arraydescr_isnative().
static PyObject* arraydescr_isnative_get | ( | PyArray_Descr * | self | ) | [static] |
References arraydescr_names_get(), and arraydescr_names_set().
Referenced by _arraydescr_isnative().
static PyObject* arraydescr_metadata_get | ( | PyArray_Descr * | self | ) | [static] |
Referenced by _arraydescr_isnative().
static PyObject* arraydescr_names_get | ( | PyArray_Descr * | self | ) | [static] |
Referenced by arraydescr_isnative_get().
static int arraydescr_names_set | ( | PyArray_Descr * | self, |
PyObject * | val | ||
) | [static] |
Referenced by arraydescr_isnative_get().
static PyObject* arraydescr_new | ( | PyTypeObject * | NPY_UNUSEDsubtype, |
PyObject * | args, | ||
PyObject * | kwds | ||
) | [static] |
static PyObject* arraydescr_newbyteorder | ( | PyArray_Descr * | self, |
PyObject * | args | ||
) | [static] |
NPY_NO_EXPORT PyObject* arraydescr_protocol_descr_get | ( | PyArray_Descr * | self | ) |
NPY_NO_EXPORT PyObject* arraydescr_protocol_typestr_get | ( | PyArray_Descr * | self | ) |
References _arraydescr_isnative(), NPY_TITLE_KEY, PyArray_ISNBO, and PyDataType_HASFIELDS.
Referenced by _arraydescr_isnative().
static PyObject* arraydescr_reduce | ( | PyArray_Descr * | self, |
PyObject * | NPY_UNUSEDargs | ||
) | [static] |
<
static PyObject* arraydescr_repr | ( | PyArray_Descr * | dtype | ) | [static] |
static PyObject* arraydescr_richcompare | ( | PyArray_Descr * | self, |
PyObject * | other, | ||
int | cmp_op | ||
) | [static] |
static PyObject* arraydescr_setstate | ( | PyArray_Descr * | self, |
PyObject * | args | ||
) | [static] |
static PyObject* arraydescr_shape_get | ( | PyArray_Descr * | self | ) | [static] |
References DEPRECATE, and PyDataType_HASFIELDS.
Referenced by _arraydescr_isnative().
NPY_NO_EXPORT PyObject* arraydescr_short_construction_repr | ( | PyArray_Descr * | dtype | ) |
References descr_length(), and descr_subscript().
static PyObject* arraydescr_str | ( | PyArray_Descr * | dtype | ) | [static] |
References PyBytes_AsString, and PyUString_Check.
Referenced by arraydescr_struct_dict_str(), and arraydescr_subarray_str().
static PyObject* arraydescr_struct_dict_str | ( | PyArray_Descr * | dtype | ) | [static] |
References arraydescr_str(), arraydescr_struct_repr(), PyDataType_HASFIELDS, PyDataType_HASSUBARRAY, PyUString_Concat, PyUString_ConcatAndDel, and PyUString_FromString.
Referenced by arraydescr_newbyteorder().
static PyObject* arraydescr_struct_list_str | ( | PyArray_Descr * | dtype | ) | [static] |
References PyUString_FromString.
Referenced by arraydescr_newbyteorder().
static PyObject* arraydescr_struct_repr | ( | PyArray_Descr * | dtype | ) | [static] |
Referenced by arraydescr_struct_dict_str().
static PyObject* arraydescr_struct_str | ( | PyArray_Descr * | dtype | ) | [static] |
static PyObject* arraydescr_subarray_str | ( | PyArray_Descr * | dtype | ) | [static] |
References arraydescr_str(), PyBytes_AsString, and PyDataType_HASFIELDS.
static PyObject* arraydescr_subdescr_get | ( | PyArray_Descr * | self | ) | [static] |
Referenced by _arraydescr_isnative().
static PyObject* arraydescr_typename_get | ( | PyArray_Descr * | self | ) | [static] |
static Py_ssize_t descr_length | ( | PyObject * | self0 | ) | [static] |
Referenced by arraydescr_short_construction_repr().
static PyObject* descr_repeat | ( | PyObject * | self, |
Py_ssize_t | length | ||
) | [static] |
static PyObject* descr_subscript | ( | PyArray_Descr * | self, |
PyObject * | op | ||
) | [static] |
Referenced by arraydescr_short_construction_repr().
static int is_datetime_typestr | ( | char * | type, |
Py_ssize_t | len | ||
) | [static] |
static int is_dtype_struct_simple_unaligned_layout | ( | PyArray_Descr * | dtype | ) | [static] |
Referenced by arraydescr_newbyteorder().
NPY_NO_EXPORT int PyArray_DescrAlignConverter | ( | PyObject * | obj, |
PyArray_Descr ** | at | ||
) |
None goes to DEFAULT type.
any object with the .fields attribute and/or .itemsize attribute (if the
naming). If itemsize is given it must be >= size computed from fields
The .fields attribute must return a convertible dictionary if present. Result inherits from PyArray_VOID.
NPY_NO_EXPORT int PyArray_DescrAlignConverter2 | ( | PyObject * | obj, |
PyArray_Descr ** | at | ||
) |
NPY_NO_EXPORT int PyArray_DescrConverter | ( | PyObject * | obj, |
PyArray_Descr ** | at | ||
) |
This function takes a Python object representing a type and converts it to a the correct PyArray_Descr * structure to describe the type.
Many objects can be used to represent a data-type which in NumPy is quite a flexible concept.
This is the central code that converts Python objects to Type-descriptor objects that are used throughout numpy.
Returns a new reference in *at, but the returned should not be modified as it may be one of the canonical immutable objects or a reference to the input obj.
Referenced by _convert_from_commastring(), array_nbytes_get(), and PyArray_DescrConverter2().
NPY_NO_EXPORT int PyArray_DescrConverter2 | ( | PyObject * | obj, |
PyArray_Descr ** | at | ||
) |
References PY_FAIL, and PyArray_DescrConverter().
Referenced by array__get_ndarray_c_version(), and array_cumsum().
NPY_NO_EXPORT PyArray_Descr* PyArray_DescrNew | ( | PyArray_Descr * | base | ) |
Referenced by _convert_from_commastring(), and array_base_get().
NPY_NO_EXPORT PyArray_Descr* PyArray_DescrNewByteorder | ( | PyArray_Descr * | self, |
char | newendian | ||
) |
altered: no arguments: The byteorder is swapped (in all subfields as well) single argument: The byteorder is forced to the given state (in all subfields as well)
Valid states: ('big', '>') or ('little' or '<') ('native', or '=')
If a descr structure with | is encountered it's own byte-order is not changed but any fields are:
Deep bytorder change of a data-type descriptor * Leaves reference count of self unchanged --- does not DECREF self *
Referenced by npyiter_apply_forced_iteration_order().
NPY_NO_EXPORT PyArray_Descr* PyArray_DescrNewFromType | ( | int | type_num | ) |
static int validate_object_field_overlap | ( | PyArray_Descr * | dtype | ) | [static] |
PyGetSetDef arraydescr_getsets[] [static] |
PyMemberDef arraydescr_members[] [static] |
{ {"type", T_OBJECT, offsetof(PyArray_Descr, typeobj), READONLY, NULL}, {"kind", T_CHAR, offsetof(PyArray_Descr, kind), READONLY, NULL}, {"char", T_CHAR, offsetof(PyArray_Descr, type), READONLY, NULL}, {"num", T_INT, offsetof(PyArray_Descr, type_num), READONLY, NULL}, {"byteorder", T_CHAR, offsetof(PyArray_Descr, byteorder), READONLY, NULL}, {"itemsize", T_INT, offsetof(PyArray_Descr, elsize), READONLY, NULL}, {"alignment", T_INT, offsetof(PyArray_Descr, alignment), READONLY, NULL}, {"flags", T_INT, offsetof(PyArray_Descr, flags), READONLY, NULL}, {NULL, 0, 0, 0, NULL}, }
PyMethodDef arraydescr_methods[] [static] |
{ {"__reduce__", (PyCFunction)arraydescr_reduce, METH_VARARGS, NULL}, {"__setstate__", (PyCFunction)arraydescr_setstate, METH_VARARGS, NULL}, {"newbyteorder", (PyCFunction)arraydescr_newbyteorder, METH_VARARGS, NULL}, {NULL, NULL, 0, NULL} }
PyMappingMethods descr_as_mapping [static] |
{ descr_length, (binaryfunc)descr_subscript, (objobjargproc)NULL, }
PySequenceMethods descr_as_sequence [static] |
{ descr_length, (binaryfunc)NULL, descr_repeat, NULL, NULL, NULL, NULL, 0, 0, 0, }
NPY_NO_EXPORT PyTypeObject PyArrayDescr_Type |
PyObject* typeDict = NULL [static] |