libdev 0.73__tar.gz → 0.75__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.
Files changed (37) hide show
  1. {libdev-0.73 → libdev-0.75}/PKG-INFO +1 -1
  2. libdev-0.75/libdev/__init__.py +7 -0
  3. {libdev-0.73 → libdev-0.75}/libdev/num.py +77 -23
  4. {libdev-0.73 → libdev-0.75}/libdev/time.py +1 -1
  5. {libdev-0.73 → libdev-0.75}/libdev.egg-info/PKG-INFO +1 -1
  6. libdev-0.75/setup.py +63 -0
  7. libdev-0.75/tests/test_num.py +157 -0
  8. libdev-0.73/libdev/__init__.py +0 -9
  9. libdev-0.73/setup.py +0 -63
  10. libdev-0.73/tests/test_num.py +0 -119
  11. {libdev-0.73 → libdev-0.75}/LICENSE +0 -0
  12. {libdev-0.73 → libdev-0.75}/README.md +0 -0
  13. {libdev-0.73 → libdev-0.75}/libdev/cfg.py +0 -0
  14. {libdev-0.73 → libdev-0.75}/libdev/check.py +0 -0
  15. {libdev-0.73 → libdev-0.75}/libdev/codes.py +0 -0
  16. {libdev-0.73 → libdev-0.75}/libdev/dev.py +0 -0
  17. {libdev-0.73 → libdev-0.75}/libdev/doc.py +0 -0
  18. {libdev-0.73 → libdev-0.75}/libdev/fin.py +0 -0
  19. {libdev-0.73 → libdev-0.75}/libdev/gen.py +0 -0
  20. {libdev-0.73 → libdev-0.75}/libdev/img.py +0 -0
  21. {libdev-0.73 → libdev-0.75}/libdev/lang.py +0 -0
  22. {libdev-0.73 → libdev-0.75}/libdev/s3.py +0 -0
  23. {libdev-0.73 → libdev-0.75}/libdev.egg-info/SOURCES.txt +0 -0
  24. {libdev-0.73 → libdev-0.75}/libdev.egg-info/dependency_links.txt +0 -0
  25. {libdev-0.73 → libdev-0.75}/libdev.egg-info/requires.txt +0 -0
  26. {libdev-0.73 → libdev-0.75}/libdev.egg-info/top_level.txt +0 -0
  27. {libdev-0.73 → libdev-0.75}/setup.cfg +0 -0
  28. {libdev-0.73 → libdev-0.75}/tests/test_cfg.py +0 -0
  29. {libdev-0.73 → libdev-0.75}/tests/test_check.py +0 -0
  30. {libdev-0.73 → libdev-0.75}/tests/test_codes.py +0 -0
  31. {libdev-0.73 → libdev-0.75}/tests/test_dev.py +0 -0
  32. {libdev-0.73 → libdev-0.75}/tests/test_doc.py +0 -0
  33. {libdev-0.73 → libdev-0.75}/tests/test_gen.py +0 -0
  34. {libdev-0.73 → libdev-0.75}/tests/test_img.py +0 -0
  35. {libdev-0.73 → libdev-0.75}/tests/test_lang.py +0 -0
  36. {libdev-0.73 → libdev-0.75}/tests/test_s3.py +0 -0
  37. {libdev-0.73 → libdev-0.75}/tests/test_time.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: libdev
3
- Version: 0.73
3
+ Version: 0.75
4
4
  Summary: Set of standard functions for development
5
5
  Home-page: https://github.com/kosyachniy/lib
6
6
  Author: Alexey Poloz
@@ -0,0 +1,7 @@
1
+ """
2
+ Initializing the Python package
3
+ """
4
+
5
+ __version__ = "0.75"
6
+
7
+ __all__ = ("__version__",)
@@ -8,7 +8,7 @@ from decimal import Decimal
8
8
 
9
9
 
10
10
  def is_float(value: str) -> bool:
11
- """ Check value for float """
11
+ """Check value for float"""
12
12
 
13
13
  try:
14
14
  float(value)
