-
Notifications
You must be signed in to change notification settings - Fork 13
Table(ak.Array) doesn't preserve AOESA #208
Copy link
Copy link
Labels
typesLGDO typesLGDO types
Description
import numpy as np
from lgdo import Table, ArrayOfEqualSizedArrays
t = Table({"waveforms": ArrayOfEqualSizedArrays(nda=np.array([[1,2,3], [4,5,6]]))})
ak_arr = t.view_as("ak")
t_back = Table(ak_arr)
assert isinstance(t_back["waveforms"], VectorOfVectors) # Not ArrayOfEqualSizedArraysIt's because AOESA isn't handled in the following function.
legend-pydataobj/src/lgdo/types/table.py
Lines 631 to 643 in f6fb8ef
| def _ak_to_lgdo_or_col_dict(array: ak.Array): | |
| if isinstance(array.type.content, ak.types.RecordType): | |
| return {field: _ak_to_lgdo_or_col_dict(array[field]) for field in array.fields} | |
| # be smart and just use Array when it makes sense | |
| if ( | |
| isinstance(array.type.content, ak.types.NumpyType) | |
| or array.type.content.parameters.get("__array__") == "string" | |
| ): | |
| return Array(array) | |
| # otherwise fallback to VoV | |
| return VectorOfVectors(array) |
Will submit a PR soon
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
typesLGDO typesLGDO types