FIX: Make array_view.size return 0 for empty arrays#5264
FIX: Make array_view.size return 0 for empty arrays#5264jkseppan wants to merge 1 commit intomatplotlib:masterfrom
Conversation
|
I had proposed doing something like this in #5185 (comment), but @tacaswell thought that didn't seem quite right. I guess I understand the objection from a purity point of view, but on the other hand most of the C++ code assumes a fix size for all the dimensions past the first one (i.e. an array of bounding boxes is always Nx2x2, so if it's passed an array of 1x0x1, I'm fine with it behaving as if it's 0x2x2). And handling the special case of "a zero in any dimension" in one place (the For completeness, we should still do something like half of #5246, which also fixes this bug but checks the expected lower dimensions. But with this, we wouldn't need to revert the |
|
Closing in favor of #5274. |
This is an API change that seems somewhat illogical to me, but it probably avoids errors like #5185 without fixes like #5241, which seems more puzzling to me. What I mean by illogical is that a sequence with a nonzero number of zero-sized elements is presented as having length 0. But making it consistent in that corner case is probably more puzzling to code using
array_viewthan returning the actual number of empty elements.