@@ -17,8 +17,9 @@ def is_float(value: str) -> bool:
17
17
 
18
18
  return True
19
19
 
20
+
20
21
  def to_num(value) -> bool:
21
- """ Convert value to int or float """
22
+ """Convert value to int or float"""
22
23
 
23
24
  if value is None:
24
25
  return None
@@ -31,16 +32,18 @@ def to_num(value) -> bool:
31
32
 
32
33
  return value
33
34
 
35
+
34
36
  def to_int(value) -> int:
35
- """ Choose only decimal """
37
+ """Choose only decimal"""
36
38
 
37
39
  if not value:
38
40
  return 0
39
41
 
40
- return int(re.sub(r'\D', '', str(value)))
42
+ return int(re.sub(r"\D", "", str(value)))
43
+
41
44
 
42
45
  def get_float(value) -> list:
43
- """ Get a list of floats """
46
+ """Get a list of floats"""
44
47
 
45
48
  if value is None:
46
49
  return []
@@ -48,8 +51,9 @@ def get_float(value) -> list:
48
51
  numbers = re.findall(r"[-+]?\d*\.\d+|[-+]?\d+", value)
49
52
  return [float(number) for number in numbers]
50
53
 
54
+
51
55
  def find_decimals(value):
52
- """ Get count of decimal """
56
+ """Get count of decimal"""
53
57
 
54
58
  if isinstance(value, str):
55
59
  while value[-1] == "0":
@@ -57,12 +61,11 @@ def find_decimals(value):
57
61
 
58
62
  return abs(Decimal(str(value)).as_tuple().exponent)
59
63
 
64
+
60
65
  def get_whole(value):
61
- """ Get whole view of a number """
66
+ """Get whole view of a number"""
62
67
 
63
- if isinstance(value, int) or (
64
- isinstance(value, str) and '.' not in value
65
- ):
68
+ if isinstance(value, int) or (isinstance(value, str) and "." not in value):
66
69
  # NOTE: to remove 0 in the start of the string
67
70
  return str(int(value))
68
71
 
@@ -72,17 +75,18 @@ def get_whole(value):
72
75
  # NOTE: to avoid the exponential form of the number
73
76
  return f"{value:.{find_decimals(value)}f}"
74
77
 
78
+
75
79
  def simplify_value(value, decimals=4):
76
- """ Get the significant part of a number """
80
+ """Get the significant part of a number"""
77
81
 
78
82
  if value is None:
79
83
  return None
80
84
 
81
85
  value = get_whole(value)
82
- if '.' not in value:
83
- value += '.'
86
+ if "." not in value:
87
+ value += "."
84
88
 
85
- whole, fractional = value.split('.')
89
+ whole, fractional = value.split(".")
86
90
 
87
91
  if value[0] == "-":
88
92
  sign = "-"
@@ -92,7 +96,7 @@ def simplify_value(value, decimals=4):
92
96
 
93
97
  if whole != "0":
94
98
  digit = len(whole)
95
- value = whole + "." + fractional[:max(0, decimals-digit)]
99
+ value = whole + "." + fractional[: max(0, decimals - digit)]
96
100
 
97
101
  else:
98
102
  offset = 0
@@ -110,8 +114,37 @@ def simplify_value(value, decimals=4):
110
114
 
111
115
  return sign + value
112
116
 
117
+
118
+ def pretty(value, decimals=None, sign=False, symbol="’"):
119
+ """Decorate the number beautifully"""
120
+
121
+ if value is None:
122
+ return None
123
+
124
+ data = str(float(value))
125
+
126
+ if decimals is not None:
127
+ cur = len(data.split(".")[0])
128
+ data = str(round(value, max(0, decimals - cur)))
129
+
130
+ if data.split(".")[-1] == "0":
131
+ data = data.split(".")[0]
132
+
133
+ if data == "0":
134
+ return "0"
135
+
136
+ if symbol:
137
+ data = add_radix(data, symbol)
138
+
139
+ if sign:
140
+ if data[0] != "-":
141
+ data = "+" + data
142
+
143
+ return data
144
+
145
+
113
146
  def add_sign(value):
