Open
Description
PyTensor doesn't have a type that behaves like masked arrays. It's not just a problem of wrapping a masked array.
In your example, as soon as you try to do some operation, you will get incorrect values:
import pytensor import numpy as np X = np.ma.masked_greater(np.array([1, 2, 3, 4]), 3) sh_val = pytensor.shared(X) print(sh_val.eval()) # [1,2,3,4] sh_val.set_value(X) print(sh_val.eval()) # [1,2,3,--] print((sh_val + 1).eval()) # [2 3 4 5]We can raise explicitly when a user tries to pass a masked array. To actually support numpy-like behavior, we would need to implement something like
MaskedTensorVariables
and write all the operations to support those types. Similar to how we handleSparseTensorVariables.
Originally posted by @ricardoV94 in #258 (comment)