Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit af6be5d

Browse files
authored
DOC: release notes for the latest shape-typing improvements (#31172)
1 parent f2cffb4 commit af6be5d

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Shape-typing support for many functions and methods
2+
---------------------------------------------------
3+
Many functions and methods now have shape-aware return type annotations.
4+
Type-checkers can now infer the number of dimensions of the returned array
5+
through common operations. For example, ``np.linspace(0, 1)`` is now typed
6+
as a 1-d ``float64`` array, and ``np.sum(x, keepdims=True)`` has the same
7+
number of dimensions as ``x``.
8+
9+
This covers ``numpy.linalg`` functions, array creation functions (like
10+
``asarray``, ``from{buffer,string,file,iter,regex}``), range functions (``linspace``,
11+
``logspace``, ``geomspace``), aggregation functions and methods (``sum``,
12+
``mean``, ``std``, ``var``, ``min``, ``max``, ``all``, ``any``, etc.), sorting
13+
(``sort``, ``argsort``, ``argpartition``), cumulative operations (``cumsum``,
14+
``cumprod``, etc.), set operations (``unique_values``, ``intersect1d``,
15+
``union1d``, etc.), and various other functions including ``nonzero``,
16+
``transpose``, ``diagonal``, ``atleast_{1,2,3}d``, ``clip``, ``round``,
17+
``inner``, ``bincount``, and ``fft.fftfreq``. Several of these also gained
18+
more precise return dtype annotations as part of this work.
19+
20+
Shape-typing is still a work-in-progress, so coverage is not yet complete.
21+
Because of limitations in Python's type system and current type-checkers,
22+
shape-typing is often only implemented for the most common lower-rank cases.

0 commit comments

Comments
 (0)