114
- """ Add sign to a number """
147
+ """Add sign to a number"""
115
148
 
116
149
  if value is None:
117
150
  return None
@@ -125,23 +158,27 @@ def add_sign(value):
125
158
 
126
159
  return f"{sign}{get_whole(value)}"
127
160
 
161
+
128
162
  def add_radix(value, symbol="’"):
129
- """ Add radix to a number """
163
+ """Add radix to a number"""
130
164
 
131
165
  if value is None:
132
166
  return None
133
167
 
134
168
  value = str(value)
135
169
 
136
- if '.' in value:
137
- integer, fractional = value.split('.')
170
+ if "." in value:
171
+ integer, fractional = value.split(".")
138
172
  else:
139
173
  integer = value
140
174
  fractional = ""
141
175
 
142
- if integer[0] == '-':
176
+ if integer[0] == "-":
143
177
  sign = "-"
144
178
  integer = integer[1:]
179
+ # elif integer[0] == '+':
180
+ # sign = '+'
181
+ # integer = integer[1:]
145
182
  else:
146
183
  sign = ""
147
184
 
@@ -159,20 +196,37 @@ def add_radix(value, symbol="’"):
159
196
 
160
197
  return data
161
198
 
199
+
162
200
  def mul(x, y):
163
- """ Multiply fractions correctly """
201
+ """Multiply fractions correctly"""
164
202
  if x is None or y is None:
165
203
  return None
166
204
  return float(Decimal(str(x)) * Decimal(str(y)))
167
205
 
206
+
168
207
  def div(x, y):
169
- """ Divide fractions correctly """
208
+ """Divide fractions correctly"""
170
209
  if x is None or y is None:
171
210
  return None
172
211
  return float(Decimal(str(x)) / Decimal(str(y)))
173
212
 
213
+
214
+ def add(x, y):
215
+ """Subtract fractions correctly"""
216
+ if x is None or y is None:
217
+ return None
218
+ return float(Decimal(str(x)) + Decimal(str(y)))
219
+
220
+
221
+ def sub(x, y):
222
+ """Subtract fractions correctly"""
223
+ if x is None or y is None:
224
+ return None
225
+ return float(Decimal(str(x)) - Decimal(str(y)))
226
+
227
+
174
228
  def to_step(value, step=1, side=False):
175
- """ Change value step """
229
+ """Change value step"""
176
230
 
177
231
  if value is None:
178
232
  return None
@@ -167,7 +167,7 @@ def parse_time(data: str, tz=0):
167
167
 
168
168
  return int(data.timestamp())
169
169
 
170
- def format_delta(sec, short=False, locale='ru'):
170
+ def format_delta(sec, short=False, locale='en'):
171
171
  """ Format time delta in words by seconds """
172
172
 
173
173
  if abs(sec) >= 259200: # 3 days
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: libdev
3
- Version: 0.73
3
+ Version: 0.75
4
4
  Summary: Set of standard functions for development
5
5
  Home-page: https://github.com/kosyachniy/lib
6
6
  Author: Alexey Poloz
