summaryrefslogtreecommitdiff
path: root/doc/source
diff options
context:
space:
mode:
authorNathan Goldbaum <nathan.goldbaum@gmail.com>2023-03-10 08:21:19 -0700
committerNathan Goldbaum <nathan.goldbaum@gmail.com>2023-03-17 09:52:37 -0600
commita24e785ead6dbd80050cb157326a6a23b279d4e4 (patch)
treeb2b941a4fa915dfda6b2f8ff6def671eafd8cb4c /doc/source
parente42c9503a14d66adfd41356ef5640c6975c45218 (diff)
downloadnumpy-a24e785ead6dbd80050cb157326a6a23b279d4e4.tar.gz
ENH: allow using dtype classes in array creation functions
This enables writing np.array(some_object, dtype=type(np.dtype('i'))). This is a follow-on from https://github.com/numpy/numpy/pull/23154, see that PR for more details. I had to add a new include to `ctors.h` to bring in the definition of the `npy_dtype_info` struct. Since `ctors.h` is included in many other files inside numpy, I found that I needed to modify fewer includes across numpy if I moved the definition of `npy_dtype_info` to `common.h` from `descriptor.h`. The new includes of `common.h` are needed to support later includes of `ctors.h` in those files. If anyone has an alternate place to put `npy_dtype_info` that would cause less churn of includes I'd love to hear about it. I spent a bunch of time tweaking the reference counts. I'm reasonably confident this is correct but not 100%, an additional careful pass over the reference count logic from a reviewer would be very appreciated. I could have made `_PyArray_FromAny` and `_PyArray_CheckFromAny` take just a `npy_dtype_info` struct, but I found it made the reference count logic more complicated, since `PyArray_FromAny` and `PyArray_CheckFromAny` steal the reference to the descriptor they are passed and I needed to conserve that behavior. Also both functions support passing in a `NULL` pointer for the descriptor and I needed to maintain that behavior as well. The change to `ucsnarrow.h` fixes a preexisting conflict with the prototype in `ucsnarrow.c` that triggered a compiler error while I was working on this.
Diffstat (limited to 'doc/source')
-rw-r--r--doc/source/reference/c-api/array.rst2
1 files changed, 1 insertions, 1 deletions
diff --git a/doc/source/reference/c-api/array.rst b/doc/source/reference/c-api/array.rst
index 6651a4760..65244f69e 100644
--- a/doc/source/reference/c-api/array.rst
+++ b/doc/source/reference/c-api/array.rst
@@ -423,7 +423,7 @@ From other objects
:c:data:`NPY_ARRAY_FORCECAST` is present in ``flags``,
this call will generate an error if the data
type cannot be safely obtained from the object. If you want to use
- ``NULL`` for the *dtype* and ensure the array is notswapped then
+ ``NULL`` for the *dtype* and ensure the array is not swapped then
use :c:func:`PyArray_CheckFromAny`. A value of 0 for either of the
depth parameters causes the parameter to be ignored. Any of the
following array flags can be added (*e.g.* using \|) to get the