array_vector#

swordfish.array_vector(data: Any = None, *, type: DataType = None) ArrayVector#
swordfish.array_vector(*, index: Any = None, value: Any = None, type: DataType = None) ArrayVector

Creates a Swordfish ArrayVector from a Python object or using specified index, value, and type.

There are two modes of initialization:

  • If data is provided, it converts the given Python object into an ArrayVector of the specified type.

  • If data is not provided, an ArrayVector is constructed using the given index and value, with an optional type.

Parameters:
  • data (Any, optional) – The input data to initialize the ArrayVector. Defaults to None.

  • index (Any, optional) – The index portion of the ArrayVector, typically a sequence of indices (used when data is None). Defaults to None.

  • value (Any, optional) – The value portion of the ArrayVector, typically a sequence of values (used when data is None). Defaults to None.

  • type (DataType, optional) – The data type of the ArrayVector. If None, it is inferred. Defaults to None.

Returns:

A Swordfish ArrayVector initialized based on the provided arguments.

Return type:

ArrayVector

Examples

Creating an ArrayVector from existing data:
>>> import swordfish as sf
>>> sf.array_vector([[1, 2], [3, 4, 5], []], type="INT")
ArrayVector([[1,2],[3,4,5],], type=INT[])
Creating an ArrayVector using index and value:
>>> sf.array_vector(index=[1, 2, 3], value=[10, 20, 30], type="SHORT")
ArrayVector([[10],[20],[30]], type=SHORT[])