-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibRangeMap.py
More file actions
38 lines (26 loc) · 1.35 KB
/
Copy pathlibRangeMap.py
File metadata and controls
38 lines (26 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""Compatibility module for legacy ``libRangeMap`` imports.
The canonical alpha package is ``librangemap``. This module keeps the old
``from libRangeMap import RangeMapper`` style usable for integer ranges while
moving behavior to the new dependency-free implementation.
"""
from librangemap import IntegerRangeMapper, UnsupportedTypeError
class RangeMapper(IntegerRangeMapper):
"""Compatibility wrapper around IntegerRangeMapper.
Unlike the historical experiment, the default output range is now
``[-1.0, 1.0]`` and strict out-of-range behavior is the default.
"""
def __init__(self, low: int, high: int, low_out: float = -1.0, high_out: float = 1.0, clip: bool = False) -> None:
super().__init__(input_range=(low, high), output_range=(low_out, high_out), clip=clip)
def get_input_range(self) -> list:
return list(self.input_range)
def get_output_range(self) -> list:
return list(self.output_range)
class CharRangeMapper:
"""Legacy character mapper placeholder.
Character mapping is deferred until beta because alpha does not allow
unknown characters to map to arbitrary fallback values.
"""
def __init__(self, *args, **kwargs) -> None:
raise UnsupportedTypeError(
"CharRangeMapper is legacy and not supported in Alpha v1; use IntegerRangeMapper for integer ranges."
)