summaryrefslogtreecommitdiff
path: root/numpy/core/include
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2020-12-09 13:15:22 -0600
committerSebastian Berg <sebastian@sipsolutions.net>2021-05-12 15:33:34 -0700
commit97031c1b82c6d86cfad9c3ecded3971402e6e8c9 (patch)
tree6f8ee1c08065678df87fa79ec2593ce5189c6657 /numpy/core/include
parent6f5ad737691433b39953663c904e9d330fa38332 (diff)
downloadnumpy-97031c1b82c6d86cfad9c3ecded3971402e6e8c9.tar.gz
MAINT: Implement new style promotion for `np.result_type`, etc.
This implements a new style promotion scheme for mutiple inputs as are passed to `np.result_type`. It should be noted that result-type heavily relies on "value-based casting" logic/promotion logic. This fact is inherited to many places. When user DTypes are introduced some of these places should potentially use "weak DType" logic instead if the input is a Python scalar. This is *not* yet implemented. It would be necessary to mark these the same way as is currently done for `np.result_type`. This type of "marking" will generally be necessary in a few places, even if may get away with just switching the logic everywhere.
Diffstat (limited to 'numpy/core/include')
-rw-r--r--numpy/core/include/numpy/ndarraytypes.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/numpy/core/include/numpy/ndarraytypes.h b/numpy/core/include/numpy/ndarraytypes.h
index dacb72022..9ff8c9831 100644
--- a/numpy/core/include/numpy/ndarraytypes.h
+++ b/numpy/core/include/numpy/ndarraytypes.h
@@ -856,6 +856,17 @@ typedef int (PyArray_FinalizeFunc)(PyArrayObject *, PyObject *);
*/
#define NPY_ARRAY_ENSUREARRAY 0x0040
+#if defined(NPY_INTERNAL_BUILD) && NPY_INTERNAL_BUILD
+ /*
+ * Dual use the ENSUREARRAY flag, to indicate that this was a converted
+ * python float, int, or complex.
+ * An array using this flag must be a temporary array that can never
+ * leave the C internals of NumPy. Even if it does, ENSUREARRAY is
+ * absolutely safe to abuse, since it alraedy is be a base class array :).
+ */
+ #define _NPY_ARRAY_WAS_PYSCALAR 0x0040
+#endif /* NPY_INTERNAL_BUILD */
+
/*
* Make sure that the strides are in units of the element size Needed
* for some operations with record-arrays.
@@ -1867,6 +1878,8 @@ typedef void (PyDataMem_EventHookFunc)(void *inp, void *outp, size_t size,
typedef PyArray_Descr *(default_descr_function)(PyArray_DTypeMeta *cls);
typedef PyArray_DTypeMeta *(common_dtype_function)(
PyArray_DTypeMeta *dtype1, PyArray_DTypeMeta *dtyep2);
+ typedef PyArray_DTypeMeta *(common_dtype_with_value_function)(
+ PyArray_DTypeMeta *dtype1, PyArray_DTypeMeta *dtyep2, PyObject *value);
typedef PyArray_Descr *(common_instance_function)(
PyArray_Descr *dtype1, PyArray_Descr *dtyep2);
@@ -1925,6 +1938,7 @@ typedef void (PyDataMem_EventHookFunc)(void *inp, void *outp, size_t size,
is_known_scalar_type_function *is_known_scalar_type;
default_descr_function *default_descr;
common_dtype_function *common_dtype;
+ common_dtype_with_value_function *common_dtype_with_value;
common_instance_function *common_instance;
/*
* The casting implementation (ArrayMethod) to convert between two