[Numpy-discussion] Re: Proposal to Extend NumPy Broadcasting for (D₁, D₂, ..., N, M) → (D₁, D₂, ..., K, M) When K is a Multiple of N (K % N == 0)

2025-04-05 Thread Robert Kern via NumPy-Discussion
On Tue, Mar 25, 2025 at 9:34 AM Shasang Thummar via NumPy-Discussion <
numpy-discussion@python.org> wrote:

> *Why Should This Be Allowed?*
>
> If *a larger dimension is an exact multiple of a smaller one*, then
> logically, the smaller array can be *repeated* along that axis *without
> physically copying data*—just like NumPy does when broadcasting (1,M) to
> (N,M).
>
> In the above example,
>
>- A has shape (2,3), and B has shape (4,3).
>- Since 4 is *a multiple of* 2 (4 % 2 == 0), A could be *logically
>repeated 2 times* to become (4,3).
>- NumPy *already does* a similar expansion when a dimension is 1, so
>why not extend the same logic?
>
> It's not a particularly similar expansion. The reason broadcasting a
1-dimension works is that we just set the stride for the broadcasted
dimension to be 0, so the pointer never advances along that dimension and
just keeps pointing at the one value along that axis. You can't do the same
thing with tiling n>1. It would have to advance within the tile and then go
back. So, unlike current broadcasting, I don't think we can just adjust the
strides on each operand separately to match the broadcasted shape, which is
something the current machinery relies upon.

You could reshape `B` to be (2, 2, 3), broadcast as normal, operate, then
reshape the result back. I'm not sure if it's guaranteed in all cases that
the reshaping back could be done without copying, and I have no clear idea
of how this works in the ternary+ operator case. But even so, this is not a
straightforward extension of the broadcasting functionality and would not
just plug in to the rest of the broadcasting machinery.

I could be wrong; haven't put too much effort into it, but I think the
first step would be to walk through what the stride tricks actually would
be to get this operation to work. Then we can talk about whether or not
it's desirable to plug it in.

-- 
Robert Kern
___
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: array.T.max() vs array.max(axis=0) performance difference

2025-04-05 Thread Joren Hammudoglu via NumPy-Discussion
Quick little typing nitpick: 

`tuple[np.float64]` describes a tuple of length 1.
To describe a tuple of arbitrary length, you'd write `tuple[np.float64, ...]`

---

On a more related note, I'm seeing an asymptotic speedup/slowdown of 14x

Equality: True
Number of points: 10
Normal:2.99 μs ± 8.81 ns per loop (mean ± std. dev. of 7 runs, 100,000 
loops each)
Transpose: 3.66 μs ± 13.4 ns per loop (mean ± std. dev. of 7 runs, 100,000 
loops each)

Number of points: 100
Normal:5.25 μs ± 19.1 ns per loop (mean ± std. dev. of 7 runs, 100,000 
loops each)
Transpose: 3.76 μs ± 2.95 ns per loop (mean ± std. dev. of 7 runs, 100,000 
loops each)

Number of points: 1000
Normal:28.1 μs ± 23.5 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops 
each)
Transpose: 5.57 μs ± 7.43 ns per loop (mean ± std. dev. of 7 runs, 100,000 
loops each)

Number of points: 1
Normal:252 μs ± 164 ns per loop (mean ± std. dev. of 7 runs, 1,000 loops 
each)
Transpose: 21 μs ± 43 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops 
each)

Number of points: 10
Normal:2.5 ms ± 2.14 μs per loop (mean ± std. dev. of 7 runs, 100 loops 
each)
Transpose: 174 μs ± 590 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops 
each)

Number of points: 100
Normal:25 ms ± 10.5 μs per loop (mean ± std. dev. of 7 runs, 10 loops each)
Transpose: 1.77 ms ± 7.62 μs per loop (mean ± std. dev. of 7 runs, 1,000 loops 
each)
___
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] next NumPy Optimization Team meeting - Monday, March 24th, 2025 at 5 pm UTC

2025-04-05 Thread Inessa Pawson via NumPy-Discussion
Hi, all!
The next NumPy Optimization Team meeting will be held on Monday, March 24th
at 17:00 UTC.
Join us via Zoom:
https://numfocus-org.zoom.us/j/81261288210?pwd=iwV99tGSjR61RTGEERKM4QKxe46g1n.1
Everyone is welcome and encouraged to attend.
To add to the meeting agenda the topics you’d like to discuss, follow the
link: https://hackmd.io/dVdSlQ0TThWkOk0OkmGsmw?both
For the notes from the previous meetings, visit:
https://github.com/numpy/archive/tree/main/optim_team_meetings

-- 
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] Add noncentral student's t-distribution

2025-04-05 Thread Seungwoo (Simon) Kim via NumPy-Discussion
Hi, 

It would be useful to have numpy support for noncentral student's 
t-distribution. Numpy already supports standard t, and it should be a 
straightforward transformation: 
- (scipy noncentral t) 
https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.nct.html
- (numpy standard t) 
https://numpy.org/doc/2.2/reference/random/generated/numpy.random.standard_t.html

Happy to contribute a PR if others find it useful. Thanks!
___
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] next NumPy triage meeting - Wednesday, April 2nd, 2025 at 5 pm UTC - now meeting ONE HOUR EARLIER

2025-04-05 Thread Inessa Pawson via NumPy-Discussion
Hi, everyone!
The next NumPy triage meeting will be held this Wednesday, April 2nd at
17:00 (5 pm) UTC. Please note the TIME CHANGE!
This is a meeting where we synchronously triage prioritized PRs and issues.
Everyone is welcome to attend and contribute to a conversation.
Join us via Zoom:
https://numfocus-org.zoom.us/j/82096749952?pwd=MW9oUmtKQ1c3a2gydGk1RTdYUUVXZz09
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] next NumPy community meeting - Wednesday, April 9th, 2025 at 5 pm UTC - now meeting ONE HOUR EARLIER

2025-04-05 Thread Inessa Pawson via NumPy-Discussion
The next NumPy community meeting will be held this Wednesday, April 9th at
17:00 (5 pm) UTC. Please note the TIME CHANGE!
Join us via Zoom:
https://numfocus-org.zoom.us/j/83278611437?pwd=ekhoLzlHRjdWc0NOY2FQM0NPemdkZz09
Everyone is welcome and encouraged to attend.
To add to the meeting agenda the topics you’d like to discuss, follow the
link: https://hackmd.io/76o-IxCjQX2mOXO_wwkcpg?both
For the notes from the previous meetings, visit:
https://github.com/numpy/archive/tree/main/community_meetings

-- 
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