Closed JonasSuni closed 2 weeks ago
This snippet is repeated everywhere. I added helper function to read the vectorsize of a variable from vlsv file to reduce code duplication, but it does not work on datareducers.
MaskedConstant inherits numpy.ndarray, so it has a .size and a .shape, which is what we just went through yesterday with @kostahoraites for a similar fix (in some place, I forget which...).
This is a fix for PR #82 :
The problem is that if for any reason the
test_variable
used inread_interpolated_variable
is masked,isinstance(test_variable, Iterable)
will returnTrue
butvalue_length=len(test_variable)
will throw the errorTypeError: len() of unsized object
. This is because the masked value is of typenp.ma.core.MaskedConstant
, which inherits the property ofIterable
from somewhere, but it's actually not iterable.This PR adds an additional check for
np.ma.core.MaskedConstant
and setsvalue_length=1
if the value is masked.