BDPotentiometer 0.0.4__tar.gz → 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {BDPotentiometer-0.0.4/src/BDPotentiometer.egg-info → bdpotentiometer-0.1.0}/PKG-INFO +1 -1
- {BDPotentiometer-0.0.4 → bdpotentiometer-0.1.0}/pyproject.toml +6 -1
- {BDPotentiometer-0.0.4 → bdpotentiometer-0.1.0}/src/BDPotentiometer/__helpers.py +8 -8
- {BDPotentiometer-0.0.4 → bdpotentiometer-0.1.0}/src/BDPotentiometer/__init__.py +2 -1
- bdpotentiometer-0.1.0/src/BDPotentiometer/__logger.py +25 -0
- bdpotentiometer-0.1.0/src/BDPotentiometer/digital_potentiometer.py +662 -0
- {BDPotentiometer-0.0.4 → bdpotentiometer-0.1.0}/src/BDPotentiometer/digital_wiper.py +47 -107
- {BDPotentiometer-0.0.4 → bdpotentiometer-0.1.0}/src/BDPotentiometer/mcp4xxx/mcp4xx1.py +24 -22
- {BDPotentiometer-0.0.4 → bdpotentiometer-0.1.0}/src/BDPotentiometer/mcp4xxx/mcp4xx2.py +19 -19
- {BDPotentiometer-0.0.4 → bdpotentiometer-0.1.0}/src/BDPotentiometer/mcp4xxx/mcp4xxx.py +14 -7
- bdpotentiometer-0.1.0/src/BDPotentiometer/potentiometer.py +373 -0
- {BDPotentiometer-0.0.4 → bdpotentiometer-0.1.0/src/BDPotentiometer.egg-info}/PKG-INFO +1 -1
- {BDPotentiometer-0.0.4 → bdpotentiometer-0.1.0}/src/BDPotentiometer.egg-info/SOURCES.txt +1 -0
- {BDPotentiometer-0.0.4 → bdpotentiometer-0.1.0}/tests/test_version.py +1 -0
- BDPotentiometer-0.0.4/src/BDPotentiometer/digital_potentiometer.py +0 -522
- BDPotentiometer-0.0.4/src/BDPotentiometer/potentiometer.py +0 -260
- {BDPotentiometer-0.0.4 → bdpotentiometer-0.1.0}/LICENSE +0 -0
- {BDPotentiometer-0.0.4 → bdpotentiometer-0.1.0}/README.md +0 -0
- {BDPotentiometer-0.0.4 → bdpotentiometer-0.1.0}/setup.cfg +0 -0
- {BDPotentiometer-0.0.4 → bdpotentiometer-0.1.0}/src/BDPotentiometer/__gpiozero_helpers.py +0 -0
- {BDPotentiometer-0.0.4 → bdpotentiometer-0.1.0}/src/BDPotentiometer/mcp4xxx/__init__.py +0 -0
- {BDPotentiometer-0.0.4 → bdpotentiometer-0.1.0}/src/BDPotentiometer.egg-info/dependency_links.txt +0 -0
- {BDPotentiometer-0.0.4 → bdpotentiometer-0.1.0}/src/BDPotentiometer.egg-info/requires.txt +0 -0
- {BDPotentiometer-0.0.4 → bdpotentiometer-0.1.0}/src/BDPotentiometer.egg-info/top_level.txt +0 -0
|
@@ -15,13 +15,13 @@ def check_number(num: Union[float, int, Real]) -> Union[float, int]:
|
|
|
15
15
|
:return: Unchanged `num` as float or int or raises ValueError if num is not a real number.
|
|
16
16
|
"""
|
|
17
17
|
if not isinstance(num, Real):
|
|
18
|
-
raise TypeError(f"Expected integer or float number, got {type(num)}")
|
|
18
|
+
raise TypeError(f"Expected a finite integer or float number, got {type(num)}")
|
|
19
19
|
if isinstance(num, Integral):
|
|
20
20
|
return int(num)
|
|
21
21
|
if num in [float("inf"), float("-inf")]:
|
|
22
|
-
raise ValueError(f"Expected integer or float number, got {num}")
|
|
22
|
+
raise ValueError(f"Expected a finite integer or float number, got {num}")
|
|
23
23
|
if isnan(num):
|
|
24
|
-
raise ValueError("Expected integer or float number, not NaN")
|
|
24
|
+
raise ValueError("Expected a finite integer or float number, not NaN")
|
|
25
25
|
if num == 0:
|
|
26
26
|
return 0.0
|
|
27
27
|
return float(num)
|
|
@@ -37,7 +37,7 @@ def check_integer(num: Union[float, int, Real]) -> int:
|
|
|
37
37
|
num = check_number(num)
|
|
38
38
|
if isinstance(num, float):
|
|
39
39
|
if not num.is_integer():
|
|
40
|
-
raise ValueError("
|
|
40
|
+
raise ValueError(f"Expected an integer number, got {num}")
|
|
41
41
|
return int(num)
|
|
42
42
|
|
|
43
43
|
|
|
@@ -50,7 +50,7 @@ def check_not_negative(num: Union[float, int]) -> Union[float, int]:
|
|
|
50
50
|
"""
|
|
51
51
|
num = check_number(num)
|
|
52
52
|
if num < 0:
|
|
53
|
-
raise ValueError("
|
|
53
|
+
raise ValueError(f"Expected non-negative number, got {num}")
|
|
54
54
|
return num
|
|
55
55
|
|
|
56
56
|
|
|
@@ -63,7 +63,7 @@ def check_positive(num: Union[float, int]) -> Union[float, int]:
|
|
|
63
63
|
"""
|
|
64
64
|
num = check_number(num)
|
|
65
65
|
if num <= 0:
|
|
66
|
-
raise ValueError("
|
|
66
|
+
raise ValueError(f"Expected a positive number, got {num}")
|
|
67
67
|
return num
|
|
68
68
|
|
|
69
69
|
|
|
@@ -95,7 +95,7 @@ def clamp(
|
|
|
95
95
|
|
|
96
96
|
|
|
97
97
|
def build_tuple(
|
|
98
|
-
value: Union[float, int, tuple[float
|
|
98
|
+
value: Union[float, int, tuple[float], list[float]],
|
|
99
99
|
num: Union[int, float],
|
|
100
100
|
func: Union[Callable, None] = None,
|
|
101
101
|
) -> tuple[float, ...]:
|
|
@@ -134,7 +134,7 @@ def build_tuple(
|
|
|
134
134
|
|
|
135
135
|
|
|
136
136
|
def adjust_tuple(
|
|
137
|
-
value: Union[tuple[float
|
|
137
|
+
value: Union[tuple[float], list[float]], num: int, default_value: float
|
|
138
138
|
) -> tuple[float, ...]:
|
|
139
139
|
"""
|
|
140
140
|
Adjusts tuple or list of floats to a given length `num` and returns a tuple.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""Logging helper functions"""
|
|
2
|
+
|
|
3
|
+
from typing import Union
|
|
4
|
+
import logging
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def get_logger(label: str, log_level: Union[int, None] = None) -> logging.Logger:
|
|
8
|
+
"""Creates logger"""
|
|
9
|
+
logger = logging.getLogger(label)
|
|
10
|
+
if log_level:
|
|
11
|
+
logger.setLevel(log_level)
|
|
12
|
+
else:
|
|
13
|
+
logger.setLevel(logging.ERROR)
|
|
14
|
+
# create console handler and set level to debug
|
|
15
|
+
ch = logging.StreamHandler()
|
|
16
|
+
ch.setLevel(logger.level)
|
|
17
|
+
# create formatter
|
|
18
|
+
formatter = logging.Formatter(
|
|
19
|
+
"%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
|
20
|
+
)
|
|
21
|
+
# add formatter to ch
|
|
22
|
+
ch.setFormatter(formatter)
|
|
23
|
+
# add ch to logger
|
|
24
|
+
logger.addHandler(ch)
|
|
25
|
+
return logger
|