Skip to content

Commit 8a997f9

Browse files
committed
rename back
1 parent f9b1e28 commit 8a997f9

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

branca/colormap.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,19 @@ def _is_hex(x: str) -> bool:
3838

3939
def _parse_hex(color_code: str) -> TypeRGBAFloats:
4040
return (
41-
_color_byte_to_normalized_float(int(color_code[1:3], 16)),
42-
_color_byte_to_normalized_float(int(color_code[3:5], 16)),
43-
_color_byte_to_normalized_float(int(color_code[5:7], 16)),
41+
_color_int_to_float(int(color_code[1:3], 16)),
42+
_color_int_to_float(int(color_code[3:5], 16)),
43+
_color_int_to_float(int(color_code[5:7], 16)),
4444
1.0,
4545
)
4646

4747

48-
def _color_byte_to_normalized_float(x: Union[int, float]) -> float:
48+
def _color_int_to_float(x: Union[int, float]) -> float:
4949
"""Convert an integer between 0 and 255 to a float between 0. and 1.0"""
5050
return x / 255.0
5151

5252

53-
def _color_normalized_float_to_byte_int(x: float) -> int:
53+
def _color_float_to_int(x: float) -> int:
5454
"""Convert a float between 0. and 1.0 to an integer between 0 and 255"""
5555
return int(x * 255.9999)
5656

@@ -78,7 +78,7 @@ def _parse_color_as_numerical_sequence(x: Union[tuple, list]) -> TypeRGBAFloats:
7878
raise ValueError(f"Color sequence should have 3 or 4 elements, not {len(x)}.")
7979
conversion_function: Callable = float
8080
if 1 < max(x) <= 255:
81-
conversion_function = _color_byte_to_normalized_float
81+
conversion_function = _color_int_to_float
8282
if min(x) < 0 or max(x) > 255:
8383
raise ValueError("Color components should be between 0.0 and 1.0 or 0 and 255.")
8484
color: List[float] = [conversion_function(value) for value in x]
@@ -175,9 +175,7 @@ def rgba_bytes_tuple(self, x: float) -> TypeRGBAInts:
175175
"""Provides the color corresponding to value `x` in the
176176
form of a tuple (R,G,B,A) with int values between 0 and 255.
177177
"""
178-
return tuple(
179-
_color_normalized_float_to_byte_int(u) for u in self.rgba_floats_tuple(x)
180-
) # type: ignore
178+
return tuple(_color_float_to_int(u) for u in self.rgba_floats_tuple(x)) # type: ignore
181179

182180
def rgb_bytes_tuple(self, x: float) -> TypeRGBInts:
183181
"""Provides the color corresponding to value `x` in the

tests/test_colormap_parse.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import pytest
22

33
from branca.colormap import (
4-
_color_byte_to_normalized_float,
5-
_color_normalized_float_to_byte_int,
4+
_color_int_to_float,
5+
_color_float_to_int,
66
_is_hex,
77
_parse_color,
88
_parse_color_as_numerical_sequence,
@@ -110,7 +110,7 @@ def test_parse_hex(input_data, expected):
110110
],
111111
)
112112
def test_color_byte_to_normalized_float(input_data, expected):
113-
assert _color_byte_to_normalized_float(input_data) == expected
113+
assert _color_int_to_float(input_data) == expected
114114

115115

116116
@pytest.mark.parametrize(
@@ -125,4 +125,4 @@ def test_color_byte_to_normalized_float(input_data, expected):
125125
],
126126
)
127127
def test_color_normalized_float_to_byte_int(input_data, expected):
128-
assert _color_normalized_float_to_byte_int(input_data) == expected
128+
assert _color_float_to_int(input_data) == expected

0 commit comments

Comments
 (0)