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
datais provided, it converts the given Python object into an ArrayVector of the specifiedtype.If
datais not provided, an ArrayVector is constructed using the givenindexandvalue, with an optionaltype.
- 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
datais None). Defaults to None.value (Any, optional) – The value portion of the ArrayVector, typically a sequence of values (used when
datais 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:
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[])