-
-
Notifications
You must be signed in to change notification settings - Fork 356
fix: check for non-int 0 fill values #3345
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3345 +/- ##
=======================================
Coverage 94.70% 94.70%
=======================================
Files 79 79
Lines 9532 9533 +1
=======================================
+ Hits 9027 9028 +1
Misses 505 505
🚀 New features to boost your workflow:
|
to test this, could we perhaps patch |
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.
Looks good to me - needs a release note entry, and I left one suggestion to improve the test too.
|
||
|
||
@pytest.mark.parametrize("dtype", [np.int8, np.uint16, np.float32, int, float]) | ||
@pytest.mark.parametrize("fill_value", [None, 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.
@pytest.mark.parametrize("fill_value", [None, 0, 1]) | |
@pytest.mark.parametrize("fill_value", [None, 0, 0.0, 1]) |
Worth explicitly including a float 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.
I think everything is cast anyway by dtype
, so it shouldn't matter, no?
I've done some digging into this topic, I'll post in a bit but I would like to hold off on merging for a bit. |
Ok apologies, I know that Tom's PR supercedes this in many ways but for anyone curious, my worry was about how memory is allocated. I learned that import numpy as np
buf = np.arange(100_000, dtype=np.float64)
# cell 1
%%timeit full = np.full((1_000_000,), 0, dtype=np.float64)
full[900_000:] = buf
# cell 2
%%timeit zeros = np.zeros((1_000_000,), dtype=np.float64)
zeros[900_000:] = buf
# cell 3
%%timeit full = np.full((1_000_000,), 0, dtype=np.float64)
full.sum()
# cell 4
%%timeit zeros = np.zeros((1_000_000,), dtype=np.float64)
zeros.sum() ![]() |
A bit of an "oops" from me, but hopefully this is more robust (than #3082)! It worked for my one example but testing this without using a spy object seems impossible (happy to contribute that though, or some other test).
TODO:
docs/user-guide/*.rst
changes/