[Numpy-discussion] Re: Is a Python function a gufunc if it broadcasts its arguments appropriately?

2025-01-02 Thread Jim Pivarski via NumPy-Discussion
gt; > `vectorize` can indeed mimic generalized ufuncs, but (unfortunately) > doesn't create them as such currently. > > - Sebastian > > > On Tue, 2024-12-31 at 10:20 -0600, Jim Pivarski via NumPy-Discussion > wrote: > > I think you're right: the function `stack

[Numpy-discussion] Re: Is a Python function a gufunc if it broadcasts its arguments appropriately?

2024-12-31 Thread Jim Pivarski via NumPy-Discussion
I think you're right: the function `stack`, as you've defined it, is a gufunc. Here's an implementation using np.vectorize (rather than nb.vectorize ). Since the sign

[Numpy-discussion] Re: Is a Python function a gufunc if it broadcasts its arguments appropriately?

2024-12-28 Thread Jim Pivarski via NumPy-Discussion
Yes, Numba (https://numba.pydata.org/) lets you write gufuncs without the performance penalty that would be incurred if it were written in pure Python: https://numba.pydata.org/numba-doc/dev/user/vectorize.html#the-guvectorize-decorator On Fri, Dec 27, 2024 at 2:10 AM john.a.dawson--- via NumPy

[Numpy-discussion] Re: dtype=object arrays not treated like Python list?

2024-03-29 Thread Jim Pivarski
On Fri, Mar 29, 2024 at 8:07 AM Steven G. Johnson wrote: > Should a dtype=object array be treated more like Python lists for type > detection/coercion reasons? Currently, they are treated quite differently: > >>> np.isfinite([1,2,3]) > array([ True, True, True]) > In this case, the `[1, 2, 3

[Numpy-discussion] Re: Arrays of variable itemsize

2024-03-13 Thread Jim Pivarski
So that this doesn't get lost amid the discussion: https://www.blosc.org/python-blosc2/python-blosc2.html Blosc is on-the-fly compression, which is a more extreme way of making variable-sized integers. The compression is in small chunks that fit into CPU cachelines, such that it's random access pe

[Numpy-discussion] Re: Arrays of variable itemsize

2024-03-13 Thread Jim Pivarski
seful subset. On Wed, Mar 13, 2024, 1:17 PM Dom Grigonis wrote: > Thanks for this. > > Random access is unfortunately a requirement. > > By the way, what is the difference between awkward and ragged? > > On 13 Mar 2024, at 18:59, Jim Pivarski wrote: > > After send

[Numpy-discussion] Re: Arrays of variable itemsize

2024-03-13 Thread Jim Pivarski
ld fit your use-case better... Jim On Wed, Mar 13, 2024, 12:47 PM Jim Pivarski wrote: > This might be a good application of Awkward Array ( > https://awkward-array.org), which applies a NumPy-like interface to > arbitrary tree-like data, or ragged (https://github.com/scikit-hep/ragge

[Numpy-discussion] Re: Arrays of variable itemsize

2024-03-13 Thread Jim Pivarski
This might be a good application of Awkward Array (https://awkward-array.org), which applies a NumPy-like interface to arbitrary tree-like data, or ragged (https://github.com/scikit-hep/ragged), a restriction of that to only variable-length lists, but satisfying the Array API standard. The variabl

[Numpy-discussion] Re: NEP 55 - Add a UTF-8 Variable-Width String DType to NumPy

2024-02-12 Thread Jim Pivarski
I see: thank you for the explanations! On Mon, Feb 12, 2024 at 3:04 PM Nathan wrote: > Stringdtyoe arrays don’t intern python strings directly, there’s always a > copy. > I had been thinking of accepting a memoryview without copying, but if there's always a copy in any case, that answers my que

[Numpy-discussion] Re: NEP 55 - Add a UTF-8 Variable-Width String DType to NumPy

2024-02-12 Thread Jim Pivarski
Hi, I know that I'm a little late to be asking about this, but I don't see a comment elsewhere on it (in the NEP, the implementation PR #25347, or this email thread). As I understand it, the new StringDType implementation distinguishes 3 types of individual strings, any of which can be present in

[Numpy-discussion] Re: Add a new inf whose data type is int

2022-11-22 Thread Jim Pivarski
If you need an identity for minimization and maximization, a number "I_max" for which "max(I_max, x) == x" and "I_min" for which "min(I_min, x) == x", you could use the extreme values of the given integer type. For instance, if your integer type is np.int64, use - I_max = np.iinfo(np.int64).mi

[Numpy-discussion] Integer array indexing (numpy.take) as function composition

2019-09-05 Thread Jim Pivarski
Hi, I'm a long-time user of Numpy; I had a question and I didn't know where else to ask. (It's not a bug—otherwise I would have posted it at https://github.com/numpy/numpy/issues). Has anyone noticed that indexing an array with integer arrays (i.e. numpy.take) is a function composition? For examp