Skip to content

Commit

Permalink
Revert types for pywrapfst.
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebgorman committed Jul 18, 2024
1 parent 941261a commit abbf506
Showing 1 changed file with 29 additions and 59 deletions.
88 changes: 29 additions & 59 deletions pywrapfst/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ _Filename = Union[os.PathLike, str]
_Symbol = str
_Label = int
_StateId = int
_ArcIteratorPropertiesType = int
_EncodeMapperPropertiesType = int

ArcMapType = Literal["identity", "input_epsilon", "invert",
"output_epsilon", "plus", "power", "quantize",
Expand Down Expand Up @@ -70,15 +72,11 @@ _WeightStr = Union[str, int, float]
WeightLike = Union[Weight, _WeightStr]

class Weight:
def __init__(self, weight_type: _WeightType, weight: _WeightStr) -> None: ...
def copy(self) -> Weight: ...
def type(self) -> _WeightType: ...
def to_string(self) -> str: ...
def __repr__(self) -> str: ...
def __str__(self) -> str: ...
def __float__(self) -> float: ...
def member(self) -> bool: ...
def properties() -> WeightProperties: ...
def __init__(self, weight_type: _WeightType, weight: _WeightStr) -> None: ...
def copy(self) -> Weight: ...
@classmethod
def zero(cls, weight_type: _WeightType) -> Weight: ...
@classmethod
Expand All @@ -87,6 +85,9 @@ class Weight:
def no_weight(cls, weight_type: _WeightType) -> Weight: ...
def __eq__(w1: Weight, w2: Weight) -> bool: ...
def __ne__(w1: Weight, w2: Weight) -> bool: ...
def to_string(self) -> str: ...
def type(self) -> _WeightType: ...
def member(self) -> bool: ...

# TODO(wolfsonkin): Look into converting these to operator overloading instead.
def plus(lhs: Weight, rhs: Weight) -> Weight: ...
Expand Down Expand Up @@ -170,7 +171,7 @@ class EncodeMapper:
def __reduce__(self) -> Union[str, Tuple[Any, ...]]: ...
def arc_type(self) -> _ArcTypeFlag: ...
def weight_type(self) -> _WeightType: ...
def flags(self) -> EncodeMapperFlags: ...
def flags(self) -> _EncodeMapperPropertiesType: ...
def properties(self, mask: FstProperties) -> FstProperties: ...
@classmethod
def read(cls, source: _Filename) -> EncodeMapper: ...
Expand Down Expand Up @@ -436,52 +437,21 @@ POS_TRINARY_PROPERTIES: FstProperties
NEG_TRINARY_PROPERTIES: FstProperties
FST_PROPERTIES: FstProperties

## Weight properties.

class WeightProperties(enum.Flag):
LEFT_SEMIRING: int
RIGHT_SEMIRING: int
SEMIRING: int
COMMUTATIVE: int
IDEMPOTENT: int
PATH: int

LEFT_SEMIRING: WeightProperties
RIGHT_SEMIRING: WeightProperties
SEMIRING: WeightProperties
COMMUTATIVE: WeightProperties
IDEMPOTENT: WeightProperties
PATH: WeightProperties

## Arc iterator flags.

class ArcIteratorFlags(enum.Flag):
ARC_ILABEL_VALUE: int
ARC_O_LABEL_VALUE: int
ARC_WEIGHT_VALUE: int
ARC_NEXT_STATE_VALUE: int
ARC_NO_CACHE: int
ARC_VALUE_FLAGS: int
ARC_FLAGS: int

ARC_I_LABEL_VALUE: ArcIteratorFlags
ARC_O_LABEL_VALUE: ArcIteratorFlags
ARC_WEIGHT_VALUE: ArcIteratorFlags
ARC_NEXT_STATE_VALUE: ArcIteratorFlags
ARC_NO_CACHE: ArcIteratorFlags
ARC_VALUE_FLAGS: ArcIteratorFlags
ARC_FLAGS: ArcIteratorFlags

## EncodeMapper flags.

class EncodeMapperFlags(enum.Flag):
ENCODE_LABELS: int
ENCODE_WEIGHTS: int
ENCODE_FLAGS: int

ENCODE_LABELS: EncodeMapperFlags
ENCODE_WEIGHTS: EncodeMapperFlags
ENCODE_FLAGS: EncodeMapperFlags
## Arc iterator properties.

ARC_I_LABEL_VALUE: _ArcIteratorPropertiesType
ARC_O_LABEL_VALUE: _ArcIteratorPropertiesType
ARC_WEIGHT_VALUE: _ArcIteratorPropertiesType
ARC_NEXT_STATE_VALUE: _ArcIteratorPropertiesType
ARC_NO_CACHE: _ArcIteratorPropertiesType
ARC_VALUE_FLAGS: _ArcIteratorPropertiesType
ARC_FLAGS: _ArcIteratorPropertiesType

## EncodeMapper properties.

ENCODE_LABELS: _EncodeMapperPropertiesType
ENCODE_WEIGHTS: _EncodeMapperPropertiesType
ENCODE_FLAGS: _EncodeMapperPropertiesType

## Arc.

Expand Down Expand Up @@ -516,14 +486,14 @@ class _ArcIterator:
def __iter__(self) -> _ArcIterator: ...
def __next__(self) -> Arc: ...
def done(self) -> bool: ...
def flags(self) -> ArcIteratorFlags: ...
def flags(self) -> _ArcIteratorPropertiesType: ...
def next(self) -> None: ...
def position(self) -> int: ...
def reset(self) -> None: ...
def seek(self, a: int) -> None: ...
def set_flags(self,
flags: ArcIteratorFlags,
mask: ArcIteratorFlags) -> None: ...
flags: _ArcIteratorPropertiesType,
mask: _ArcIteratorPropertiesType) -> None: ...
def value(self) -> Arc: ...

class _MutableArcIterator:
Expand All @@ -533,14 +503,14 @@ class _MutableArcIterator:
def __iter__(self) -> _MutableArcIterator: ...
def __next__(self) -> Arc: ...
def done(self) -> bool: ...
def flags(self) -> ArcIteratorFlags: ...
def flags(self) -> _ArcIteratorPropertiesType: ...
def next(self) -> None: ...
def position(self) -> int: ...
def reset(self) -> None: ...
def seek(self, a: int) -> None: ...
def set_flags(self,
flags: ArcIteratorFlags,
mask: ArcIteratorFlags) -> None: ...
flags: _ArcIteratorPropertiesType,
mask: _ArcIteratorPropertiesType) -> None: ...
def set_value(self, arc: Arc) -> None: ...
def value(self) -> Arc: ...

Expand Down

0 comments on commit abbf506

Please sign in to comment.