fix: check for non-int 0 fill values#3345
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3345 +/- ##
=======================================
Coverage 93.53% 93.53%
=======================================
Files 89 89
Lines 11901 11902 +1
=======================================
+ Hits 11132 11133 +1
Misses 769 769
🚀 New features to boost your workflow:
|
|
to test this, could we perhaps patch |
dstansby
left a comment
There was a problem hiding this comment.
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.
| @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.
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()
|
|
@ilan-gold is this still active? |
|
Looking back at the history here, the PR itself, and my last comment, I don't see why not. It's pretty marginal though. Maybe @TomAugspurger has an opinion. |

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/*.rstchanges/