Skip to content

Commit

Permalink
Merge pull request #212 from dstansby/pad-error
Browse files Browse the repository at this point in the history
Fix pad error
  • Loading branch information
dstansby committed Jun 5, 2023
2 parents 3b9f958 + 48c4d19 commit 47e2f00
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
15 changes: 9 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@
*.tmp
.pytest_cache/

*.DS_Store

*.pyc
*.egg-info/
build
/.project
/.pydevproject
*.ipynb
/*.html
/testing.py
**/.coverage
**/.hypothesis
**/coverage.xml
**/codecov.sh

doc/_build
doc/api

.eggs/*
dist/*
.hypothesis/*

/*.html
coverage.xml
.coverage
htmlcov
*asv/*

cdflib/_version.py
Expand Down
3 changes: 2 additions & 1 deletion cdflib/cdfread.py
Original file line number Diff line number Diff line change
Expand Up @@ -1305,9 +1305,10 @@ def _read_vdr2(self, byte_loc: int) -> VDR:
num_dims = len(dim_sizes)
coff = 124 + toadd + 4 * self._rvariables_num_dims
# Only set if pad value is in the flags
pad: Union[None, str, np.ndarray] = None
if pad_bool:
byte_stream = vdr[coff:]
pad: Union[str, np.ndarray]

try:
pad = self._read_data(byte_stream, data_type, 1, num_elements)
except Exception:
Expand Down
15 changes: 8 additions & 7 deletions tests/test_cdfread.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@

from cdflib import CDF

fname = pathlib.Path(__file__) / ".." / "testfiles" / "psp_fld_l2_mag_rtn_1min_20200104_v02.cdf"


def test_read():
@pytest.mark.parametrize("fname", ["psp_fld_l2_mag_rtn_1min_20200104_v02.cdf", "de2_ion2s_rpa_19830213_v01.cdf"])
def test_read(fname):
fname = (pathlib.Path(__file__) / ".." / "testfiles" / fname).resolve()
cdf = CDF(fname)

cdf.cdf_info()
varatts = cdf.varattsget("psp_fld_l2_mag_RTN_1min")
assert isinstance(varatts, dict)
info = cdf.cdf_info()

# Smoke test variable access
for var in info.zVariables:
cdf.varattsget(var)
cdf.varget(var)

def test_context():
with CDF(fname) as cdf:
cdf.cdf_info()

Expand Down
Binary file added tests/testfiles/de2_ion2s_rpa_19830213_v01.cdf
Binary file not shown.
1 change: 0 additions & 1 deletion tests/testfiles/testing_file_location.txt

This file was deleted.

0 comments on commit 47e2f00

Please sign in to comment.