Open jpivarski opened 1 month ago
The line linked above should never fail; it finds the first record array content in the broadcasted contents?
Ah, that's right! I thought that contents
was the contents
of one of the RecordArrays:
>>> no_fields_record = ak.Array([{}, {}, {}, {}, {}])
>>> no_fields_record.layout
<RecordArray is_tuple='false' len='5'>
</RecordArray>
>>> no_fields_record.layout.contents
[]
>>> next(c for c in no_fields_record.layout.contents)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
StopIteration
But this contents
is the subset of inputs
that are Content
instances (which enters this function as a closure):
Okay, this line should not fail. But in trying to make this line fail, something else went wrong in recordarray.py line 760 _mergemany
.
So you're right, it was not the error I was looking for, and through some coincidence, I found a different error.
No-field records are not sufficiently tested, perhaps.
Version of Awkward Array
HEAD
Description and code to reproduce
This line:
https://github.com/scikit-hep/awkward/blob/e946646c6315ff9bde0c8a2255ee6f7fc6a31539/src/awkward/_broadcasting.py#L471
doesn't handle the possibility that the RecordArray has no fields (
len(contents) == 0
).Very, very few functions actually broadcast through fields; the ufuncs raise an error if they haven't been overloaded (and if they have been overloaded, the use the overload instead),
ak.broadcast_arrays
stops at records by a deliberate decision:https://github.com/scikit-hep/awkward/blob/e946646c6315ff9bde0c8a2255ee6f7fc6a31539/src/awkward/operations/ak_broadcast_arrays.py#L240
In our test suite, the only examples that reach the record-broadcasting code (
broadcast_any_record
, past the part that errors-out whenoptions["allow_records"]
is false) areak.transform
andak.concatenate
.I tried to trigger this error and got a different one:
It's not a high priority because it's such a weird case, but this really should result in