jina.types.ndarray.sparse package

Module contents

class jina.types.ndarray.sparse.BaseSparseNdArray(*args, **kwargs)[source]

Bases: jina.types.ndarray.BaseNdArray

The base class for SparseNdArray.

Do not use this class directly. Subclass should be used.

Set constructor method.

Parameters
  • args – args passed to super().

  • kwargs – kwargs passed to super().

null_proto()[source]

Get the new protobuf representation.

Return type

SparseNdArrayProto

Returns

An empty SparseNdArrayProto

sparse_constructor(indices, values, shape)[source]

Sparse NdArray constructor, must be implemented by subclass.

Parameters
  • indices (np.ndarray) – the indices of the sparse array

  • values (np.ndarray) – the values of the sparse array

  • shape (List[int]) – the shape of the sparse array

Return type

~AnySparseNdArray

Returns

Sparse NdArray

sparse_parser(value)[source]

Parse a Sparse NdArray to indices, values and shape, must be implemented by subclass.

Parameters

value (~AnySparseNdArray) – the sparse ndarray

Return type

Dict[str, Union[ForwardRef, List[int]]]

Returns

a Dict with three entries {‘indices’: …, ‘values’:…, ‘shape’:…}

property value

Get the value of protobuf message in SparseNdArray.

Return type

~AnySparseNdArray

Returns

A SparseNdArray.