Skip to main content

Библиотека для безопасной универсальной нормализации альтернативных форматов ввода числовых данных — как в виде чисел, так и в виде строк с числовыми значениями — к стандартам записи чисел в Python и типизации их в int или float, а для случаев, когда входные данные не являются числовыми, гарантируется сохранение исходного типа и значения данных.

Project description

numnorm

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 get

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), get(num_1), type(get(num_1)))
print (num_2, type(num_2), get(num_2), type(get(num_2)))
print (num_3, type(num_3), get(num_3), type(get(num_3)))
print (num_4, type(num_4), get(num_4), type(get(num_4)))
print (num_5, type(num_5), get(num_5), type(get(num_5)))
print (num_6, type(num_6), get(num_6), type(get(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 get unction from the numnorm library:

from numnorm import get

Call the function:

result = get(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 get

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), get(num_1), type(get(num_1)))
print (num_2, type(num_2), get(num_2), type(get(num_2)))
print (num_3, type(num_3), get(num_3), type(get(num_3)))
print (num_4, type(num_4), get(num_4), type(get(num_4)))
print (num_5, type(num_5), get(num_5), type(get(num_5)))
print (num_6, type(num_6), get(num_6), type(get(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'>

Использование:

Импортируйте функцию get из библиотеки numnorm :

from numnorm import get

Обращение к функции:

result = get(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

numnorm-1.0.2.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

numnorm-1.0.2-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file numnorm-1.0.2.tar.gz.

File metadata

  • Download URL: numnorm-1.0.2.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for numnorm-1.0.2.tar.gz
Algorithm Hash digest
SHA256 bd87cb05af6dc2862e0b05f4bf34fea87361b6de28c97276fc09d441ef760efe
MD5 5dbb608bd3639bda401bd2ed6feffb0a
BLAKE2b-256 bbc0b57c4a82154dd9f3144d0661fb2a1f6318030e018ff828c011c46a8dc9bd

See more details on using hashes here.

File details

Details for the file numnorm-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: numnorm-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for numnorm-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ab8362ad8b11d4799ab6abff96320beab29256f955a8b63b1bf3c797d26f8f2b
MD5 d90c28bcd02decd1b4e657ff164f345c
BLAKE2b-256 5ebe7437e5c0e634f4d88c7fe567db7f5cdc3d0ee7354cc3a919e2a73d90f48e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page