[Numpy-discussion] Re: [EXTERNAL] Copy on __setitem__

2024-12-26 Thread Benjamin Root via NumPy-Discussion
Seems to make sense to me? Or is the following a bug? >>> import numpy as np >>> u = np.zeros(5) >>> v = np.ones(5) >>> u array([0., 0., 0., 0., 0.]) >>> u[...] = v >>> u array([1., 1., 1., 1., 1.]) >>> v[4] = 5 >>> v array([1., 1., 1., 1., 5.]) >>> u array([1., 1., 1., 1., 1.]) If you don't do a

[Numpy-discussion] Re: slice an array along specific axis

2025-02-01 Thread Benjamin Root via NumPy-Discussion
When I usually need to do something like that, I just construct a tuple of slice() objects. No need to use swapaxes(). Or am I missing something? On Sat, Feb 1, 2025 at 10:24 AM Michael Mullen wrote: > Hello, > > I am writing a class handling NumPy arrays, and basing it off some > computations I

[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-03-25 Thread Benjamin Root via NumPy-Discussion
Shasang, My main concern is that if there is a legitimate bug in someone's code that is causing mismatched array sizes, this can mask that bug in certain situations where the mismatch just so happens to produce arrays of certain shapes. I am intrigued by the idea, though. Ben Root On Tue, Mar 25

[Numpy-discussion] Tricky ufunc implementation question

2025-06-27 Thread Benjamin Root via NumPy-Discussion
I'm looking at a situation where I like to wrap a C++ function that takes two doubles as inputs, and returns an error code, a position vector, and a velocity vector so that I essentially would have a function signature of (N), (N) -> (N), (N, 3), (N, 3). When I try to use np.vectorize() or np.fromp

[Numpy-discussion] Re: Tricky ufunc implementation question

2025-06-27 Thread Benjamin Root via NumPy-Discussion
Discussion < numpy-discussion@python.org> wrote: > On Fri, Jun 27, 2025 at 5:29 PM Benjamin Root via NumPy-Discussion > wrote: > > > > I'm looking at a situation where I like to wrap a C++ function that > takes two doubles as inputs, and returns an error code, a pos