dask-contrib / dask-awkward

Native Dask collection for awkward arrays, and the library to use it.
https://dask-awkward.readthedocs.io
BSD 3-Clause "New" or "Revised" License
61 stars 19 forks source link

subtraction binary operator for scalars #515

Closed AndrewLevin closed 5 months ago

AndrewLevin commented 5 months ago

The subtraction binary operator for scalars seems to reverse the order of the operands. If I run the code below using dask_awkward version 2024.6.0, the result is 1, while it should be -1.

import dask.array as da
import dask_awkward as dak
import numpy as np

x=dak.from_dask_array(da.from_array(np.array([1])))

y = x[0]

z = 0-y

print(z.compute())
martindurant commented 5 months ago

Just to note at first: this is not the case for arrays (phew!).

In [8]: (arr - 1).compute()
Out[8]: <Array [0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4] type='15 * float64'>

In [9]: (1 - arr).compute()
Out[9]: <Array [0, -1, -2, -3, -4, 0, ..., -4, 0, -1, -2, -3, -4] type='15 * float64'>

One-element arrays are OK too.