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

Regression in createVariable between 1.5.8 and 1.6.0 #1175

Closed
mrsalo opened this issue Jul 1, 2022 · 2 comments
Closed

Regression in createVariable between 1.5.8 and 1.6.0 #1175

mrsalo opened this issue Jul 1, 2022 · 2 comments

Comments

@mrsalo
Copy link

mrsalo commented Jul 1, 2022

  • netcdf4 version 1.6.0
  • Arch Linux and Rocky Linux 8

See the attached file to reproduce the behaviour, it works with 1.5.8, but does not with 1.6.0, but instead prints the following error message:

# v1.5.8
$ pip install --upgrade netcdf4==1.5.8 2&>1 > /dev/null; python regression.py
$
# v1.6.0
$ pip install --upgrade netcdf4==1.6.0 2&>1 > /dev/null; python regression.py
Traceback (most recent call last):
  File "/.../regression.py", line 21, in <module>
    main()
  File "/.../regression.py", line 10, in main
    cdf["data"].createVariable(
  File "src/netCDF4/_netCDF4.pyx", line 2838, in netCDF4._netCDF4.Dataset.createVariable
  File "src/netCDF4/_netCDF4.pyx", line 4003, in netCDF4._netCDF4.Variable.__init__
  File "src/netCDF4/_netCDF4.pyx", line 1965, in netCDF4._netCDF4._ensure_nc_success
RuntimeError: NetCDF: Filter error: bad id or parameters or duplicate filter
$
# content of regression.py
import netCDF4


def main():
    cdf = netCDF4.Dataset("bug.nc", "w", format="NETCDF4", memory=None)
    cdf.createGroup("data")
    dim_size = 100
    cdf["data"].createDimension("number_tm_packets", dim_size)
    row_of_bytes = cdf["data"].createVLType("uint8", "row_of_bytes")
    cdf["data"].createVariable(
        varname="tm_packets",
        datatype=row_of_bytes,
        dimensions=("number_tm_packets",),
        zlib=True,
        shuffle=True,
        endian="native",
    )


if __name__ == '__main__':
    main()
@jswhit
Copy link
Collaborator

jswhit commented Jul 3, 2022

Compression does not work with variable-length types. Maybe this did not cause an error with netcdf-c 4.8.1 (which was used for the netcdf4-python 1.5.8 wheel), but it looks like it does for netcdf-c 4.9.0 (which is used by the netcdf4-python 1.6.0 wheel). The error message (which comes from the C lib) is somewhat confusing though.

See https://forum.hdfgroup.org/t/compression-of-variable-lenght-datatypes/1384

@mrsalo
Copy link
Author

mrsalo commented Jul 4, 2022

Thank you very much for the clarification, I was not aware of that.
Removing the zlib=True fixes the issue.
I opened an issue in netcdf-c to improve the error message: Unidata/netcdf-c#2447

@mrsalo mrsalo closed this as completed Jul 4, 2022
@rstoneback rstoneback mentioned this issue Jul 13, 2022
18 tasks
jjpr-mit added a commit to brain-score/brainio that referenced this issue Sep 7, 2022
mschrimpf added a commit to brain-score/brainio that referenced this issue Sep 27, 2022
* unpin xarray, numpy, pandas, netcdf4

* Fix deprecation "TypeError: Using a DataArray object to construct a variable is ambiguous, please extract the data using the .data property."  See pydata/xarray#6508.  There are other errors, however.

* See Unidata/netcdf4-python#1175 "Regression in createVariable between 1.5.8 and 1.6.0".

* Testing on Python 3.7 only covers through xarray 0.20.2.  This is an experiment.

* Fix get_metadata to account for the internal restructuring of indexes in xarray 2022.06.  Update tests for same.

* Fixed bug where we were stripping off attrs inadvertently when writing netCDF.

* TestPlainGroupby.test_on_data_array fails with Python = 3.8.13, numpy = 1.23.2, xarray = 2022.06.0.  That means it has nothing to do with BrainIO.

* test_on_data_array should not involve any BrainIO classes.  This is to test for bugs in xarray.  With xarray==2022.06.0, this test fails.

* xarray 2022.06.0 has a bug which breaks BrainIO:  pydata/xarray#6836.

* Adapt get_metadata to the change in the index API between 2022.03.0 and 2022.06.0.  Now test_get_metadata passes under 2022.03.0 and 2022.06.0.

* Getting an error from tests on Travis (but not locally):  RuntimeError: NetCDF: Filter error: bad id or parameters or duplicate filter.  This might fix it?

* Compression test failed:  assert 614732 > 615186.  This might fix it.

* Travis doesn't offer python 3.10 yet.  Make sample assembly bigger so compression has an effect.

* Bump minor version.

Authored-by: Jonathan Prescott-Roy <jjpr@mit.edu> and Martin Schrimpf <msch@mit.edu>
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

No branches or pull requests

2 participants