-
Notifications
You must be signed in to change notification settings - Fork 98
Introduce a flat option to ensure_contiguous_ndarray to switch off flatten for ZFPY codec #307
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great start @halehawk!
Instead of printing and exiting, you want to raise an error, as suggested below.
You will also need to test for this error in test_zfpy.py using with pytest.raises
.
buf = ensure_contiguous_ndarray(buf) | ||
# not flatten c-order array and raise exception for f-order array | ||
if not isinstance(buf, np.ndarray): | ||
raise TypeError("The zfp codec does not support none numpy arrays." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What other type would you expect here? I thought all Zarr array data would come into numcodecs as numpy arrays?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to repeat my answers here, I added test_err_encode_list, which caused buf.flags not raise a correct error. So I added check the instance first. Do you have any different recommendation?
There is a test_err_encode_list, I cannot pass it if I don't check the type
of the object.
…On Fri, Feb 18, 2022 at 9:25 AM Ryan Abernathey ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In numcodecs/zfpy.py
<#307 (comment)>
:
> @@ -54,8 +55,16 @@ def __init__(
def encode(self, buf):
- # normalise inputs
- buf = ensure_contiguous_ndarray(buf)
+ # not flatten c-order array and raise exception for f-order array
+ if not isinstance(buf, np.ndarray):
+ raise TypeError("The zfp codec does not support none numpy arrays."
What other type would you expect here? I thought all Zarr array data would
come into numcodecs as numpy arrays?
—
Reply to this email directly, view it on GitHub
<#307 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACAPEFCWGARTLSEC7QPPEQ3U3ZXHHANCNFSM5OFA7XAQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your work on this! LGTM!
One final question I have (which doesn't have to hold up this PR) is whether you have tested this branch on a real-world use case and verified that it leads to much better compression, as expected from the discussion in #303. |
@rabernat I checked both numcodecs 0.9.1 which has flatten array and my modified numcodecs. The non-flatten array definitely can provide us better compression ratio, for example using precison mode 16 bits, we can get from 2.28 to 4.32 on a 4D array, though the error metric might be not that good, such as: rmse from 0.003979 to 0.05241. |
Looks like Peter's group added some meta data about macos-python3.10-zfpy build, but didn't upload the package yet. So I got download problem with this zfpy package. |
Looks like zfpy-0.5.5-cp310-macos can be pip install successfully now, this time the failed OSX CI/build (3.10) should be able to pass. How can I restart all PR checks? |
Now my PR failed on macos-py310 check again, but the problem was happened during building blosc.cpython-310-darwin.so. @rabernat @jakirkham Do you have any advice on this? Can you ignore this failure and merge my PR now? Thanks! |
I do not know what is causing the OSX py 3.10 failure. In general we do not like to merge things with failing CI, but I would defer to John's judgement on this. |
Regarding CI. Fixing in PR ( #311 ) |
.github/workflows/ci-osx.yaml
Outdated
conda create -n env python==${{matrix.python-version}} wheel pip compilers | ||
conda create -n env python=${{matrix.python-version}} wheel pip compilers 'clang>=12.0.1' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave this for that PR to sort out 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You want to me revert the modification?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
LGTM, but i would appreciate another maintainer approval. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally LGTM. Had a small suggestion on parameter naming. Once done would be happy to merge 🙂
Thanks for all the work here @halehawk! 😄
Done. Thanks for the feedback.
…On Tue, Mar 1, 2022 at 12:55 PM jakirkham ***@***.***> wrote:
***@***.**** commented on this pull request.
Generally LGTM. Had a small suggestion on parameter naming. Once done
would be happy to merge 🙂
Thanks for all the work here @halehawk <https://github.com/halehawk>! 😄
------------------------------
In numcodecs/compat.py
<#307 (comment)>
:
> @@ -50,7 +50,7 @@ def ensure_ndarray(buf):
return arr
-def ensure_contiguous_ndarray(buf, max_buffer_size=None):
+def ensure_contiguous_ndarray(buf, max_buffer_size=None, flat=True):
Preference for using a verb to describe the action taken or not
⬇️ Suggested change
-def ensure_contiguous_ndarray(buf, max_buffer_size=None, flat=True):
+def ensure_contiguous_ndarray(buf, max_buffer_size=None, flatten=True):
------------------------------
In numcodecs/compat.py
<#307 (comment)>
:
> + # check if flat flag is on or not
+ if flat:
⬇️ Suggested change
- # check if flat flag is on or not
- if flat:
+ # check if flatten flag is on or not
+ if flatten:
—
Reply to this email directly, view it on GitHub
<#307 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACAPEFHSU5TNJYNYFMGAMP3U5ZYZNANCNFSM5OFA7XAQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think this should fix CI
Thanks @halehawk for the PR and everyone for the reviews! 😄 |
closes #303
TODO:
tox -e py39
passes locallytox -e docs
passes locally