Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Behavioral issue changes within the same python version (libnetCDF/netcdf-c 4.10.0 bugs) #1475

@jeremyleung521

Description

@jeremyleung521

Hi,

Due to changes in libnetcdf (netcdf-c) 4.10.0, there appears to be behavioral changes even if staying on the same python version (1.7.4). This includes indexing and "diskless mode". The environments used for testing are all installs from conda-forge. Our CI failed miserably on the first example, so I'm assuming this is the behavior on all/most UNIX OSes. To resolve this I suppose releasing a post-version pinning libnetcdf <4.10.0 until the next python release seems apt? I'm not having trouble on the PyPI release.

  1. Previously the code ignores any indices not present in the dataset (e.g. bigger than the size of the dataset) and only retrieve the rows that are possible. Now, it throws an IndexError. While I believe what is happening now (throwing an IndexError) is the "correct" behavior, it's a little rough having behavioral changes when we're technically in the same python version.

Minimal reproducible example with libnetcdf 4.10.0. Note that frame0.nc has 501 frames in the first dimension, so the slice had indexed something out of the shape.

import netCDF4
with netCDF4.Dataset('tests/data/frame0.nc', format='netCDF3') as file:
    coord = file.variables['coordinates'][slice(500, 510,2)]

Related:
mdtraj/mdtraj#2142
mdtraj/mdtraj#2143

  1. While creating a self-contained example, I found out that diskless mode is also broken with libnetcdf 4.10.0. This is fine with libnetcdf 4.9.3.
In [4]: nc = netCDF4.Dataset('diskless_example.nc', 'w', diskless=True, persist=True)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[4], line 1
----> 1 nc = netCDF4.Dataset('diskless_example.nc', 'w', diskless=True, persist=True)

File src/netCDF4/_netCDF4.pyx:2415, in netCDF4._netCDF4.Dataset.__init__()

ValueError: diskless mode requires netcdf lib >= 4.2.1, you have 4.10.0

Thanks.

EDIT: 2 is fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions