feat: improve and fix delayed length calculations and add delayed length calculation for layouts that need it#3889
feat: improve and fix delayed length calculations and add delayed length calculation for layouts that need it#3889ikrommyd wants to merge 19 commits intoscikit-hep:mainfrom
Conversation
| and mask.length is not unknown_length | ||
| and length > content.length * 8 | ||
| and ak._util.maybe_length_of(content) is not unknown_length | ||
| and length > content.length |
There was a problem hiding this comment.
This is actually funny. It's always been testing the wrong thing given the error message it wants to raise
|
The documentation preview is ready to be viewed at http://preview.awkward-array.org.s3-website.us-east-1.amazonaws.com/PR3889 |
Codecov Report❌ Patch coverage is Additional details and impacted files
🚀 New features to boost your workflow:
|
| and mask.length is not unknown_length | ||
| and length > content.length * 8 |
There was a problem hiding this comment.
content.length usually measures bytes, while the length variable might represent the expected size in bits.
There was a problem hiding this comment.
This is the whole snippet (without my changes)
if (
content.backend.nplike.known_data
and length is not unknown_length
and mask.length is not unknown_length
and length > content.length * 8
):
raise ValueError(
f"{type(self).__name__} 'length' ({length}) must be <= len(content) ({content.length})"
)
So I think this was meant to check whether length > content.length. The length of the mask is checked right above for length > mask.length * 8. Only mask.length is in bits as far as I know/can understand. .length is always the "physical" length of the layout/array. So length and content.length are neither in bytes nor bits in general. It's the "number of elements" (which does correspond to bytes of the mask in this case).
Partial fix for #3888
Tackles Bug 1 only