Closed jkanche closed 10 months ago
_list_to_numpy_with_mask
should have sanitized x
to a properly typed Numpy array, there shouldn't be a dtype=object
anymore.
that's true, i'm more concerned about how the assignment seems to work:
>>> import numpy as np
>>> a = np.array([1,0,100], dtype=np.int32)
>>> m = np.array([0,1,0], np.int8)
>>> a
array([ 1, 0, 100], dtype=int32)
>>> m
array([0, 1, 0], dtype=int8)
>>> a[m] = 2000
>>> a
array([2000, 2000, 100], dtype=int32)
its considering the mask as indices 0 and 1 and replacing the value in those two positions.
I guess we should convert it into a boolean array
>>> a = np.array([1,0,100], dtype=np.int32)
>>> a[m.astype(np.bool_)] = 4000
>>> a
array([ 1, 4000, 100], dtype=int32)
Yes, it's a little confusing. I'll rework this entire set of utilities to make them easier to use.
Anywhere this notation is used: - https://github.com/ArtifactDB/dolomite-base/blob/master/src/dolomite_base/_utils_vector.py#L44