libdev-0.75/setup.py ADDED
@@ -0,0 +1,63 @@
1
+ """
2
+ Setup the Python package
3
+ """
4
+
5
+ import pathlib
6
+ import re
7
+ from setuptools import setup, find_packages
8
+
9
+
10
+ with open("README.md", "r", encoding="utf-8") as file:
11
+ long_description = file.read()
12
+
13
+ WORK_DIR = pathlib.Path(__file__).parent
14
+
15
+
16
+ def get_version():
17
+ """Get version"""
18
+
19
+ txt = (WORK_DIR / "libdev" / "__init__.py").read_text("utf-8")
20
+
21
+ try:
22
+ return re.findall(r"^__version__ = \"([^\"]+)\"\r?$", txt, re.M)[0]
23
+ except IndexError as e:
24
+ raise RuntimeError("Unable to determine version") from e
25
+
26
+
27
+ setup(
28
+ name="libdev",
29
+ version=get_version(),
30
+ description="Set of standard functions for development",
31
+ long_description=long_description,
32
+ long_description_content_type="text/markdown",
33
+ url="https://github.com/kosyachniy/lib",
34
+ author="Alexey Poloz",
35
+ author_email="polozhev@mail.ru",
36
+ classifiers=[
37
+ "Development Status :: 4 - Beta",
38
+ "Environment :: Console",
39
+ "Intended Audience :: Developers",
40
+ "Topic :: Software Development :: Libraries :: Application Frameworks",
41
+ "License :: OSI Approved :: MIT License",
42
+ "Programming Language :: Python :: 3",
43
+ "Operating System :: OS Independent",
44
+ ],
45
+ keywords=(
46
+ "standard, lib, dev, development, cfg, config, generate, codes, "
47
+ "tokens, ids, passwords, generator, ciphers, time, formatter, nlp, "
48
+ "natural language, aws, s3, upload file, file server"
49
+ ),
50
+ packages=find_packages(exclude=("tests",)),
51
+ python_requires=">=3.7, <4",
52
+ install_requires=[
53
+ "requests", # Because of conflicts with main repo
54
+ "python-dotenv==1.0.0",
55
+ "boto3==1.28.46",
56
+ "Pillow==10.0.0",
57
+ ],
58
+ project_urls={
59
+ "Source": "https://github.com/kosyachniy/lib",
60
+ },
61
+ license="MIT",
62
+ include_package_data=False,
63
+ )
@@ -0,0 +1,157 @@
1
+ from libdev.num import (
2
+ is_float,
3
+ to_num,
4
+ to_int,
5
+ get_float,
6
+ find_decimals,
7
+ get_whole,
8
+ simplify_value,
9
+ add_sign,
10
+ add_radix,
11
+ to_step,
12
+ add,
13
+ pretty,
14
+ )
15
+
16
+
17
+ def test_float():
18
+ assert is_float("0") == True
19
+ assert is_float("-0.") == True
20
+ assert is_float("-.0") == True
21
+ assert is_float(".1") == True
22
+ assert is_float("-.2") == True
23
+ assert is_float("-3.") == True
24
+ assert is_float("4.0") == True
25
+ assert is_float("-5.678") == True
26
+ assert is_float("6.7x") == False
27
+ assert is_float("-7..8") == False
28
+ assert is_float("") == False
29
+ assert is_float(".") == False
30
+ assert is_float(1) == True
31
+ assert is_float(-2.0) == True
32
+ assert is_float(None) == False
33
+
34
+
35
+ def test_num():
36
+ assert to_num("0") == 0
37
+ assert to_num("1.") == 1
38
+ assert to_num("-2.0") == -2
39
+ assert to_num("3.45") == 3.45
40
+ assert to_num("-.0") == 0
41
+ assert to_num(-4.5) == -4.5
42
+ assert to_num(5.0) == 5
43
+
44
+
45
+ def test_int():
46
+ assert to_int(None) == 0
47
+ assert to_int(0) == 0
48
+ assert to_int("") == 0
49
+ assert to_int("0") == 0
50
+ assert to_int("&nbsp;0") == 0
51
+ assert to_int(" \t\n12 -34 .&7a8") == 123478
52
+
53
+
54
+ def test_get_float():
55
+ assert get_float(None) == []
56
+ assert get_float("") == []
57
+ assert get_float("asd") == []
58
+ assert get_float("0.0") == [0.0]
59
+ assert get_float("0.") == [0.0]
60
+ assert get_float(".0") == [0.0]
61
+ assert get_float("0") == [0.0]
62
+ assert get_float("123") == [123.0]
63
+ assert get_float("asd 1.2") == [1.2]
64
+ assert get_float("asd1.2fgh") == [1.2]
65
+ assert get_float("asd1.2fgh3") == [1.2, 3.0]
66
+ assert get_float("1 2") == [1.0, 2.0]
67
+ assert get_float("1.2%.3") == [1.2, 0.3]
68
+ assert get_float("1.2-.3") == [1.2, -0.3]
69
+ assert get_float("1.2.3") == [1.2, 0.3]
70
+ assert get_float("1..2") == [1.0, 0.2]
71
+ assert get_float("1...2") == [1.0, 0.2]
72
+
73
+
74
+ def test_decimals():
75
+ assert find_decimals(0) == 0
76
+ assert find_decimals(1.0) == 1
77
+ assert find_decimals(0.120) == 2
78
+ assert find_decimals("1000.00012000") == 5
79
+ assert find_decimals(-0.000000000123456700) == 16
80
+
81
+
82
+ def test_whole():
83
+ assert get_whole(0) == "0"
84
+ assert get_whole(0.0) == "0.0"
85
+ assert get_whole(12.340) == "12.34"
86
+ assert get_whole("12.003400") == "12.0034"
87
+ assert get_whole(-0.0000000001234567) == "-0.0000000001234567"
88
+ assert get_whole("-0.0000000001234567000") == "-0.0000000001234567"
89
+
90
+
91
+ def test_simplify():
92
+ assert simplify_value("0") == "0"
93
+ assert simplify_value("0.") == "0"
94
+ assert simplify_value(-25901050.0425) == "-25901050"
95
+ assert simplify_value(-0.0000000001234567) == "-0.0000000001234"
96
+ assert simplify_value("12.345000") == "12.34"
97
+ assert simplify_value(0.01234, 2) == "0.012"
98
+ assert simplify_value("012340000000") == "12340000000"
99
+
100
+
101
+ def test_add_sign():
102
+ assert add_sign(0) == "0"
103
+ assert add_sign("0") == "0"
104
+ assert add_sign("0.") == "0.0"
105
+ assert add_sign(-0.0) == "0.0"
106
+ assert add_sign("-0") == "0"
107
+ assert add_sign(1) == "+1"
108
+ assert add_sign(-100) == "-100"
109
+ assert add_sign(-0.000000001) == "-0.000000001"
110
+ assert add_sign(1.23e-10) == "+0.000000000123"
111
+
112
+
113
+ def test_add_radix():
114
+ assert add_radix(None) == None
115
+ assert add_radix(0) == "0"
116
+ assert add_radix(0.0) == "0.0"
117
+ assert add_radix(0.1) == "0.1"
118
+ assert add_radix(1234) == "1’234"
119
+ assert add_radix(123456) == "123’456"
120
+ assert add_radix(1234567.89012) == "1’234’567.89012"
121
+
122
+
123
+ def test_to_step():
124
+ assert to_step(None) == None
125
+ assert to_step(0) == 0
126
+ assert to_step(0.0) == 0
127
+ assert to_step(0.1) == 0
128
+ assert to_step(1.2) == 1
129
+ assert to_step(1.2, 0.1) == 1.2
130
+ assert to_step(1.234, 0.1) == 1.2
131
+ assert to_step(1.234, 0.1, True) == 1.3
132
+ assert to_step(1.2, 0.1, True) == 1.2
133
+ assert to_step(1.2, 10) == 0
134
+ assert to_step(1.2, 10, True) == 10
135
+ assert to_step(123.456, 10) == 120
136
+ assert isinstance(to_step(12, 0.1), float)
137
+ assert isinstance(to_step(12.456, 1), int)
138
+
139
+
140
+ def test_add():
141
+ assert add(0.7, 0.2) == 0.9
142
+
143
+
144
+ def test_pretty():
145
+ assert pretty(None) == None
146
+ assert pretty(0) == "0"
147
+ assert pretty(0.0) == "0"
148
+ assert pretty(0.0) == "0"
149
+ assert pretty(1.0) == "1"
150
+ assert pretty(0.1) == "0.1"
151
+ assert pretty(1.1, 2) == "1.1"
152
+ assert pretty(0.1, 2) == "0.1"
153
+ assert pretty(1.1, 0) == "1"
154
+ assert pretty(1.7, 0) == "2"
155
+ assert pretty(123.456, 1) == "123"
156
+ assert pretty(123.456, 1, True) == "+123"
157
+ assert pretty(12345.6, 3, True) == "+12’346"
@@ -1,9 +0,0 @@
1
- """
2
- Initializing the Python package
3
- """
4
-
5
- __version__ = '0.73'
6
-
7
- __all__ = (
8
- '__version__',
9
- )
libdev-0.73/setup.py DELETED
@@ -1,63 +0,0 @@
1
- """
2
- Setup the Python package
3
- """
4
-
5
- import pathlib
6
- import re
7
- from setuptools import setup, find_packages
8
-
9
-
10
- with open('README.md', 'r', encoding='utf-8') as file:
11
- long_description = file.read()
12
-
13
- WORK_DIR = pathlib.Path(__file__).parent
14
-
15
-
16
- def get_version():
17
- """ Get version """
18
-
19
- txt = (WORK_DIR / 'libdev' / '__init__.py').read_text('utf-8')
20
-
21
- try:
22
- return re.findall(r"^__version__ = '([^']+)'\r?$", txt, re.M)[0]
23
- except IndexError as e:
24
- raise RuntimeError('Unable to determine version') from e
25
-
26
-
27
- setup(
28
- name='libdev',
29
- version=get_version(),
30
- description='Set of standard functions for development',
31
- long_description=long_description,
32
- long_description_content_type='text/markdown',
33
- url='https://github.com/kosyachniy/lib',
34
- author='Alexey Poloz',
35
- author_email='polozhev@mail.ru',
36
- classifiers=[
37
- 'Development Status :: 4 - Beta',
38
- 'Environment :: Console',
39
- 'Intended Audience :: Developers',
40
- 'Topic :: Software Development :: Libraries :: Application Frameworks',
41
- 'License :: OSI Approved :: MIT License',
42
- 'Programming Language :: Python :: 3',
43
- 'Operating System :: OS Independent',
44
- ],
45
- keywords=(
46
- 'standard, lib, dev, development, cfg, config, generate, codes, '
47
- 'tokens, ids, passwords, generator, ciphers, time, formatter, nlp, '
48
- 'natural language, aws, s3, upload file, file server'
49
- ),
50
- packages=find_packages(exclude=('tests',)),
51
- python_requires='>=3.7, <4',
52
- install_requires=[
53
- 'requests', # Because of conflicts with main repo
54
- 'python-dotenv==1.0.0',
55
- 'boto3==1.28.46',
56
- 'Pillow==10.0.0',
57
- ],
58
- project_urls={
59
- 'Source': 'https://github.com/kosyachniy/lib',
60
- },
61
- license='MIT',
62
- include_package_data=False,
63
- )
@@ -1,119 +0,0 @@
1
- from libdev.num import (
2
- is_float, to_num, to_int, get_float, find_decimals, get_whole,
3
- simplify_value, add_sign, add_radix, to_step,
4
- )
5
-
6
-
7
- def test_float():
8
- assert is_float('0') == True
9
- assert is_float('-0.') == True
10
- assert is_float('-.0') == True
11
- assert is_float('.1') == True
12
- assert is_float('-.2') == True
13
- assert is_float('-3.') == True
14
- assert is_float('4.0') == True
15
- assert is_float('-5.678') == True
16
- assert is_float('6.7x') == False
17
- assert is_float('-7..8') == False
18
- assert is_float('') == False
19
- assert is_float('.') == False
20
- assert is_float(1) == True
21
- assert is_float(-2.) == True
22
- assert is_float(None) == False
23
-
24
- def test_num():
25
- assert to_num('0') == 0
26
- assert to_num('1.') == 1
27
- assert to_num('-2.0') == -2
28
- assert to_num('3.45') == 3.45
29
- assert to_num('-.0') == 0
30
- assert to_num(-4.5) == -4.5
31
- assert to_num(5.0) == 5
32
-
33
- def test_int():
34
- assert to_int(None) == 0
35
- assert to_int(0) == 0
36
- assert to_int('') == 0
37
- assert to_int('0') == 0
38
- assert to_int('&nbsp;0') == 0
39
- assert to_int(' \t\n12 -34 .&7a8') == 123478
40
-
41
- def test_get_float():
42
- assert get_float(None) == []
43
- assert get_float('') == []
44
- assert get_float('asd') == []
45
- assert get_float('0.0') == [0.]
46
- assert get_float('0.') == [0.]
47
- assert get_float('.0') == [0.]
48
- assert get_float('0') == [0.]
49
- assert get_float('123') == [123.]
50
- assert get_float('asd 1.2') == [1.2]
51
- assert get_float('asd1.2fgh') == [1.2]
52
- assert get_float('asd1.2fgh3') == [1.2, 3.]
53
- assert get_float('1 2') == [1., 2.]
54
- assert get_float('1.2%.3') == [1.2, 0.3]
55
- assert get_float('1.2-.3') == [1.2, -0.3]
56
- assert get_float('1.2.3') == [1.2, 0.3]
57
- assert get_float('1..2') == [1., 0.2]
58
- assert get_float('1...2') == [1., 0.2]
59
-
60
-
61
- def test_decimals():
62
- assert find_decimals(0) == 0
63
- assert find_decimals(1.) == 1
64
- assert find_decimals(0.120) == 2
65
- assert find_decimals('1000.00012000') == 5
66
- assert find_decimals(-0.000000000123456700) == 16
67
-
68
- def test_whole():
69
- assert get_whole(0) == '0'
70
- assert get_whole(0.) == '0.0'
71
- assert get_whole(12.340) == '12.34'
72
- assert get_whole('12.003400') == '12.0034'
73
- assert get_whole(-0.0000000001234567) == '-0.0000000001234567'
74
- assert get_whole('-0.0000000001234567000') == '-0.0000000001234567'
75
-
76
- def test_simplify():
77
- assert simplify_value('0') == '0'
78
- assert simplify_value('0.') == '0'
79
- assert simplify_value(-25901050.0425) == '-25901050'
80
- assert simplify_value(-0.0000000001234567) == '-0.0000000001234'
81
- assert simplify_value('12.345000') == '12.34'
82
- assert simplify_value(0.01234, 2) == '0.012'
83
- assert simplify_value('012340000000') == '12340000000'
84
-
85
- def test_add_sign():
86
- assert add_sign(0) == '0'
87
- assert add_sign('0') == '0'
88
- assert add_sign('0.') == '0.0'
89
- assert add_sign(-0.) == '0.0'
90
- assert add_sign('-0') == '0'
91
- assert add_sign(1) == '+1'
92
- assert add_sign(-100) == '-100'
93
- assert add_sign(-0.000000001) == '-0.000000001'
94
- assert add_sign(1.23e-10) == '+0.000000000123'
95
-
96
- def test_add_radix():
97
- assert add_radix(None) == None
98
- assert add_radix(0) == '0'
99
- assert add_radix(0.) == '0.0'
100
- assert add_radix(.1) == '0.1'
101
- assert add_radix(1234) == '1’234'
102
- assert add_radix(123456) == '123’456'
103
- assert add_radix(1234567.89012) == '1’234’567.89012'
104
-
105
- def test_to_step():
106
- assert to_step(None) == None
107
- assert to_step(0) == 0
108
- assert to_step(0.) == 0
109
- assert to_step(0.1) == 0
110
- assert to_step(1.2) == 1
111
- assert to_step(1.2, 0.1) == 1.2
112
- assert to_step(1.234, 0.1) == 1.2
113
- assert to_step(1.234, 0.1, True) == 1.3
114
- assert to_step(1.2, 0.1, True) == 1.2
115
- assert to_step(1.2, 10) == 0
116
- assert to_step(1.2, 10, True) == 10
117
- assert to_step(123.456, 10) == 120
118
- assert isinstance(to_step(12, 0.1), float)
119
- assert isinstance(to_step(12.456, 1), int)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes