8000 ENH: Expose abstract DType classes in the experimental DType API by ngoldbaum · Pull Request #25209 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: Expose abstract DType classes in the experimental DType API #25209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
ENH: Expose abstract DType classes in the experimental DType API
  • Loading branch information
ngoldbaum committed Nov 20, 2023
commit 128d9b444137a2aa145c1abf26816b8808e3c5e8
4 changes: 4 additions & 0 deletions numpy/_core/include/numpy/experimental_dtype_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@ PyArray_GetDefaultDescr(PyArray_DTypeMeta *DType)
/* Object/Void */
#define PyArray_ObjectDType (*(PyArray_DTypeMeta *)__experimental_dtype_api_table[42])
#define PyArray_VoidDType (*(PyArray_DTypeMeta *)__experimental_dtype_api_table[43])
/* Abstract */
#define PyArray_PyIntAbstractDType (*(PyArray_DTypeMeta *)__experimental_dtype_api_table[44])
#define PyArray_PyFloatAbstractDType (*(PyArray_DTypeMeta *)__experimental_dtype_api_table[45])
#define PyArray_PyComplexAbstractDType (*(PyArray_DTypeMeta *)__experimental_dtype_api_table[46])

/*
* ********************************
Expand Down
8 changes: 7 additions & 1 deletion numpy/_core/src/multiarray/experimental_public_dtype_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "convert_datatype.h"
#include "common_dtype.h"
#include "umathmodule.h"
#include "abstractdtypes.h"


static PyArray_DTypeMeta *
dtype_does_not_promote(
Expand Down Expand Up @@ -443,7 +445,7 @@ _PyArray_GetDefaultDescr(PyArray_DTypeMeta *DType)
NPY_NO_EXPORT PyObject *
_get_experimental_dtype_api(PyObject *NPY_UNUSED(mod), PyObject *arg)
{
static void *experimental_api_table[44] = {
static void *experimental_api_table[47] = {
&PyUFunc_AddLoopFromSpec,
&PyUFunc_AddPromoter,
&PyArrayDTypeMeta_Type,
Expand Down Expand Up @@ -498,6 +500,10 @@ _get_experimental_dtype_api(PyObject *NPY_UNUSED(mod), PyObject *arg)
/* Object and Structured */
experimental_api_table[42] = PyArray_DTypeFromTypeNum(NPY_OBJECT);
experimental_api_table[43] = PyArray_DTypeFromTypeNum(NPY_VOID);
/* Ab 4F1D stract */
experimental_api_table[44] = &PyArray_PyIntAbstractDType;
experimental_api_table[45] = &PyArray_PyFloatAbstractDType;
experimental_api_table[46] = &PyArray_PyComplexAbstractDType;
}

char *env = getenv("NUMPY_EXPERIMENTAL_DTYPE_API");
Expand Down
0