2020-09-24 01:15:36 -04:00
|
|
|
#
|
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
# or more contributor license agreements. See the NOTICE file
|
|
|
|
# distributed with this work for additional information
|
|
|
|
# regarding copyright ownership. The ASF licenses this file
|
|
|
|
# to you under the Apache License, Version 2.0 (the
|
|
|
|
# "License"); you may not use this file except in compliance
|
|
|
|
# with the License. You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing,
|
|
|
|
# software distributed under the License is distributed on an
|
|
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
# KIND, either express or implied. See the License for the
|
|
|
|
# specific language governing permissions and limitations
|
|
|
|
# under the License.
|
|
|
|
|
|
|
|
from typing import overload
|
2020-11-24 19:27:04 -05:00
|
|
|
from typing import Any, Dict, Iterable, List, NoReturn, Optional, Tuple, Type, Union
|
2020-09-24 01:15:36 -04:00
|
|
|
|
|
|
|
from pyspark.ml import linalg as newlinalg # noqa: F401
|
|
|
|
from pyspark.sql.types import StructType, UserDefinedType
|
|
|
|
|
|
|
|
from numpy import float64, ndarray # type: ignore[import]
|
|
|
|
|
|
|
|
class VectorUDT(UserDefinedType):
|
|
|
|
@classmethod
|
|
|
|
def sqlType(cls) -> StructType: ...
|
|
|
|
@classmethod
|
|
|
|
def module(cls) -> str: ...
|
|
|
|
@classmethod
|
|
|
|
def scalaUDT(cls) -> str: ...
|
|
|
|
def serialize(
|
|
|
|
self, obj: Vector
|
|
|
|
) -> Tuple[int, Optional[int], Optional[List[int]], List[float]]: ...
|
|
|
|
def deserialize(self, datum: Any) -> Vector: ...
|
|
|
|
def simpleString(self) -> str: ...
|
|
|
|
|
|
|
|
class MatrixUDT(UserDefinedType):
|
|
|
|
@classmethod
|
|
|
|
def sqlType(cls) -> StructType: ...
|
|
|
|
@classmethod
|
|
|
|
def module(cls) -> str: ...
|
|
|
|
@classmethod
|
|
|
|
def scalaUDT(cls) -> str: ...
|
|
|
|
def serialize(
|
2020-11-24 19:27:04 -05:00
|
|
|
self, obj: Matrix
|
2020-09-24 01:15:36 -04:00
|
|
|
) -> Tuple[
|
|
|
|
int, int, int, Optional[List[int]], Optional[List[int]], List[float], bool
|
|
|
|
]: ...
|
|
|
|
def deserialize(self, datum: Any) -> Matrix: ...
|
|
|
|
def simpleString(self) -> str: ...
|
|
|
|
|
|
|
|
class Vector:
|
|
|
|
__UDT__: VectorUDT
|
|
|
|
def toArray(self) -> ndarray: ...
|
|
|
|
|
|
|
|
class DenseVector(Vector):
|
|
|
|
array: ndarray
|
|
|
|
@overload
|
|
|
|
def __init__(self, *elements: float) -> None: ...
|
|
|
|
@overload
|
|
|
|
def __init__(self, __arr: bytes) -> None: ...
|
|
|
|
@overload
|
|
|
|
def __init__(self, __arr: Iterable[float]) -> None: ...
|
2020-11-24 19:27:04 -05:00
|
|
|
def __reduce__(self) -> Tuple[Type[DenseVector], bytes]: ...
|
2020-09-24 01:15:36 -04:00
|
|
|
def numNonzeros(self) -> int: ...
|
|
|
|
def norm(self, p: Union[float, str]) -> float64: ...
|
|
|
|
def dot(self, other: Iterable[float]) -> float64: ...
|
|
|
|
def squared_distance(self, other: Iterable[float]) -> float64: ...
|
|
|
|
def toArray(self) -> ndarray: ...
|
|
|
|
@property
|
|
|
|
def values(self) -> ndarray: ...
|
|
|
|
def __getitem__(self, item: int) -> float64: ...
|
|
|
|
def __len__(self) -> int: ...
|
|
|
|
def __eq__(self, other: Any) -> bool: ...
|
|
|
|
def __ne__(self, other: Any) -> bool: ...
|
|
|
|
def __hash__(self) -> int: ...
|
|
|
|
def __getattr__(self, item: str) -> Any: ...
|
|
|
|
def __neg__(self) -> DenseVector: ...
|
|
|
|
def __add__(self, other: Union[float, Iterable[float]]) -> DenseVector: ...
|
|
|
|
def __sub__(self, other: Union[float, Iterable[float]]) -> DenseVector: ...
|
|
|
|
def __mul__(self, other: Union[float, Iterable[float]]) -> DenseVector: ...
|
|
|
|
def __div__(self, other: Union[float, Iterable[float]]) -> DenseVector: ...
|
|
|
|
def __truediv__(self, other: Union[float, Iterable[float]]) -> DenseVector: ...
|
|
|
|
def __mod__(self, other: Union[float, Iterable[float]]) -> DenseVector: ...
|
|
|
|
def __radd__(self, other: Union[float, Iterable[float]]) -> DenseVector: ...
|
|
|
|
def __rsub__(self, other: Union[float, Iterable[float]]) -> DenseVector: ...
|
|
|
|
def __rmul__(self, other: Union[float, Iterable[float]]) -> DenseVector: ...
|
|
|
|
def __rdiv__(self, other: Union[float, Iterable[float]]) -> DenseVector: ...
|
|
|
|
def __rtruediv__(self, other: Union[float, Iterable[float]]) -> DenseVector: ...
|
|
|
|
def __rmod__(self, other: Union[float, Iterable[float]]) -> DenseVector: ...
|
|
|
|
|
|
|
|
class SparseVector(Vector):
|
|
|
|
size: int
|
|
|
|
indices: ndarray
|
|
|
|
values: ndarray
|
|
|
|
@overload
|
|
|
|
def __init__(self, size: int, *args: Tuple[int, float]) -> None: ...
|
|
|
|
@overload
|
|
|
|
def __init__(self, size: int, __indices: bytes, __values: bytes) -> None: ...
|
|
|
|
@overload
|
|
|
|
def __init__(
|
|
|
|
self, size: int, __indices: Iterable[int], __values: Iterable[float]
|
|
|
|
) -> None: ...
|
|
|
|
@overload
|
|
|
|
def __init__(self, size: int, __pairs: Iterable[Tuple[int, float]]) -> None: ...
|
|
|
|
@overload
|
|
|
|
def __init__(self, size: int, __map: Dict[int, float]) -> None: ...
|
|
|
|
def numNonzeros(self) -> int: ...
|
|
|
|
def norm(self, p: Union[float, str]) -> float64: ...
|
2020-11-24 19:27:04 -05:00
|
|
|
def __reduce__(self) -> Tuple[Type[SparseVector], Tuple[int, bytes, bytes]]: ...
|
2020-09-24 01:15:36 -04:00
|
|
|
def dot(self, other: Iterable[float]) -> float64: ...
|
|
|
|
def squared_distance(self, other: Iterable[float]) -> float64: ...
|
|
|
|
def toArray(self) -> ndarray: ...
|
|
|
|
def __len__(self) -> int: ...
|
2020-11-24 19:27:04 -05:00
|
|
|
def __eq__(self, other: Any) -> bool: ...
|
2020-09-24 01:15:36 -04:00
|
|
|
def __getitem__(self, index: int) -> float64: ...
|
2020-11-24 19:27:04 -05:00
|
|
|
def __ne__(self, other: Any) -> bool: ...
|
2020-09-24 01:15:36 -04:00
|
|
|
def __hash__(self) -> int: ...
|
|
|
|
|
|
|
|
class Vectors:
|
|
|
|
@overload
|
|
|
|
@staticmethod
|
|
|
|
def sparse(size: int, *args: Tuple[int, float]) -> SparseVector: ...
|
|
|
|
@overload
|
|
|
|
@staticmethod
|
|
|
|
def sparse(size: int, __indices: bytes, __values: bytes) -> SparseVector: ...
|
|
|
|
@overload
|
|
|
|
@staticmethod
|
|
|
|
def sparse(
|
|
|
|
size: int, __indices: Iterable[int], __values: Iterable[float]
|
|
|
|
) -> SparseVector: ...
|
|
|
|
@overload
|
|
|
|
@staticmethod
|
|
|
|
def sparse(size: int, __pairs: Iterable[Tuple[int, float]]) -> SparseVector: ...
|
|
|
|
@overload
|
|
|
|
@staticmethod
|
|
|
|
def sparse(size: int, __map: Dict[int, float]) -> SparseVector: ...
|
|
|
|
@overload
|
|
|
|
@staticmethod
|
2020-11-24 19:27:04 -05:00
|
|
|
def dense(*elements: float) -> DenseVector: ...
|
2020-09-24 01:15:36 -04:00
|
|
|
@overload
|
|
|
|
@staticmethod
|
2020-11-24 19:27:04 -05:00
|
|
|
def dense(__arr: bytes) -> DenseVector: ...
|
2020-09-24 01:15:36 -04:00
|
|
|
@overload
|
|
|
|
@staticmethod
|
2020-11-24 19:27:04 -05:00
|
|
|
def dense(__arr: Iterable[float]) -> DenseVector: ...
|
2020-09-24 01:15:36 -04:00
|
|
|
@staticmethod
|
|
|
|
def stringify(vector: Vector) -> str: ...
|
|
|
|
@staticmethod
|
|
|
|
def squared_distance(v1: Vector, v2: Vector) -> float64: ...
|
|
|
|
@staticmethod
|
|
|
|
def norm(vector: Vector, p: Union[float, str]) -> float64: ...
|
|
|
|
@staticmethod
|
|
|
|
def zeros(size: int) -> DenseVector: ...
|
|
|
|
|
|
|
|
class Matrix:
|
|
|
|
__UDT__: MatrixUDT
|
|
|
|
numRows: int
|
|
|
|
numCols: int
|
|
|
|
isTransposed: bool
|
|
|
|
def __init__(
|
|
|
|
self, numRows: int, numCols: int, isTransposed: bool = ...
|
|
|
|
) -> None: ...
|
2020-11-24 19:27:04 -05:00
|
|
|
def toArray(self) -> NoReturn: ...
|
2020-09-24 01:15:36 -04:00
|
|
|
|
|
|
|
class DenseMatrix(Matrix):
|
|
|
|
values: Any
|
|
|
|
@overload
|
|
|
|
def __init__(
|
|
|
|
self, numRows: int, numCols: int, values: bytes, isTransposed: bool = ...
|
|
|
|
) -> None: ...
|
|
|
|
@overload
|
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
numRows: int,
|
|
|
|
numCols: int,
|
|
|
|
values: Iterable[float],
|
|
|
|
isTransposed: bool = ...,
|
|
|
|
) -> None: ...
|
2020-11-24 19:27:04 -05:00
|
|
|
def __reduce__(self) -> Tuple[Type[DenseMatrix], Tuple[int, int, bytes, int]]: ...
|
2020-09-24 01:15:36 -04:00
|
|
|
def toArray(self) -> ndarray: ...
|
|
|
|
def toSparse(self) -> SparseMatrix: ...
|
|
|
|
def __getitem__(self, indices: Tuple[int, int]) -> float64: ...
|
2020-11-24 19:27:04 -05:00
|
|
|
def __eq__(self, other: Any) -> bool: ...
|
2020-09-24 01:15:36 -04:00
|
|
|
|
|
|
|
class SparseMatrix(Matrix):
|
|
|
|
colPtrs: ndarray
|
|
|
|
rowIndices: ndarray
|
|
|
|
values: ndarray
|
|
|
|
@overload
|
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
numRows: int,
|
|
|
|
numCols: int,
|
|
|
|
colPtrs: bytes,
|
|
|
|
rowIndices: bytes,
|
|
|
|
values: bytes,
|
|
|
|
isTransposed: bool = ...,
|
|
|
|
) -> None: ...
|
|
|
|
@overload
|
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
numRows: int,
|
|
|
|
numCols: int,
|
|
|
|
colPtrs: Iterable[int],
|
|
|
|
rowIndices: Iterable[int],
|
|
|
|
values: Iterable[float],
|
|
|
|
isTransposed: bool = ...,
|
|
|
|
) -> None: ...
|
2020-11-24 19:27:04 -05:00
|
|
|
def __reduce__(
|
|
|
|
self,
|
|
|
|
) -> Tuple[Type[SparseMatrix], Tuple[int, int, bytes, bytes, bytes, int]]: ...
|
2020-09-24 01:15:36 -04:00
|
|
|
def __getitem__(self, indices: Tuple[int, int]) -> float64: ...
|
|
|
|
def toArray(self) -> ndarray: ...
|
|
|
|
def toDense(self) -> DenseMatrix: ...
|
2020-11-24 19:27:04 -05:00
|
|
|
def __eq__(self, other: Any) -> bool: ...
|
2020-09-24 01:15:36 -04:00
|
|
|
|
|
|
|
class Matrices:
|
|
|
|
@overload
|
|
|
|
@staticmethod
|
|
|
|
def dense(
|
|
|
|
numRows: int, numCols: int, values: bytes, isTransposed: bool = ...
|
|
|
|
) -> DenseMatrix: ...
|
|
|
|
@overload
|
|
|
|
@staticmethod
|
|
|
|
def dense(
|
|
|
|
numRows: int, numCols: int, values: Iterable[float], isTransposed: bool = ...
|
|
|
|
) -> DenseMatrix: ...
|
|
|
|
@overload
|
|
|
|
@staticmethod
|
|
|
|
def sparse(
|
|
|
|
numRows: int,
|
|
|
|
numCols: int,
|
|
|
|
colPtrs: bytes,
|
|
|
|
rowIndices: bytes,
|
|
|
|
values: bytes,
|
|
|
|
isTransposed: bool = ...,
|
|
|
|
) -> SparseMatrix: ...
|
|
|
|
@overload
|
|
|
|
@staticmethod
|
|
|
|
def sparse(
|
|
|
|
numRows: int,
|
|
|
|
numCols: int,
|
|
|
|
colPtrs: Iterable[int],
|
|
|
|
rowIndices: Iterable[int],
|
|
|
|
values: Iterable[float],
|
|
|
|
isTransposed: bool = ...,
|
|
|
|
) -> SparseMatrix: ...
|