Skip to content
array_like

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], any List[Scalar[dtype]]) via _materialize_scalar_list’s DType genericity, 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 and Int-indexed Float64 access. Conform a data-holding struct to this to pass it directly as Plot.encode()’s x/y without first copying it into a List[Float64].
  • StringSequence: Float64Sequence’s counterpart for categorical data (Plot.encode_categorical()’s x), with String elements.