-
-
Notifications
You must be signed in to change notification settings - Fork 329
Correct default fill_value for creation.create #966
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
Correct default fill_value for creation.create #966
Conversation
Hello @benjeffery! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2022-02-16 15:16:58 UTC |
2a70286
to
baf1315
Compare
@@ -16,7 +16,7 @@ | |||
|
|||
|
|||
def create(shape, chunks=True, dtype=None, compressor='default', | |||
fill_value=0, order='C', store=None, synchronizer=None, | |||
fill_value=None, order='C', store=None, synchronizer=None, |
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.
Are there any other effects from changing this from 0
to None
?
Should we be updating fill_value
s elsewhere to match?
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.
The only other use of fill_value=0
I can see is creation.open_array
. I assume this should probably be None
too, but I'm not too familiar with all the effects here.
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.
open_array
just calls init_array
if needed, which already has fill_value=None
. So making it None
in open_array
seems more consistent with the underlying function.
Thanks Ben! 😄 Had a couple questions above 🙂 |
Looks like I've broken a bunch of tests here too - I was only running a subset for speed locally. WIll fix up tomorrow. |
The tests that fail seem to expect |
Because of this check, arrays with a fill value of |
Interesting we might want to revisit that check then. Most of the code uses Typically anywhere we have a If no Generally though the Zarr v2 spec leaves this ambiguous:
|
😲 |
baf1315
to
5a265c6
Compare
I've pushed up quick fixes to the tests here. |
Still a number errors of the form:
not rolling this into 2.11.1. |
@benjeffery: let me know if help is needed here. |
Does this mean that numeric types will default to None also? I find that suboptimal, and I think 0 is a good default fill value for numeric types. So I would use However, I really don't have strong feelings about the issue here. But if numeric arrays will need to specify a fill_value, then some loud documentation needs to exist about that... Again, this is all based on my own default expectations, which were always sparse writing and 0 default, but might not match others'. |
I'm not sure my fixes here are the correct way to go about this, and that some of the ideas in #965 are the right way to do this. |
Attempting to fix #965
I have added a small test in what I think is the right place. This bug might have been caught if the tests in
test_core.py
usedcreation.create
instead ofself.create_array
. Maybe I am missing something, but I couldn't see any obvious reason why those tests have their own creation routine that usesstorage.init_array
(which hasfill_value=None
). I'm happy to make that change if it is the right thing to do, but it breaks a lot of the nbytes and hexdigest tests, so I didn't propose it in the PR.Thanks!
TODO: