numpy 2.0.0
|
#include "Python.h"
#include "npy_config.h"
#include "numpy/npy_3kcompat.h"
#include "numpy/ufuncobject.h"
#include "ufunc_type_resolution.h"
Data Structures | |
struct | _ufunc_masker_data |
Defines | |
#define | _UMATHMODULE |
#define | NPY_NO_DEPRECATED_API |
Functions | |
static const char * | npy_casting_to_string (NPY_CASTING casting) |
NPY_NO_EXPORT int | PyUFunc_ValidateCasting (PyUFuncObject *ufunc, NPY_CASTING casting, PyArrayObject **operands, PyArray_Descr **dtypes) |
static PyArray_Descr * | ensure_dtype_nbo (PyArray_Descr *type) |
NPY_NO_EXPORT int | PyUFunc_DefaultTypeResolution (PyUFuncObject *ufunc, NPY_CASTING casting, PyArrayObject **operands, PyObject *type_tup, PyArray_Descr **out_dtypes, PyUFuncGenericFunction *out_innerloop, void **out_innerloopdata) |
NPY_NO_EXPORT int | PyUFunc_SimpleBinaryComparisonTypeResolution (PyUFuncObject *ufunc, NPY_CASTING casting, PyArrayObject **operands, PyObject *type_tup, PyArray_Descr **out_dtypes, PyUFuncGenericFunction *out_innerloop, void **out_innerloopdata) |
NPY_NO_EXPORT int | PyUFunc_SimpleUnaryOperationTypeResolution (PyUFuncObject *ufunc, NPY_CASTING casting, PyArrayObject **operands, PyObject *type_tup, PyArray_Descr **out_dtypes, PyUFuncGenericFunction *out_innerloop, void **out_innerloopdata) |
NPY_NO_EXPORT int | PyUFunc_OnesLikeTypeResolution (PyUFuncObject *ufunc, NPY_CASTING NPY_UNUSED(casting), PyArrayObject **operands, PyObject *type_tup, PyArray_Descr **out_dtypes, PyUFuncGenericFunction *out_innerloop, void **out_innerloopdata) |
NPY_NO_EXPORT int | PyUFunc_SimpleBinaryOperationTypeResolution (PyUFuncObject *ufunc, NPY_CASTING casting, PyArrayObject **operands, PyObject *type_tup, PyArray_Descr **out_dtypes, PyUFuncGenericFunction *out_innerloop, void **out_innerloopdata) |
NPY_NO_EXPORT int | PyUFunc_AbsoluteTypeResolution (PyUFuncObject *ufunc, NPY_CASTING casting, PyArrayObject **operands, PyObject *type_tup, PyArray_Descr **out_dtypes, PyUFuncGenericFunction *out_innerloop, void **out_innerloopdata) |
static PyObject * | get_datetime_metacobj_from_dtype (PyArray_Descr *dtype) |
static PyArray_Descr * | timedelta_dtype_with_copied_meta (PyArray_Descr *dtype) |
NPY_NO_EXPORT int | PyUFunc_AdditionTypeResolution (PyUFuncObject *ufunc, NPY_CASTING casting, PyArrayObject **operands, PyObject *type_tup, PyArray_Descr **out_dtypes, PyUFuncGenericFunction *out_innerloop, void **out_innerloopdata) |
NPY_NO_EXPORT int | PyUFunc_SubtractionTypeResolution (PyUFuncObject *ufunc, NPY_CASTING casting, PyArrayObject **operands, PyObject *type_tup, PyArray_Descr **out_dtypes, PyUFuncGenericFunction *out_innerloop, void **out_innerloopdata) |
NPY_NO_EXPORT int | PyUFunc_MultiplicationTypeResolution (PyUFuncObject *ufunc, NPY_CASTING casting, PyArrayObject **operands, PyObject *type_tup, PyArray_Descr **out_dtypes, PyUFuncGenericFunction *out_innerloop, void **out_innerloopdata) |
NPY_NO_EXPORT int | PyUFunc_DivisionTypeResolution (PyUFuncObject *ufunc, NPY_CASTING casting, PyArrayObject **operands, PyObject *type_tup, PyArray_Descr **out_dtypes, PyUFuncGenericFunction *out_innerloop, void **out_innerloopdata) |
static NpyAuxData * | ufunc_masker_data_clone (NpyAuxData *data) |
static void | unmasked_ufunc_loop_as_masked (char **args, npy_intp *dimensions, npy_intp *steps, NpyAuxData *innerloopdata) |
NPY_NO_EXPORT int | PyUFunc_DefaultTypeResolutionMasked (PyUFuncObject *ufunc, NPY_CASTING casting, PyArrayObject **operands, PyObject *type_tup, PyArray_Descr **out_dtypes, PyUFuncGenericMaskedFunction *out_innerloop, NpyAuxData **out_innerloopdata) |
static int | ufunc_loop_matches (PyUFuncObject *self, PyArrayObject **op, NPY_CASTING input_casting, NPY_CASTING output_casting, int any_object, int use_min_scalar, int *types, int *out_no_castable_output, char *out_err_src_typecode, char *out_err_dst_typecode) |
static int | set_ufunc_loop_data_types (PyUFuncObject *self, PyArrayObject **op, PyArray_Descr **out_dtype, int *types) |
static int | find_ufunc_matching_userloop (PyUFuncObject *self, PyArrayObject **op, NPY_CASTING input_casting, NPY_CASTING output_casting, int any_object, int use_min_scalar, PyArray_Descr **out_dtype, PyUFuncGenericFunction *out_innerloop, void **out_innerloopdata, int *out_no_castable_output, char *out_err_src_typecode, char *out_err_dst_typecode) |
static int | find_ufunc_specified_userloop (PyUFuncObject *self, int n_specified, int *specified_types, PyArrayObject **op, NPY_CASTING casting, int any_object, int use_min_scalar, PyArray_Descr **out_dtype, PyUFuncGenericFunction *out_innerloop, void **out_innerloopdata) |
static int | dtype_kind_to_simplified_ordering (char kind) |
static int | should_use_min_scalar (PyArrayObject **op, int nop) |
NPY_NO_EXPORT int | find_best_ufunc_inner_loop (PyUFuncObject *self, PyArrayObject **op, NPY_CASTING input_casting, NPY_CASTING output_casting, int any_object, PyArray_Descr **out_dtype, PyUFuncGenericFunction *out_innerloop, void **out_innerloopdata) |
NPY_NO_EXPORT int | find_specified_ufunc_inner_loop (PyUFuncObject *self, PyObject *type_tup, PyArrayObject **op, NPY_CASTING casting, int any_object, PyArray_Descr **out_dtype, PyUFuncGenericFunction *out_innerloop, void **out_innerloopdata) |
#define _UMATHMODULE |
#define NPY_NO_DEPRECATED_API |
static int dtype_kind_to_simplified_ordering | ( | char | kind | ) | [static] |
References PyArray_DescrFromType(), and _PyArray_Descr::type_num.
Referenced by set_ufunc_loop_data_types().
static PyArray_Descr* ensure_dtype_nbo | ( | PyArray_Descr * | type | ) | [static] |
Referenced by PyUFunc_MultiplicationTypeResolution().
NPY_NO_EXPORT int find_best_ufunc_inner_loop | ( | PyUFuncObject * | self, |
PyArrayObject ** | op, | ||
NPY_CASTING | input_casting, | ||
NPY_CASTING | output_casting, | ||
int | any_object, | ||
PyArray_Descr ** | out_dtype, | ||
PyUFuncGenericFunction * | out_innerloop, | ||
void ** | out_innerloopdata | ||
) |
<blockquote>
</blockquote>
Referenced by PyUFunc_DefaultTypeResolution().
NPY_NO_EXPORT int find_specified_ufunc_inner_loop | ( | PyUFuncObject * | self, |
PyObject * | type_tup, | ||
PyArrayObject ** | op, | ||
NPY_CASTING | casting, | ||
int | any_object, | ||
PyArray_Descr ** | out_dtype, | ||
PyUFuncGenericFunction * | out_innerloop, | ||
void ** | out_innerloopdata | ||
) |
Referenced by PyUFunc_DefaultTypeResolution().
static int find_ufunc_matching_userloop | ( | PyUFuncObject * | self, |
PyArrayObject ** | op, | ||
NPY_CASTING | input_casting, | ||
NPY_CASTING | output_casting, | ||
int | any_object, | ||
int | use_min_scalar, | ||
PyArray_Descr ** | out_dtype, | ||
PyUFuncGenericFunction * | out_innerloop, | ||
void ** | out_innerloopdata, | ||
int * | out_no_castable_output, | ||
char * | out_err_src_typecode, | ||
char * | out_err_dst_typecode | ||
) | [static] |
References NPY_MAXARGS, set_ufunc_loop_data_types(), should_use_min_scalar(), and ufunc_loop_matches().
static int find_ufunc_specified_userloop | ( | PyUFuncObject * | self, |
int | n_specified, | ||
int * | specified_types, | ||
PyArrayObject ** | op, | ||
NPY_CASTING | casting, | ||
int | any_object, | ||
int | use_min_scalar, | ||
PyArray_Descr ** | out_dtype, | ||
PyUFuncGenericFunction * | out_innerloop, | ||
void ** | out_innerloopdata | ||
) | [static] |
static PyObject* get_datetime_metacobj_from_dtype | ( | PyArray_Descr * | dtype | ) | [static] |
static const char* npy_casting_to_string | ( | NPY_CASTING | casting | ) | [static] |
References NPY_EQUIV_CASTING, NPY_NO_CASTING, NPY_SAFE_CASTING, NPY_SAME_KIND_CASTING, and NPY_UNSAFE_CASTING.
NPY_NO_EXPORT int PyUFunc_AbsoluteTypeResolution | ( | PyUFuncObject * | ufunc, |
NPY_CASTING | casting, | ||
PyArrayObject ** | operands, | ||
PyObject * | type_tup, | ||
PyArray_Descr ** | out_dtypes, | ||
PyUFuncGenericFunction * | out_innerloop, | ||
void ** | out_innerloopdata | ||
) |
NPY_NO_EXPORT int PyUFunc_AdditionTypeResolution | ( | PyUFuncObject * | ufunc, |
NPY_CASTING | casting, | ||
PyArrayObject ** | operands, | ||
PyObject * | type_tup, | ||
PyArray_Descr ** | out_dtypes, | ||
PyUFuncGenericFunction * | out_innerloop, | ||
void ** | out_innerloopdata | ||
) |
<blockquote> m8[<A>] + m8[<B>] => m8[gcd(<A>,<B>)] + m8[gcd(<A>,<B>)] m8[<A>] + int => m8[<A>] + m8[<A>] int + m8[<A>] => m8[<A>] + m8[<A>] M8[<A>] + int => M8[<A>] + m8[<A>] int + M8[<A>] => m8[<A>] + M8[<A>] M8[<A>] + m8[<B>] => M8[gcd(<A>,<B>)] + m8[gcd(<A>,<B>)] m8[<A>] + M8[<B>] => m8[gcd(<A>,<B>)] + M8[gcd(<A>,<B>)]</blockquote>
NPY_NO_EXPORT int PyUFunc_DefaultTypeResolution | ( | PyUFuncObject * | ufunc, |
NPY_CASTING | casting, | ||
PyArrayObject ** | operands, | ||
PyObject * | type_tup, | ||
PyArray_Descr ** | out_dtypes, | ||
PyUFuncGenericFunction * | out_innerloop, | ||
void ** | out_innerloopdata | ||
) |
for the provided ufunc, filling out_dtypes, out_innerloop, and out_innerloopdata.
Returns 0 on success, -1 on error.
References find_best_ufunc_inner_loop(), find_specified_ufunc_inner_loop(), _tagPyUFuncObject::nin, _tagPyUFuncObject::nout, NPY_SAFE_CASTING, PyArray_DESCR, and PyTypeNum_ISOBJECT.
Referenced by PyUFunc_MultiplicationTypeResolution(), PyUFunc_SimpleUnaryOperationTypeResolution(), and timedelta_dtype_with_copied_meta().
NPY_NO_EXPORT int PyUFunc_DefaultTypeResolutionMasked | ( | PyUFuncObject * | ufunc, |
NPY_CASTING | casting, | ||
PyArrayObject ** | operands, | ||
PyObject * | type_tup, | ||
PyArray_Descr ** | out_dtypes, | ||
PyUFuncGenericMaskedFunction * | out_innerloop, | ||
NpyAuxData ** | out_innerloopdata | ||
) |
ufunc, then wraps it with a function which only calls the inner loop where the mask is True.
Returns 0 on success, -1 on error.
NPY_NO_EXPORT int PyUFunc_DivisionTypeResolution | ( | PyUFuncObject * | ufunc, |
NPY_CASTING | casting, | ||
PyArrayObject ** | operands, | ||
PyObject * | type_tup, | ||
PyArray_Descr ** | out_dtypes, | ||
PyUFuncGenericFunction * | out_innerloop, | ||
void ** | out_innerloopdata | ||
) |
<blockquote> m8[<A>] / m8[<B>] to m8[gcd(<A>,<B>)] / m8[gcd(<A>,<B>)] -> float64 m8[<A>] / int## to m8[<A>] / int64 -> m8[<A>] m8[<A>] / float## to m8[<A>] / float64 -> m8[<A>]</blockquote>
NPY_NO_EXPORT int PyUFunc_MultiplicationTypeResolution | ( | PyUFuncObject * | ufunc, |
NPY_CASTING | casting, | ||
PyArrayObject ** | operands, | ||
PyObject * | type_tup, | ||
PyArray_Descr ** | out_dtypes, | ||
PyUFuncGenericFunction * | out_innerloop, | ||
void ** | out_innerloopdata | ||
) |
<blockquote> int## * m8[<A>] => int64 * m8[<A>] m8[<A>] * int## => m8[<A>] * int64 float## * m8[<A>] => float64 * m8[<A>] m8[<A>] * float## => m8[<A>] * float64</blockquote>
References _tagPyUFuncObject::data, ensure_dtype_nbo(), _tagPyUFuncObject::functions, _tagPyUFuncObject::name, NPY_DOUBLE, NPY_LONGLONG, NPY_TIMEDELTA, _tagPyUFuncObject::ntypes, PyArray_DESCR, PyArray_DescrFromType(), PyArray_DescrNewFromType(), PyArray_PromoteTypes(), PyTypeNum_ISDATETIME, PyTypeNum_ISFLOAT, PyTypeNum_ISINTEGER, PyUFunc_DefaultTypeResolution(), PyUFunc_ValidateCasting(), PyUString_ConcatAndDel, PyUString_FromFormat, PyUString_FromString, and _tagPyUFuncObject::types.
NPY_NO_EXPORT int PyUFunc_OnesLikeTypeResolution | ( | PyUFuncObject * | ufunc, |
NPY_CASTING | NPY_UNUSEDcasting, | ||
PyArrayObject ** | operands, | ||
PyObject * | type_tup, | ||
PyArray_Descr ** | out_dtypes, | ||
PyUFuncGenericFunction * | out_innerloop, | ||
void ** | out_innerloopdata | ||
) |
NPY_NO_EXPORT int PyUFunc_SimpleBinaryComparisonTypeResolution | ( | PyUFuncObject * | ufunc, |
NPY_CASTING | casting, | ||
PyArrayObject ** | operands, | ||
PyObject * | type_tup, | ||
PyArray_Descr ** | out_dtypes, | ||
PyUFuncGenericFunction * | out_innerloop, | ||
void ** | out_innerloopdata | ||
) |
NPY_NO_EXPORT int PyUFunc_SimpleBinaryOperationTypeResolution | ( | PyUFuncObject * | ufunc, |
NPY_CASTING | casting, | ||
PyArrayObject ** | operands, | ||
PyObject * | type_tup, | ||
PyArray_Descr ** | out_dtypes, | ||
PyUFuncGenericFunction * | out_innerloop, | ||
void ** | out_innerloopdata | ||
) |
NPY_NO_EXPORT int PyUFunc_SimpleUnaryOperationTypeResolution | ( | PyUFuncObject * | ufunc, |
NPY_CASTING | casting, | ||
PyArrayObject ** | operands, | ||
PyObject * | type_tup, | ||
PyArray_Descr ** | out_dtypes, | ||
PyUFuncGenericFunction * | out_innerloop, | ||
void ** | out_innerloopdata | ||
) |
References PyUFunc_DefaultTypeResolution().
NPY_NO_EXPORT int PyUFunc_SubtractionTypeResolution | ( | PyUFuncObject * | ufunc, |
NPY_CASTING | casting, | ||
PyArrayObject ** | operands, | ||
PyObject * | type_tup, | ||
PyArray_Descr ** | out_dtypes, | ||
PyUFuncGenericFunction * | out_innerloop, | ||
void ** | out_innerloopdata | ||
) |
<blockquote> m8[<A>] - m8[<B>] => m8[gcd(<A>,<B>)] - m8[gcd(<A>,<B>)] m8[<A>] - int => m8[<A>] - m8[<A>] int - m8[<A>] => m8[<A>] - m8[<A>] M8[<A>] - int => M8[<A>] - m8[<A>] M8[<A>] - m8[<B>] => M8[gcd(<A>,<B>)] - m8[gcd(<A>,<B>)]</blockquote>
NPY_NO_EXPORT int PyUFunc_ValidateCasting | ( | PyUFuncObject * | ufunc, |
NPY_CASTING | casting, | ||
PyArrayObject ** | operands, | ||
PyArray_Descr ** | dtypes | ||
) |
the input types, and the output types can be cast to the output operands where provided.
Returns 0 on success, -1 (with exception raised) on validation failure.
References _tagPyUFuncObject::name, _tagPyUFuncObject::nin, _tagPyUFuncObject::nout, npy_casting_to_string(), PyArray_CanCastArrayTo(), PyArray_CanCastTypeTo(), PyArray_DESCR, PyUString_ConcatAndDel, PyUString_FromFormat, and PyUString_FromString.
Referenced by PyUFunc_MultiplicationTypeResolution().
static int set_ufunc_loop_data_types | ( | PyUFuncObject * | self, |
PyArrayObject ** | op, | ||
PyArray_Descr ** | out_dtype, | ||
int * | types | ||
) | [static] |
References dtype_kind_to_simplified_ordering(), kind(), PyArray_DESCR, and PyArray_NDIM.
Referenced by find_ufunc_matching_userloop().
static int should_use_min_scalar | ( | PyArrayObject ** | op, |
int | nop | ||
) | [static] |
Referenced by find_ufunc_matching_userloop().
static PyArray_Descr* timedelta_dtype_with_copied_meta | ( | PyArray_Descr * | dtype | ) | [static] |
References PyUFunc_DefaultTypeResolution().
static int ufunc_loop_matches | ( | PyUFuncObject * | self, |
PyArrayObject ** | op, | ||
NPY_CASTING | input_casting, | ||
NPY_CASTING | output_casting, | ||
int | any_object, | ||
int | use_min_scalar, | ||
int * | types, | ||
int * | out_no_castable_output, | ||
char * | out_err_src_typecode, | ||
char * | out_err_dst_typecode | ||
) | [static] |
Referenced by find_ufunc_matching_userloop().
static NpyAuxData* ufunc_masker_data_clone | ( | NpyAuxData * | data | ) | [static] |
References PyArray_DESCR, and _PyArray_Descr::type.
static void unmasked_ufunc_loop_as_masked | ( | char ** | args, |
npy_intp * | dimensions, | ||
npy_intp * | steps, | ||
NpyAuxData * | innerloopdata | ||
) | [static] |