[Numpy-discussion] next NumPy triage meeting - January 10th, 2024 at 6pm UTC

2024-01-07 Thread Inessa Pawson
The next NumPy triage meeting will be held this Wednesday, January 10th at
6pm UTC. This is a meeting where we synchronously triage prioritized PRs
and issues.
Join us via Zoom:
https://numfocus-org.zoom.us/j/82096749952?pwd=MW9oUmtKQ1c3a2gydGk1RTdYUUVXZz09
.
Everyone is welcome to attend and contribute to a conversation.
Please notify us of issues or PRs that you’d like to have reviewed by
adding a GitHub link to them in the meeting agenda:
https://hackmd.io/68i_JvOYQfy9ERiHgXMPvg.

-- 
Cheers,
Inessa

Inessa Pawson
GitHub: inessapawson
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com


[Numpy-discussion] Re: Fixing definition of reduceat for Numpy 2.0?

2024-01-07 Thread Sebastian Berg
On Sat, 2023-12-23 at 09:56 -0500, Marten van Kerkwijk wrote:
> Hi Sebastian,
> 
> > That looks nice, I don't have a clear feeling on the order of
> > items, if
> > we think of it in terms of `(start, stop)` there was also the idea
> > voiced to simply add another name in which case you would allow
> > start
> > and stop to be separate arrays.
> 
> Yes, one could add another method.  Or perhaps even add a new
> argument
> to `.reduce` instead (say `slices`).  But this seemed the simplest
> route...
> 
> > Of course if go with your `slice(start, stop)` idea that also
> > works,
> > although passing as separate parameters seems nice too.
> > 
> > Adding another name (if we can think of one at least) seems pretty
> > good
> > to me, since I suspect we would add docs to suggest not using
> > `reduceat`.
> 
> If we'd want to, even with the present PR it would be possible to
> (very
> slowly) deprecate the use of a list of single integers.  But I'm
> trying
> to go with just making the existing method more useful.
> 
> > One small thing about the PR: I would like to distinct `default`
> > and
> > `initial`.  I.e. the default value is used only for empty
> > reductions,
> > while the initial value should be always used (unless you would
> > pass
> > both, which we don't for normal reductions though).
> > I suppose the machinery isn't quite set up to do both side-by-side.
> 
> I just followed what is done for reduce, where a default could also
> have
> made sense given that `where` can exclude all inputs along a given
> row.
> I'm not convinced it would be necessary to have both, though it would
> not be hard to add.


Was looking at the PR, which still seems worthwhile, although not
urgnet right now.

But, this makes me think (loudly ;)) that the `get_reduction_initial`
should maybe distinguish this more fully...

Because there are 3 cases, even if we only use the first two currently:

1. True idenity: default and initial are the same.
2. Default but no initial: Object sum has no initial, but does use `0`
   as default.
3. Initial is not valid default: This would be useful to simplify
   min/max reductions: `-inf` or `MIN_INT` are valid initial values
   but are not valid default values.

- Sebastian

> 
> All the best,
> 
> Marten
> ___
> NumPy-Discussion mailing list -- numpy-discussion@python.org
> To unsubscribe send an email to numpy-discussion-le...@python.org
> https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
> Member address: sebast...@sipsolutions.net
> 


___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com


[Numpy-discussion] NEP 56: array API standard support in the main numpy namespace

2024-01-07 Thread Ralf Gommers
Hi all,

Here is what is probably the second-to-last NEP for NumPy 2.0 (the last one
being the informational summary NEP of all major changes):
https://github.com/numpy/numpy/pull/25542. Full text below.

