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 nc_del_attr to Cdunif to allow attribute removal in netCDF files #1841

Merged
merged 4 commits into from Feb 19, 2016

Conversation

Projects
None yet
3 participants
@dnadeau4
Contributor

dnadeau4 commented Feb 18, 2016

Allow to delete Global Attributes or Variable attributes when calling del(f.attribute) or delattr(f, attribute). Cdunifmodule "set_attribute" function is called with a null pointer "0x00" which is different than Py_None. Without this change deleting an attribute with a "del" or "delattr" call was crashing the program with a segmentation fault.

@dnadeau4 dnadeau4 changed the title from Add nc_del_attr to Cdunif to allow attribute remove in netCDF files to Add nc_del_attr to Cdunif to allow attribute removal in netCDF files Feb 18, 2016

@doutriaux1

This comment has been minimized.

Member

doutriaux1 commented Feb 18, 2016

@dnadeau4 can you please add a test case? Thanks!

import cdms2, MV
f = cdms2.open("test.nc","w")
s = MV2.ones((20,20))
s.id="test"
s.test_attribute = "some variable attribute"
f.test_attribute = "some file attribute"
f.write(s)
f.close()
f = cdms2.open("test.nc","r+")
del(f.some_attribute)
s=f["test"]
del(s.some_attribute)
f.close()
f = cdms2.open("test.nc")
assert(hasattr(f,"some_attribute") is False)
s=f["test"]
assert(hasattr(s,"some_attribute") is False)
@dnadeau4

This comment has been minimized.

Contributor

dnadeau4 commented Feb 19, 2016

I added the test.

@durack1

This comment has been minimized.

Member

durack1 commented Feb 19, 2016

@dnadeau4 it would be a good idea to merge these changes into the existing branch issue1579_durack1_UpdateNetcdf4.3.3.1To4.4.0 - this branch includes the new netcdf 4.4.0 final release..

@doutriaux1

This comment has been minimized.

Member

doutriaux1 commented Feb 19, 2016

@durack1 totally different issue, one issue per branch. The NetCDF4 needs testing first.

@durack1

This comment has been minimized.

Member

durack1 commented Feb 19, 2016

@doutriaux1 not sure I agree with you. In 4.4.0 Unidata/netcdf-c#128 is fixed, and these changes will likely impact the operation of Cdunif. This is documented in #1398

@dnadeau4

This comment has been minimized.

Contributor

dnadeau4 commented Feb 19, 2016

@doutriaux1 How come you did not merge it yet? I did add the test and I tried it. Thanks for providing a template.

@doutriaux1

This comment has been minimized.

Member

doutriaux1 commented Feb 19, 2016

my bad, didn't see that you had a test in!

Update CDMS_Test_del_attributes.py
gave a more unique name to test file

doutriaux1 added a commit that referenced this pull request Feb 19, 2016

Merge pull request #1841 from UV-CDAT/nc_del_attr
Add nc_del_attr to Cdunif to allow attribute removal in netCDF files

@doutriaux1 doutriaux1 merged commit 8bb4dda into master Feb 19, 2016

0 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/travis-ci/push The Travis CI build is in progress
Details

@doutriaux1 doutriaux1 deleted the nc_del_attr branch Feb 19, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment