[Numpy-discussion] Re: np.where and ZeroDivisionError: float division by zero

2024-04-26 Thread Lucas Colley
> What you are hoping for here is known as "short circuit" or "lazy" evaluation. In SciPy, we have the private utility function `_lazywhere`[1] for this. Cheers, Lucas [1] https://github.com/scipy/scipy/blob/f44326023dc51758495491fc9f06858fd38358a0/scipy/_lib/_util.py#L88-L156 > On 26 Apr 2024

[Numpy-discussion] Re: A better syntax for using ufunc.at?

2024-07-24 Thread Lucas Colley
While not about exactly your proposed syntax, the discussion in https://github.com/data-apis/array-api/issues/609 is relevant. Cheers, Lucas > On 24 Jul 2024, at 11:49, Oras P. wrote: > > I am aware that to do unbuffered addition operation, I can use `np.add.at` > like this: > ``` > np.add.at

[Numpy-discussion] Re: ENH: Uniform interface for accessing minimum or maximum value of a dtype

2024-08-25 Thread Lucas Colley
+1 for the general idea! It may be nice to have such a function which sits at the top level of the API, to fit into https://data-apis.org/array-api/draft/API_specification/data_type_functions.html nicely. However, ‘min_value’ or ‘min‘ won’t do then - we’d probably need to include ‘dtype’ in th

[Numpy-discussion] Re: ENH: Uniform interface for accessing minimum or maximum value of a dtype

2024-08-26 Thread Lucas Colley
Or how about `np.dtype_info(dt)`, which could return an object with attributes like `min` and `max`. Would that be possible? ___ NumPy-Discussion mailing list -- numpy-discussion@python.org To unsubscribe send an email to numpy-discussion-le...@python.or

[Numpy-discussion] Re: Add diagonal offset argument to all functions that are missing it

2025-02-11 Thread Lucas Colley via NumPy-Discussion
Ralf Gommers wrote: > This sounds quite reasonable to me. The `k=0` keyword is quite badly named, > which is my one concern. Especially when tacking it on at the end of a > signature with already 3-4 keywords, it's not a good name. How about > something like `diag_offset`? FWIW, we chose `offset`

[Numpy-discussion] Re: Making `T` property Array API compatible

2025-04-12 Thread Lucas Colley via NumPy-Discussion
> The new discrepancy between `arr.T` and `arr.transpose()` is justified, as > `T` is defined by the Array API, where `transpose` isn't and should retain > the existing behavior. The other side of the coin here is that this change would fix the discrepancy between `arr.T` and the functions `np.ma

[Numpy-discussion] Re: Making `T` property Array API compatible

2025-04-14 Thread Lucas Colley via NumPy-Discussion
If NumPy were to make a move on the deprecation, then I think it would be reasonable to change the standard from > If the array instance is not two-dimensional, an error should be raised. to “if the array instance is not two-dimensional, behaviour should match `.mT`, or an error should be raise