Open h3ndrk opened 1 year ago
This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale
, or this will be closed in 14 days.
Probably still broken...
This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale
, or this will be closed in 14 days.
Probably still broken...
I'm generating a Python API from the following schema:
This generates a Python object that contains a
_UnPack()
method which generates a Pythonlist
or a NumPyndarray
depending on whether NumPy can be imported or not (see https://github.com/google/flatbuffers/blob/master/python/flatbuffers/compat.py):In my project, I'm also using
--gen-compare
which generates the following equality operator:This
__eq__()
operator works forlist
but not forndarray
. Forlist
this yields whether the list items are the same (what we want). Forndarray
this will do a component-wise comparison and yields a newndarray
containing boolean values but not a single boolean value that would be required for the__eq__()
's return value. In the generated operator, the booleanndarray
gets converted to a single boolean value resulting in the exceptionValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
.A possible fix would be to add
.any()
or similar if NumPy is detected.As a quickfix, I patched the Python library for my project to always return
None
fromimport_numpy()
. But that is not what we want upstream probably.