Библиотека для безопасной универсальной нормализации альтернативных форматов ввода числовых данных — как в виде чисел, так и в виде строк с числовыми значениями — к стандартам записи чисел в Python и типизации их в int или float, а для случаев, когда входные данные не являются числовыми, библиотека гарантирует возврат данных с сохранением исходного типа и значения.
Project description
numnorm
Под английским на русском :-)
In English:
The library provides safe and universal normalization of alternative input formats for numerical data. It handles both direct numeric values and string representations of numbers, bringing them into compliance with Python’s number notation standards and converting them to int or float types.
At the same time, for data that are not numeric, the library guarantees preservation of the original data type and value — no information loss occurs.
The library is robust when processing input data of various classes: str, int, float, list, tuple, dict, set, bool, complex, object — none of these types will cause an error during its operation.
The code below provides some examples of alternative number input formats, both numeric and string, that the library can correctly process, normalize, and convert to the appropriate data type.
from numnorm import norm
num_1 = 4/2
num_2 = -0.0
num_3 = '-,5'
num_4 = '+000,000'
num_5 = '-123,0'
num_6 = '+123,500'
print (num_1, type(num_1), norm(num_1), type(norm(num_1)))
print (num_2, type(num_2), norm(num_2), type(norm(num_2)))
print (num_3, type(num_3), norm(num_3), type(norm(num_3)))
print (num_4, type(num_4), norm(num_4), type(norm(num_4)))
print (num_5, type(num_5), norm(num_5), type(norm(num_5)))
print (num_6, type(num_6), norm(num_6), type(norm(num_6)))
Output:
2.0 <class 'float'> 2 <class 'int'>
-0.0 <class 'float'> 0 <class 'int'>
-,5 <class 'str'> -0.5 <class 'float'>
+000,000 <class 'str'> 0 <class 'int'>
-123,0 <class 'str'> -123 <class 'int'>
+123,500 <class 'str'> 123.5 <class 'float'>
Usage
Import the norm unction from the numnorm library:
from numnorm import norm
Accessing the function:
result = norm(data)
where:
data - input data to be processed;
result - processing result of the input data.
Installation
Install the package using pip:
pip install numnorm
На русском:
Библиотека обеспечивает безопасную и универсальную нормализацию альтернативных форматов ввода числовых данных. Она работает как с непосредственными числовыми значениями, так и со строковыми представлениями чисел, приводя их к стандартам записи чисел в Python и преобразуя в типы int или float.
При этом для данных, которые не являются числовыми, библиотека гарантирует сохранение исходного типа и значения — никакой потери информации не происходит.
Библиотека устойчива к входным данным различных классов: str, int, float, list, tuple, dict, set, bool, complex, object — ни один из этих типов не приведёт к возникновению ошибки в процессе её работы.
В коде ниже представлены некоторые примеры альтернативных форматов ввода чисел — как в числовом, так и в строковом виде, — которые библиотека способна корректно обработать, нормализовать и привести к соответствующему типу данных.
from numnorm import norm
num_1 = 4/2
num_2 = -0.0
num_3 = '-,5'
num_4 = '+000,000'
num_5 = '-123,0'
num_6 = '+123,500'
print (num_1, type(num_1), norm(num_1), type(norm(num_1)))
print (num_2, type(num_2), norm(num_2), type(norm(num_2)))
print (num_3, type(num_3), norm(num_3), type(norm(num_3)))
print (num_4, type(num_4), norm(num_4), type(norm(num_4)))
print (num_5, type(num_5), norm(num_5), type(norm(num_5)))
print (num_6, type(num_6), norm(num_6), type(norm(num_6)))
Результат:
2.0 <class 'float'> 2 <class 'int'>
-0.0 <class 'float'> 0 <class 'int'>
-,5 <class 'str'> -0.5 <class 'float'>
+000,000 <class 'str'> 0 <class 'int'>
-123,0 <class 'str'> -123 <class 'int'>
+123,500 <class 'str'> 123.5 <class 'float'>
Использование:
Импортируйте функцию norm из библиотеки numnorm :
from numnorm import norm
Обращение к функции:
result = norm(data)
где:
data - исходные данные для обработки;
result - результат обработки исходных данных.
Установка
Установите пакет через pip:
pip install numnorm
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file numnorm-1.1.0.tar.gz.
File metadata
- Download URL: numnorm-1.1.0.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0dd58a9b7ee0253cbccbcb1c4acdc9e1aabff77d9bdc1172863f0772b04bdc12
|
|
| MD5 |
393eb3de4dce48c26ecf99bcd3a9ee8b
|
|
| BLAKE2b-256 |
2d59020b7a2d50a60e97431e3615cd4398cd79bebd29c93409cfc96b8f8d63b8
|
File details
Details for the file numnorm-1.1.0-py3-none-any.whl.
File metadata
- Download URL: numnorm-1.1.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
083313fc9452d7e1571de6350c695fd735788a208bdc70ed30a38538073adff9
|
|
| MD5 |
1129b9be9f2735aea25ed4ae46021c42
|
|
| BLAKE2b-256 |
973028659c66b18407afb1d382973437dac2337928080828eb0aaa904de1d31c
|