mirror of
https://github.com/kristoferssolo/School.git
synced 2025-10-21 20:10:38 +00:00
48 lines
1.2 KiB
Python
48 lines
1.2 KiB
Python
from typing import (
|
|
Any,
|
|
Callable,
|
|
Literal,
|
|
overload,
|
|
)
|
|
|
|
import numpy as np
|
|
|
|
_BinOp = Callable[[Any, Any], Any]
|
|
_BoolOp = Callable[[Any, Any], bool]
|
|
|
|
def scalar_compare(
|
|
values: np.ndarray, # object[:]
|
|
val: object,
|
|
op: _BoolOp, # {operator.eq, operator.ne, ...}
|
|
) -> np.ndarray: ... # np.ndarray[bool]
|
|
def vec_compare(
|
|
left: np.ndarray, # np.ndarray[object]
|
|
right: np.ndarray, # np.ndarray[object]
|
|
op: _BoolOp, # {operator.eq, operator.ne, ...}
|
|
) -> np.ndarray: ... # np.ndarray[bool]
|
|
def scalar_binop(
|
|
values: np.ndarray, # object[:]
|
|
val: object,
|
|
op: _BinOp, # binary operator
|
|
) -> np.ndarray: ...
|
|
def vec_binop(
|
|
left: np.ndarray, # object[:]
|
|
right: np.ndarray, # object[:]
|
|
op: _BinOp, # binary operator
|
|
) -> np.ndarray: ...
|
|
@overload
|
|
def maybe_convert_bool(
|
|
arr: np.ndarray, # np.ndarray[object]
|
|
true_values=...,
|
|
false_values=...,
|
|
convert_to_masked_nullable: Literal[False] = ...,
|
|
) -> tuple[np.ndarray, None]: ...
|
|
@overload
|
|
def maybe_convert_bool(
|
|
arr: np.ndarray, # np.ndarray[object]
|
|
true_values=...,
|
|
false_values=...,
|
|
*,
|
|
convert_to_masked_nullable: Literal[True],
|
|
) -> tuple[np.ndarray, np.ndarray]: ...
|