-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add get_fill_value Variable method and fill_value='default' option #1375
Conversation
if no_fill == 1: # no filling for this variable | ||
return None | ||
else: | ||
try: | ||
fillval = self._FillValue | ||
return fillval |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure when no_fill would be one -- but if there is a _FillValue
attribute, maybe it should be returned anyway? e.g. look for that first?
The other question is what to do if the _FillValue
attribute doesn't match what nc_inq_var_fill returns?
That would be a malformed file, but maybe helpful to warn the user somehow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if no_fill=1, there is no pre-filling of data in the variable (so _FillValue
is not used). Not sure what happens if pre-filling is turned off and _FillValue
is set - but in this case, I think the user would expect to get information on what is actually happening when you create a variable and don't write data to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah -- that's the challenge -- the fill value has a well defined meaning and purpose, but it's commonly used (abused?) to means missing value, or invalid value. So someone could, in theory, write a file without the fill value set, and then use the attribute to mean missing data. so ????
But I suppose the pathological cases are not our problem :-) -- the point of this new method to get the actual, under the hood, fill_value.
in which case, looking for the FillValue attribute is unnecessary -- unless we want to check that it matches, which might be a good idea!
_ensure_nc_success(ierr) | ||
return fillval | ||
else: | ||
# no default filling for non-primitive data types. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this is where no_fill would be 1 -- so I'd think we would want to return the _FillValue attribute if it exists.
see issue #1374