More Math! Many of the aggregates you are familiar with, but null-safe
Project description
More Math!
Basic math functions that have been stabilized to act well over Null
/None
/NaN
Branch | Status |
---|---|
master | |
dev |
Overview
Many of the basic math functions you know and love, with the additional benefit
that they do not throw exceptions and do not return NaN
.
These functions are all module methods. Be sure you call the functions
with mo_math.
prefix, like
import mo_math
mo_math.abs(-42)
or rename the functions
from mo_math import abs as mo_abs
mo_abs(-42)
This prevents confusion with the __builtin__
functions by the same name
Functions
Functions are generally conservative in the face of nulls: Specifically, they return Null
if any of their operands are not a number.
Most functions need no introduction, but some are interesting:
round(value, decimal=7, digits=None)
- Rounds to 7 decimal points, unless specified differently. Rounding todecimal=0
will return anint
. The useful parameter here isdigits
, which rounds to a specified number of significant digits.floor(value, mod=1)
- Themod
ulo parameter is used to specify the granularity of the floor function.ceiling(value, mod=1)
- Return the smallest value, that's equal or larger thanvalue
, with suitable granularity.mod(value, mod=1)
- Works on floatsapprox_str(value)
- Round values, and returntext
(unicode
in py2,str
in py3)sign(v)
- Missing from the Python library
The all-caps aggregate functions accept only one parameter; an iterable. They are decisive operators: Non-numbers are ignored, if no values are numbers then the aggregate will return Null
.
COUNT(values)
SUM(values)
PRODUCT(values)
MIN(values)
MAX(values)
Crypto
The AES and RSA crypto functions provide structured input/output on top of cryptography
library. The intent is to reveal the signed/encrypted structures so third parties can decode the data.
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
File details
Details for the file mo_math-7.647.24166.tar.gz
.
File metadata
- Download URL: mo_math-7.647.24166.tar.gz
- Upload date:
- Size: 48.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f76ebd057ef719809f75a4b6fa4ba8f8bee5ddc934d89f9d219ae4339e20ec0 |
|
MD5 | b3ee742c118d624437bf0971759b206d |
|
BLAKE2b-256 | 5772ebab7ba3ef61e73bc060571166599141514c922c38376c2ddc90c0bf572d |
File details
Details for the file mo_math-7.647.24166-py3-none-any.whl
.
File metadata
- Download URL: mo_math-7.647.24166-py3-none-any.whl
- Upload date:
- Size: 55.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1723beab00dfdf34744216b6cea80c7ac2332ce88450c467baa6c9cfbdfebd12 |
|
MD5 | 68fb6ab8e30f842a66960c82ec0ff185 |
|
BLAKE2b-256 | a278dda6370b79bf359c1fc810ff73ef5ac2433953f1384d9e2489ce9aaed04f |