Skip to content

Commit 0218b0f

Browse files
Rename unconstrained_map_range to map_unconstrained_range
1 parent e535518 commit 0218b0f

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

adafruit_simplemath.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def map_range(
3535
:attr:`out_min` is greater than :attr:`out_max`, the corresponding range
3636
is reversed, allowing, for example, mapping a range of 0-10 to 50-0.
3737
38-
See also :py:func:`unconstrained_map_range`
38+
See also :py:func:`map_unconstrained_range`
3939
4040
.. code-block::
4141
@@ -55,11 +55,11 @@ def map_range(
5555
:rtype: float
5656
"""
5757

58-
mapped = unconstrained_map_range(x, in_min, in_max, out_min, out_max)
58+
mapped = map_unconstrained_range(x, in_min, in_max, out_min, out_max)
5959
return constrain(mapped, out_min, out_max)
6060

6161

62-
def unconstrained_map_range(
62+
def map_unconstrained_range(
6363
x: float, in_min: float, in_max: float, out_min: float, out_max: float
6464
) -> float:
6565
"""
@@ -74,10 +74,10 @@ def unconstrained_map_range(
7474
7575
.. code-block::
7676
77-
from adafruit_simplemath import unconstrained_map_range
77+
from adafruit_simplemath import map_unconstrained_range
7878
7979
celsius = -20
80-
fahrenheit = unconstrained_map_range(celsius, 0, 100, 32, 212)
80+
fahrenheit = map_unconstrained_range(celsius, 0, 100, 32, 212)
8181
print(celsius, "degress Celsius =", fahrenheit, "degrees Fahrenheit")
8282
8383
:param float x: Value to convert

examples/simplemath_simpletest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# SPDX-License-Identifier: Unlicense
55

6-
from adafruit_simplemath import map_range, unconstrained_map_range, constrain
6+
from adafruit_simplemath import map_range, map_unconstrained_range, constrain
77

88
print("map_range() examples")
99
# Map, say, a sensor value, from a range of 0-255 to 0-1023.
@@ -21,13 +21,13 @@
2121
x = map_range(percent, 0, 100, 0, screen_width - 1)
2222
print("X position", percent, "% from the left of screen is", x)
2323

24-
print("\nunconstrained_map_range() examples")
24+
print("\nmap_unconstrained_range() examples")
2525
celsius = 20
26-
fahrenheit = unconstrained_map_range(celsius, 0, 100, 32, 212)
26+
fahrenheit = map_unconstrained_range(celsius, 0, 100, 32, 212)
2727
print(celsius, "degress Celsius =", fahrenheit, "degrees Fahrenheit")
2828

2929
celsius = -20
30-
fahrenheit = unconstrained_map_range(celsius, 0, 100, 32, 212)
30+
fahrenheit = map_unconstrained_range(celsius, 0, 100, 32, 212)
3131
print(celsius, "degress Celsius =", fahrenheit, "degrees Fahrenheit")
3232

3333
print("\nconstrain() examples")

tests/map_unconstrained_range_test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# SPDX-FileCopyrightText: 2021 James Carr
2+
#
3+
# SPDX-License-Identifier: Unlicense
4+
5+
from adafruit_simplemath import map_unconstrained_range
6+
7+
8+
def test_map_unconstrained_range():
9+
assert map_unconstrained_range(-40, 32, 212, 0, 100) == -40.0
10+
assert map_unconstrained_range(50, 32, 212, 0, 100) == 10.0
11+
assert map_unconstrained_range(392, 32, 212, 0, 100) == 200.0

tests/unconstrained_map_range_test.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)