Here is a simple illustration:
>>> np.digitize([1.1, 2.2, 3.3] * u.g, [0, 1, 2, 3] * u.kg)
array([2, 3, 4]) # expected array([1, 1, 1])
All input values are more than 0 and less than 1 kg, so should be in bin 1 (note: digitize uses 0 for "outside the bin range below"), but the result is what is expected for input values and bins treated as bare arrays. Similarly, mismatched dimensions are ignored:
>>> np.digitize([1.1,2.2,3.3] * u.g, [0, 1, 2, 3] * u.s)
array([2, 3, 4]) # expected to raise
Here is a simple illustration:
All input values are more than 0 and less than 1 kg, so should be in bin
1(note: digitize uses0for "outside the bin range below"), but the result is what is expected for input values and bins treated as bare arrays. Similarly, mismatched dimensions are ignored: