array_like
Mojo module 🡭
array_like
Adapters for data not stored as List[Float64] or List[String].
Two independent axes, each with its own mechanism:
- A different container type (a custom buffer wrapper, a future
dataframe column type) via
Float64Sequence/StringSequence(__len__+Int-indexed element access), which that type’s author declares conformance to. - A different numeric element type through an ordinary
List(List[Int],List[Float32], anyList[Scalar[dtype]]) via_materialize_scalar_list’sDTypegenericity, with no trait involved.
Trait adapters require declared conformance; third-party types such as numpy
arrays need dedicated overloads. The traits extend Sized so len() works
on conforming values.
Traits
Float64Sequence: Anything with a length andInt-indexedFloat64access. Conform a data-holding struct to this to pass it directly asPlot.encode()’sx/ywithout first copying it into aList[Float64].StringSequence:Float64Sequence’s counterpart for categorical data (Plot.encode_categorical()’sx), withStringelements.