Skip to content

Multiple typetracer-backed layouts raise errors related to unknown length on ak.validity_error checks #3776

@ikrommyd

Description

@ikrommyd

Version of Awkward Array

HEAD

Description and code to reproduce

For example:

ak.validity_error(ak.Array([1,2,3]).layout.to_typetracer(True))

raises

File ~/Dropbox/work/pyhep_dev/awkward/src/awkward/contents/numpyarray.py:1173, in NumpyArray._validity_error(self, path)
   1171     return f"at {path} ({type(self)!r}): shape is zero-dimensional"
   1172 for i, dim in enumerate(self.shape):
-> 1173     if dim < 0:
   1174         return f"at {path} ({type(self)!r}): shape[{i}] < 0"
   1175 for i, stride in enumerate(self.strides):

File ~/Dropbox/work/pyhep_dev/awkward/src/awkward/_nplikes/shape.py:76, in UnknownLength.__gt__(self, other)
     75 def __gt__(self, other):
---> 76     raise TypeError("cannot order unknown lengths")

TypeError: cannot order unknown lengths

This error occurred while calling

    ak.validity_error(
        <Array-typetracer [...] type='## * int64'>
    )

and

ak.validity_error(ak.Array([[1,2],[3]]).layout.to_typetracer(True))

raises

File ~/Dropbox/work/pyhep_dev/awkward/src/awkward/contents/listoffsetarray.py:1756, in ListOffsetArray._validity_error(self, path)
   1755 def _validity_error(self, path):
-> 1756     if self.offsets.length < 1:
   1757         return f"at {path} ({type(self)!r}): len(offsets) < 1"
   1758     assert (
   1759         self.starts.nplike is self._backend.nplike
   1760         and self.stops.nplike is self._backend.nplike
   1761     )

File ~/Dropbox/work/pyhep_dev/awkward/src/awkward/_nplikes/shape.py:76, in UnknownLength.__gt__(self, other)
     75 def __gt__(self, other):
---> 76     raise TypeError("cannot order unknown lengths")

TypeError: cannot order unknown lengths

This error occurred while calling

    ak.validity_error(
        <Array-typetracer [...] type='## * var * int64'>
    )

We should ensure that unknown length is treated properly inside these layout methods.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThe problem described is something that must be fixed

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions