A pure Python library for numeric type checking and validation
Project description
isNumber in Python
This project provides a set of Python functions for checking various properties of numbers, including integers, floats, and complex numbers. These functions can be useful for validating input, handling edge cases, and working with different number types in your Python projects.
Table of Contents
Installation
pip install the_number
Usage
Import the functions you need in your Python script:
from the_number import isInteger, isInf, isNaN, isFinite, isNumber
# Example usage
print(isNumber(5)) # True
print(isNumber(3.14)) # True
print(isNumber(1 + 2j)) # True
print(isNumber(float('inf'))) # True
print(isNumber(float('nan'))) # False
Functions
isInteger(obj: complex | float | int) -> bool
Checks if the object is an integer, float, or complex number.
Example:
print(isInteger(5)) # True
print(isInteger(3.14)) # True
print(isInteger(1 + 2j)) # True
print(isInteger("5")) # False
isInf(obj: complex | float | int) -> bool
Checks if the object is positive or negative infinity.
Example:
print(isInf(float('inf'))) # True
print(isInf(float('-inf'))) # True
print(isInf(5)) # False
isNaN(obj: complex | float | int) -> bool
Checks if the object is NaN (Not a Number).
Example:
print(isNaN(float('nan'))) # True
print(isNaN(5)) # False
isFinite(obj: complex | float | int) -> bool
Checks if the object is a finite number.
Example:
print(isFinite(5)) # True
print(isFinite(3.14)) # True
print(isFinite(1 + 2j)) # True
print(isFinite(float('inf'))) # False
print(isFinite(float('nan'))) # False
isNumber(obj: complex | float | int) -> bool
Checks if the object is a valid number (integer, float, or complex) and not NaN.
Example:
print(isNumber(5)) # True
print(isNumber(3.14)) # True
print(isNumber(1 + 2j)) # True
print(isNumber(float('inf'))) # True
print(isNumber(float('nan'))) # False
Testing
To run the tests, execute the following command in the project directory:
python -m unittest test_numbers.py
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
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 the_number-0.1.1.tar.gz.
File metadata
- Download URL: the_number-0.1.1.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1be47f614616b18452a7b0173f27955a3e5e25ff860567270e101aedd7961a94
|
|
| MD5 |
d4275f741795a848482e90cdce54d812
|
|
| BLAKE2b-256 |
9616e57cc107ccbef1a837fb7eaf8426aa9f1346dc8e194e81ef57281e91296a
|
File details
Details for the file the_number-0.1.1-py3-none-any.whl.
File metadata
- Download URL: the_number-0.1.1-py3-none-any.whl
- Upload date:
- Size: 2.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28f9feb1230dd2cb8d766e4ac4cb8def0175acb578174612497d78cb60f297aa
|
|
| MD5 |
386605366d627cddf2b6052dcdbccac0
|
|
| BLAKE2b-256 |
56a94b4e04f9f3d02f19c5f5e53c2a17902d0bba004dcd867a1fd4f715dbe9aa
|