A lot of the work has been under discussion since the 2.0 developer meeting
in April and has been merged. A few of PRs that didn't make sense as
standalone changes without this NEP are still open (see the "NumPy 2.0 API
Changes" label), and there's a couple ones that still need to be opened.

For editorial comments on the text, please comment on GitHub. For
significant conceptual/design comments, please post them on this thread.

Cheers,
Ralf



=
NEP 56 — Array API standard support in NumPy's main namespace
=

:Author: Ralf Gommers 
:Author: Mateusz Sokół 
:Author: Nathan Goldbaum 
:Status: Draft
:Type: Standards Track
:Created: 2023-12-19
:Resolution: TODO mailing list link


Abstract


This NEP proposes adding full support for the 2022.12 version of the array
API
standard in NumPy's main namespace for the 2.0 release.

Motivation and scope


.. note::

The main changes proposed in this NEP were presented in the NumPy 2.0
Developer Meeting in April 2023 (see `here
<
https://github.com/numpy/archive/blob/main/2.0_developer_meeting/NumPy_2.0_devmeeting_array_API_adoption.pdf
>`__
for presentations from that meeting) and given a thumbs up there. The
majority of the implementation work for NumPy 2.0 has already been
merged.
For the rest, PRs are ready - those are mainly the items that are
specific
to array API support and we'd probably not consider for inclusion in
NumPy
without that context. This NEP will focus on those APIs and PRs in a bit
more detail.

:ref:`NEP47` contains the motivation for adding array API support to NumPy.
This NEP expands on and supersedes NEP 47. The main reason NEP 47 aimed for
a
separate ``numpy.array_api`` submodule rather than the main namespace is
that
casting rules differed too much. With value-based casting being removed
(:ref:`NEP50`), that will be resolved in NumPy 2.0. Having NumPy be a
superset
of the array API standard will be a significant improvement for code
portability to other libraries (CuPy, JAX, PyTorch, etc.) and thereby
address
one of the top user requests from the 2020 NumPy user survey [4]_ (GPU
support).
See `the numpy.array_api API docs (1.26.x) <
https://numpy.org/doc/1.26/reference/array_api.html#table-of-differences-between-numpy-array-api-and-numpy
>`__
for an overview of differences between it and the main namespace (note that
the
"strictness" ones are not applicable).

Experiences with ``numpy.array_api``, which is still marked as experimental,
have shown that the separate strict implementation and separate array object
are mostly good for testing purposes, but not for regular usage in
downstream
libraries. Having support in the main namespace resolves this issue. Hence
this
NEP supersedes NEP 47. The ``numpy.array_api`` module will be moved to a
standalone package, to facilitate easier updates not tied to a NumPy release
cycle.

Some of the key design rules from the array API standard (e.g., output
dtypes
predictable from input dtypes, no polymorphic APIs with varying number of
returns controlled by keywords) will also be applied to NumPy functions that
are not part of the array API standard, because those design rules are now
understood to be good practice in general. Those two design rules in
particular
make it easier for Numba and other JIT compilers to support NumPy or
NumPy-compatible APIs. We'll note that making existing arguments
positional-only and keyword-only is a good idea for functions added to
NumPy in
the future, but will not be done for existing functions since each such
change
is a backwards compatibility break and it's not necessary for writing code
that
is portable across libraries supporting the standard. An additional reason
to
apply those design rules to all functions in the main namespace now is that
it
then becomes much easier to deal with potential standardization of new
functions already present in NumPy - those could otherwise be blocked or
forced
to use alternative function names due to the need for backwards
compatibility.

It is important that new functions added to the main namespace integrate
well
with the rest of NumPy. So they should for example follow broadcasting and
other rules as expected, and work with all NumPy's dtypes rather than only
the
ones in the standard. The same goes for backwards-incompatible changes
(e.g.,
linear algebra functions need to all support batching in the same way, and
consider the last two axes as matrices). As a result, NumPy should become
more
rather than less consistent.

We'll note that one remaining incompatibility will be that NumPy is
returning
array scalars rather than 0-D arrays in most cases where

[Numpy-discussion] next NumPy Newcomers' Hour - January 11th, 2024 at 10pm UTC

2024-01-07 Thread Inessa Pawson
Our next Newcomers' Hour will be held this Thursday, January 11th at 10pm
UTC. Stop by to ask questions, share your progress, celebrate success, or
just to say hi.

To add to the meeting agenda the topics you’d like to discuss, follow the
link: https://hackmd.io/3f3otyyuTte3FU9y3QzsLg?both.

Join the meeting via Zoom:
https://us06web.zoom.us/j/82563808729?pwd=ZFU3Z2dMcXBGb05YemRsaGE1OW5nQT09.

-- 
Cheers,
Inessa

Inessa Pawson
GitHub: inessapawson
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com