pinecone.data.dataclasses.sparse_values

 1from dataclasses import dataclass
 2
 3from typing import List
 4from .utils import DictLike
 5from ..types import SparseVectorTypedDict
 6
 7
 8@dataclass
 9class SparseValues(DictLike):
10    indices: List[int]
11    values: List[float]
12
13    def to_dict(self) -> SparseVectorTypedDict:
14        return {"indices": self.indices, "values": self.values}
15
16    @staticmethod
17    def from_dict(sparse_values_dict: SparseVectorTypedDict) -> "SparseValues":
18        return SparseValues(
19            indices=sparse_values_dict["indices"], values=sparse_values_dict["values"]
20        )
@dataclass
class SparseValues(pinecone.data.dataclasses.utils.DictLike):
 9@dataclass
10class SparseValues(DictLike):
11    indices: List[int]
12    values: List[float]
13
14    def to_dict(self) -> SparseVectorTypedDict:
15        return {"indices": self.indices, "values": self.values}
16
17    @staticmethod
18    def from_dict(sparse_values_dict: SparseVectorTypedDict) -> "SparseValues":
19        return SparseValues(
20            indices=sparse_values_dict["indices"], values=sparse_values_dict["values"]
21        )
SparseValues(indices: List[int], values: List[float])
indices: List[int]
values: List[float]
14    def to_dict(self) -> SparseVectorTypedDict:
15        return {"indices": self.indices, "values": self.values}
@staticmethod
def from_dict( sparse_values_dict: pinecone.data.types.sparse_vector_typed_dict.SparseVectorTypedDict) -> SparseValues:
17    @staticmethod
18    def from_dict(sparse_values_dict: SparseVectorTypedDict) -> "SparseValues":
19        return SparseValues(
20            indices=sparse_values_dict["indices"], values=sparse_values_dict["values"]
21        )