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

Issue64 #66

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pyfive/dataobjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ def compression_opts(self):
if GZIP_DEFLATE_FILTER in self._filter_ids:
gzip_entry = [d for d in self.filter_pipeline
if d['filter_id'] == GZIP_DEFLATE_FILTER][0]
return gzip_entry['client_data'][0]
key = {0:'client_data_values',1:'client_data'}['client_data' in gzip_entry]
return gzip_entry[key][0]
return None
Comment on lines 323 to 326
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the documentation pointed to in your issue, [link], it seems there is only a single list of client data values. Instead of your suggested fix, I think we instead should search-and-replace in the code and never produce any dictionary with "client_data" as the key. (disclaimer: I haven't actually studied the source code yet)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see arguments for doing it both ways, the code I've committed is as faithful to what is in the file at point of use, to do different would require hacking the message structure before using it ... I'd defer to the package owners on what is the best option.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine, thanks for elaborating!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(At some point you'd have to do what I've got above, insofar as we see files with both compression option structures, we can't control what we will get to have to read.)


@property
Expand Down
10 changes: 10 additions & 0 deletions tests/test_filter_pipeline_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,13 @@ def test_filter_pipeline_descr_v2():
d = hfile['data']
assert d.shape == (10,10,10)
assert_almost_equal(d[0,0,0], 1.0)


def test_filter_pipeline_compression_opts_v2():

with pyfive.File(FILTER_PIPELINE_V2_FILE) as hfile:
assert 'data' in hfile
d = hfile['data']
# the point of this test is to ensure we can actually retrieve the compression opts
x = d.compression_opts
assert x == 9
Loading