1647 Commits
Author SHA1 Message Date
Iason Krommydas a74be27658 ENH: support reduction loops in ufunc.reduceat (#32212)
Signed-off-by: Iason Krommydas <iason.krom@gmail.com>
2026-10-28 11:56:29 -06:00
Pratham Hole fd16286d38 ENH: Add np.ma.assert_array_equal (#30617) 2026-10-28 17:26:02 +02:00
Abhinay Reddy Keesara c5cf6f3f95 DEP: Deprecate np.dot when a.ndim >= 2 and b.ndim > 2 (#32759)
When a.ndim >= 2 and b.ndim > 2, np.dot() and ndarray.dot() place b's leading dimensions in the middle of the result:

a = np.ones((2, 3))
b = np.ones((4, 3, 5))
np.dot(a, b).shape  # (2, 4, 5) - the 4 ends up in the middle

@/matmul gives (4, 2, 5). This PR deprecates the dot behavior for these inputs and suggests numpy.tensordot(a, b, axes=[-1, -2]) for the same result, or @/matmul for batched matrix multiplication.
2026-10-20 21:03:14 +02:00
pereradrianandAdrián Muñoz Perera 8ba30a04ad DOC: point to C-API include instructions at top of Array API page [sk… (#33094)
Co-authored-by: Adrián Muñoz Perera <10870103+pereradrian@users.noreply.github.com>
2026-10-19 21:23:12 +03:00
Inessa Pawson 3adadd9100 DOC: point non-security crash reports to the issue tracker in security.rst (#33077) 2026-10-18 15:15:55 -06:00
Inessa Pawson d65183b0f2 DOC: Unify and cross-link array subclassing documentation (#33067) 2026-10-17 21:41:53 +03:00
Sebastian Berg d96ccfed87 ENH: Expand abstract DType hierarchy (#31755) 2026-10-16 13:24:13 +03:00
Raghuveer Devulapalli 9c7415aff5 Merge pull request #32826 from berezucc/doc-cpu-baseline-none-dispatch
DOC: note that cpu-baseline=none does not disable CPU dispatch
2026-10-13 03:49:03 +00:00
Dragos-Georgian IonandInessa Pawson 82b2cf5518 DOC: fixing `ndarray` declaration documentation (#32933)
Co-authored-by: Inessa Pawson <inessapawson@gmail.com>
2026-10-08 09:43:37 +02:00
Nikita Berezyuk 9a51153879 DOC: note that cpu-baseline=none does not disable CPU dispatch 2026-09-29 15:40:14 -04:00
Nathan Goldbaum e0e69cd79a DOC: tweaks and fixes for string functionality docs (#32755) 2026-09-24 11:27:18 -06:00
Nathan Goldbaum b245332d3b BUG: apply the NEP 50 scalar rules in concatenate and choose, and make casting="no" match "equiv" (#32497) 2026-09-15 12:40:49 -06:00
Matti Picus 15a1636a6d Merge pull request #32596 from shbhmbnsl1/doc/cython-c-api
DOC: add details about Cython in NumPy C-API reference
2026-09-15 09:16:17 +03:00
Shubham Bansal 69ee088f80 DOC: update typed memoryview note 2026-09-14 14:55:08 -04:00
Shubham Bansal af30a26ca7 DOC: update with more realistic example 2026-09-14 14:14:02 -04:00
Shubham Bansal 8546890969 DOC: add hyperlinks to cython documentation and pxd file 2026-09-14 12:59:15 -04:00
Shubham Bansal 63d607c043 DOC: Update example based on the review comments 2026-09-14 11:01:15 -04:00
Matti Picus a24a715500 Merge pull request #31002 from vishal-rk/issue-22635-remove-python2-docs
DOC: removed python2-specific include path from nditer cython example …
2026-09-14 07:26:50 +03:00
Shubham Bansal c4a22e4f10 DOC: add details about Cython in NumPy C-API reference 2026-09-11 13:32:23 -04:00
Iason Krommydas 7f16df0fa2 ENH: implement np.minmax (#32231)
Implements np.minmax using the new ability to register reduction loops to ufuncs implemented in #31816

The loops are implemented in the existing .c.src files with the np.minimun/maximum loops and using exactly the same optimizations and SIMD as them. Two new files minmax.cpp and minmax.h are created just to create the ufunc and initialize the array methods.
I found this to be by far the easiest setup to do now. The other option would be porting the whole loops_minmax.dispatch.c.src to highway and using only c++ but that is a more complicated change with a way more difficult review so I did not do that.

minmax is not a method on the ndarray like min and max are. The only thing exposed in the top-level API is the new np.minmax function. The minimummaximum ufunc is not exposed as np.minimummaximum like np.minimum and np.maximum are as I do not believe there's much use in that. If we ever need it, it's a very simple change.

We should also consider adding a nanminmax in a follow-up PR for completeness and also adding a masked array aware implementation (either by making minmax a method on the ndarray or only by a np.ma.minmax).

Signed-off-by: Iason Krommydas <iason.krom@gmail.com>
2026-09-10 12:33:39 +02:00
Matti Picus d7a680a0a4 DOC: break long lines 2026-09-07 10:05:54 +03:00
Nathan Goldbaum 6068016edd ENH: infer sizes when casting or creating arrays from StringDType arrays (#32097)
Adds a new helper stringdtype_find_fixed_width_descr and uses 
it in a new code path in find_descriptor_from_array that works
like the existing object string and datetime code paths in that
function that scan array values to infer the destination dtype.

Also adds tests for this new behavior.
2026-08-28 19:23:43 -04:00
Nathan Goldbaum 923f0dc672 BUG: validate UTF-8 and harden StringDType bounds handling (#32296) 2026-08-21 08:44:04 -06:00
Nathan Goldbaum 1785d72cac MAINT: soft-deprecate PyArray_malloc/realloc/free in favor of PyMem_Raw APIs 2026-08-18 10:38:51 -06:00
Iason Krommydas 83a7e03f8a ENH: implement unwrap for masked arrays under np.ma (#32091) 2026-08-01 06:57:38 -06:00
Iason Krommydas 10613a8579 ENH: add mechanism to register reduction loops to ufuncs for multi-output reductions (#31816)
Signed-off-by: Iason Krommydas <iason.krom@gmail.com>
2026-07-30 12:53:37 -06:00
14caf739d4 ENH: Add top_k based on partitioning (#31659)
Co-authored-by: Jules <julia.poo.poo.poo@gmail.com>
Co-authored-by: Joren Hammudoglu <jhammudoglu@gmail.com>
Co-authored-by: Iason Krommydas <iason.krom@gmail.com>
2026-07-29 09:16:23 -06:00
Nathan Goldbaum 6ed4340ebe DOC: improve documentation for state stored in context variables (#32037) 2026-07-18 15:20:03 +02:00
e87191ec1f ENH: New-style ArrayMethods for partitioning (#31614)
Co-authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com>
Co-authored-by: Sebastian Berg <sebastianb@nvidia.com>
2026-07-16 14:19:09 +02:00
Pieter Eendebak 279da819df ENH: Improve ufunc performance by caching the loop function (#31068)
Rather than looking up loops with the `PyUFunc_DefaultLegacyInnerLoopSelector` every time, this caches
the actual loop on the ArrayMethod.

Conceptually, this is the right thing, but there are two annoyances unfortunately:
1. We have a `ReplaceLoopByDescr` whether it is used by anyone (except pnumpy which is unmaintained) is another question.
2. We allow dict registration of dtypes which is contrary to how ufunc dispatching works and means that we can't use the path quite always (until that get's deprecated at least)...
2026-07-15 10:55:55 +02:00
Sebastian Berg 80a35f1b07 DOC: Correct backcompat sentence and reduce NumPy 2 docs (#31869) 2026-07-09 10:24:00 -06:00
Matti Picus 1832390615 Merge pull request #31003 from vishal-rk/issue-15859-missing-type-codes-docs
DOC: add missing one-character dtype codes to arrays.dtypes table (gh…
2026-07-06 09:32:45 +03:00
Nathan Goldbaum 4380db760a BUG: avoid deadlocks using NpyString API (#31682)
For NpyString_acquire_allocators and NpyString_release_allocators, the fix is to sort the mutexes by address before locking. I added tests for ufuncs that need 2, 3, and 4 allocators as well as one that uses a duplicate allocator that all deadlock on main and don't with the fixes here.

Also releases the string allocator mutex before grabbing the GIL, as this in theory not necessary safe if arbitrary Python could be running (there are more paths that would need this fix, though).
2026-07-01 12:57:01 +02:00
Shoumik Chakravarty 8811d183a4 DOC: fix duplicated-word and grammar typos in C-API reference (#31802) 2026-06-30 08:57:54 -06:00
Charles Harris 27ac384a42 MAINT, DOC: Update sphinx to 8.2.3. (#31748) 2026-06-29 12:07:07 -06:00
Sebastian Berg 5e403264ee BUG: Relax finfo to be easier accessible for all user dtypes (#31563)
This allows `finfo` to be used for downstream user dtypes that do not subclass `inexact` or are "complex".  Where complex is defined by whether `arr.imag/arr.real` return the same "real" dtype correspondance.
2026-06-22 08:58:11 +02:00
Codex beb055de72 Fix typo in array.rst: 'of of' → 'of' 2026-06-14 10:07:24 +05:30
Maanas AroraandSebastian Berg f898c60088 ENH: Descending partitioning (#31511)
This PR adds `descending` as an option to partitioning and expands the internal implementations
to support it.

User DTypes are not yet supported as they currently always use the sort fallback. Additional changes
should allow to (a) use the sort as a fallback in a more reliable way and (b) change partitioning to support
a similar new-style API with registration for user DTypes.

Co-authored-by: Sebastian Berg <sebastianb@nvidia.com>
2026-06-10 14:17:17 +02:00
Sebastian Berg eb4d200f9d ENH: Create a path for legacy dtypes to transition to new DType API (#31302)
This adds and importantly backports a way for legacy dtypes to transition to the new API.
I.e. with one caveat I found for now (array dtype printing prints as np.array([1.0], dtype=repr(dtype)) and the repr now shouldn't be bfloat16 for an ml_dtype bfloat16), this allows transitioning a package like ml_dtypes over.

The advantage of this is that it allows using the new API even back to NumPy 2 without any real serious downsides (for dtypes that are currently on the legacy API).
This is a pretty big deal, I think.  Because the new API does offer a few improvements that can be reliably overridden also for NumPy 2.0 and it makes it a lot simpler to opt-in to new API e.g. for NumPy 2.4+ (with a runtime check).
2026-05-14 14:39:13 +02:00
Sebastian Berg aa48f6090c DOC: Add forgotten `register_dlpack_dtype` to docs
[skip azp] [skip cirrus] [skip actions]
2026-05-12 12:26:16 +02:00
riku-sakamoto b7282420a6 DOC: update datetime documentation to explain that "NaT" also requires specific unit (#31282) 2026-04-22 18:38:32 -06:00
riku-sakamotoandDavis Bennett 6a85991032 ENH: tweak timedelta deprecation message (#31107)
Co-authored-by: Davis Bennett <davis.v.bennett@gmail.com>
2026-04-09 11:00:34 -06:00
Charles Harris f91c8a83d8 Merge pull request #31076 from DimitriPapadopoulos/typos
MAINT: Fix typos
2026-03-30 18:13:01 -06:00
Pieter Eendebak 5de81a539d ENH: Improve performance of ufuncs using NPY_METH_NO_FLOATINGPOINT_ERRORS (#30987) 2026-03-29 11:49:18 +02:00
Sebastian Berg 30dcf3cf9e ENH: Add internal real/imag ufuncs, use for attributes and refine object dtype (#30984)
Restructure real/imag attributes to use an `ArrayMethod` that can be registered similar to other ufuncs and sorting functions.

Object dtype is changed here to use `getattr(element, "real", element)` and `getattr(element, "imag", 0)` as a step in a more reliable direction. The returned array is marked as read-only to prevent trying to modify `.real/.imag` results directly.

(If the object changes are problematic, they can be modified again. The main reason for this is also to allow user DTypes to define this correctly.)
2026-03-29 11:48:00 +02:00
Dimitri Papadopoulos d69bddc2c4 MAINT: Fix typos 2026-03-26 18:31:18 +02:00
Kumar AdityaandNathan Goldbaum b996b34012 ENH: add getters for accessing struct fields in cython (#30994)
This PR adds getters for accessing struct fields in cython. In future these would call an ABI function to get the actual fields struct on opaque PyObject builds.

Co-authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com>
2026-03-24 14:41:06 +01:00
Nathan Goldbaum 54d9fd17ae DOC: Apply Marten's comments and rephrase slightly 2026-03-21 09:19:43 -06:00
Nathan Goldbaum 185b41aee4 Respond to Matti's comments 2026-03-20 13:55:45 -06:00
Nathan GoldbaumandMatti Picus 939c604437 Update doc/source/reference/c-api/array.rst
Co-authored-by: Matti Picus <matti.picus@gmail.com>
2026-03-20 13:23:46 -06:00