What happened?
When masking a heat array with only one True entry, heat returns the entire (aka unmasked) array rather than the one entry that the mask specifies. This is, of course, unlike the behavior of numpy and pytorch. See the code snippet below for a minimal failing example and comparison with numpy and pytorch.
Code snippet triggering the error
import numpy as np
import heat as ht
a = np.arange(12).reshape((4, 3)) # some numpy data
a_heat = ht.array(a) # same data in heat
# generate a mask with two True entries and zeros else
mask = np.zeros_like(a).astype(bool)
mask[0, 1] = True
mask[2, 0] = True
mask_heat = ht.array(mask) # make a heat copy of the mask
print(mask)
"""
[[False True False]
[False False False]
[ True False False]
[False False False]]
"""
print(a[mask])
"""
[1 6]
"""
print(a_heat[mask_heat])
"""
DNDarray([1, 6], dtype=ht.int64, device=cpu:0, split=None)
"""
# so far, so good. Now on to the bug
# now generate a mask with only one True entry and zeros else
mask = np.zeros_like(a).astype(bool)
mask[0, 1] = True
mask_heat = ht.array(mask) # make a heat copy of the mask
print(mask)
"""
[[False True False]
[False False False]
[False False False]
[False False False]]
"""
print(a[mask])
"""
[1]
"""
print(a_heat[mask_heat])
"""
DNDarray([[[ 0, 1, 2],
[ 3, 4, 5],
[ 6, 7, 8],
[ 9, 10, 11]]], dtype=ht.int64, device=cpu:0, split=None)
"""
print(a_heat.larray[mask_heat.larray])
"""
tensor([1])
"""
Error message or erroneous outcome
Version
main (1.8.0-dev)
Python version
3.13.11
PyTorch version
2.10
MPI version
What happened?
When masking a heat array with only one True entry, heat returns the entire (aka unmasked) array rather than the one entry that the mask specifies. This is, of course, unlike the behavior of numpy and pytorch. See the code snippet below for a minimal failing example and comparison with numpy and pytorch.
Code snippet triggering the error
Error message or erroneous outcome
Version
main (1.8.0-dev)
Python version
3.13.11
PyTorch version
2.10
MPI version