Skip to content
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

Merged
merged 20 commits into from
Oct 22, 2024

Conversation

jswhit
Copy link
Collaborator

@jswhit jswhit commented Oct 20, 2024

see issue #1374

@jswhit jswhit changed the title add get_fill_value Variable method add get_fill_value Variable method and fill_value= Oct 21, 2024
@jswhit jswhit changed the title add get_fill_value Variable method and fill_value= add get_fill_value Variable method and fill_value='default' option Oct 21, 2024
Comment on lines +4656 to +4661
if no_fill == 1: # no filling for this variable
return None
else:
try:
fillval = self._FillValue
return fillval
Copy link
Contributor

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?

Copy link
Collaborator Author

@jswhit jswhit Oct 22, 2024

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.

Copy link
Contributor

@ChrisBarker-NOAA ChrisBarker-NOAA Oct 22, 2024

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.
Copy link
Contributor

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.

@jswhit jswhit merged commit d181813 into master Oct 22, 2024
36 checks passed
@jswhit jswhit deleted the issue1374 branch October 22, 2024 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants