numpy  2.0.0
src/multiarray/arrayobject.h File Reference

Go to the source code of this file.

Functions

NPY_NO_EXPORT PyObject * _strings_richcompare (PyArrayObject *self, PyArrayObject *other, int cmp_op, int rstrip)
NPY_NO_EXPORT PyObject * array_richcompare (PyArrayObject *self, PyObject *other, int cmp_op)
NPY_NO_EXPORT int array_might_be_written (PyArrayObject *obj)

Variables

static const int NPY_ARRAY_WARN_ON_WRITE = (1 << 31)

Function Documentation

NPY_NO_EXPORT PyObject* _strings_richcompare ( PyArrayObject self,
PyArrayObject other,
int  cmp_op,
int  rstrip 
)
Cast arrays to a common type

<

define(NPY_PY3K)
Broad-cast the arrays to a common shape

References dimensions, PyArray_Dims::len, NPY_ANYORDER, NPY_BOOL, NPY_MAXDIMS, PyArray_Dims::ptr, PyArray_DIMS, PyArray_GenericReduceFunction(), PyArray_NDIM, and PyArray_Newshape().

Call this from contexts where an array might be written to, but we have no way to tell. (E.g., when converting to a read-write buffer.)
2012-07-17, 1.7
Only warn once per array
NPY_NO_EXPORT PyObject* array_richcompare ( PyArrayObject self,
PyObject *  other,
int  cmp_op 
)
Special case for string arrays (which don't and currently can't have ufunc loops defined, so there's no point in trying).
Never mind, carry on, see what happens
Never mind, carry on, see what happens
If we reach this point, it means that we are not comparing string-to-string. It's possible that this will still work out, e.g. if the other array is an object array, then both will be cast to object or something? I don't know how that works actually, but it does, b/c this works:

System Message: ERROR/3 (<string>, line 6) Unexpected indentation.

<blockquote> l = ["a", "b"] assert np.array(l, dtype="S1") == np.array(l, dtype="O")</blockquote>

System Message: WARNING/2 (<string>, line 8) Block quote ends without a blank line; unexpected unindent.
So we fall through and see what happens.
See discussion in number.c
2013-07-25, 1.7
The ufunc does not support void/structured types, so these need to be handled specifically. Only a few cases are supported.
If not successful, indicate that the items cannot be compared this way.
2015-05-07, 1.10
2015-05-07, 1.10
If the comparison results in NULL, then the two array objects can not be compared together; indicate that
Comparisons should raise errors when element-wise comparison is not possible.
2015-05-14, 1.10
2013-07-25, 1.8
The ufunc does not support void/structured types, so these need to be handled specifically. Only a few cases are supported.
If not successful, indicate that the items cannot be compared this way.
2015-05-07, 1.10
2015-05-07, 1.10
Comparisons should raise errors when element-wise comparison is not possible.
2015-05-14, 1.10

Variable Documentation

const int NPY_ARRAY_WARN_ON_WRITE = (1 << 31) [static]
This flag is used to mark arrays which we would like to, in the future, turn into views. It causes a warning to be issued on the first attempt to write to the array (but the write is allowed to succeed).
This flag is for internal use only, and may be removed in a future release, which is why the #define is not exposed to user code. Currently it is set on arrays returned by ndarray.diagonal.

Referenced by PyArray_SetStringFunction().