Skip to main content

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 Build Status
dev Build Status

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 to decimal=0 will return an int. The useful parameter here is digits, which rounds to a specified number of significant digits.
  • floor(value, mod=1) - The modulo parameter is used to specify the granularity of the floor function.
  • ceiling(value, mod=1) - Return the smallest value, that's equal or larger than value, with suitable granularity.
  • mod(value, mod=1) - Works on floats
  • approx_str(value) - Round values, and return text (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

mo_math-7.685.25166.tar.gz (49.5 kB view details)

Uploaded Source

Built Distribution

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

mo_math-7.685.25166-py3-none-any.whl (55.9 kB view details)

Uploaded Python 3

File details

Details for the file mo_math-7.685.25166.tar.gz.

File metadata

  • Download URL: mo_math-7.685.25166.tar.gz
  • Upload date:
  • Size: 49.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for mo_math-7.685.25166.tar.gz
Algorithm Hash digest
SHA256 9c4d5d20959a59eb81d17c7f5b46f62334b6c005b8bb91f6a13c8d987cf16837
MD5 90c1b83928337c84d6c8338528e82dbe
BLAKE2b-256 43a39cf07fe47dd36c02d8040ce8dc63c27bc31f2fc4dd17a6238dde703203ec

See more details on using hashes here.

File details

Details for the file mo_math-7.685.25166-py3-none-any.whl.

File metadata

  • Download URL: mo_math-7.685.25166-py3-none-any.whl
  • Upload date:
  • Size: 55.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for mo_math-7.685.25166-py3-none-any.whl
Algorithm Hash digest
SHA256 ab9abdcaa94ec280d032fcb83715a956a4ebc088953d2478038753ddfe13b0d3
MD5 b1b581c6d8591eb77366befe6f3289e0
BLAKE2b-256 edac1b4243e5f5686f96539611f3fd4a63dbbe67918cd4660c5571e801b7bb02

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