# More Math!
Basic math functions that have been stabilized to act well over `Null`/`None`/`NaN`
|Branch |Status |
|------------|---------|
|master | [![Build Status](https://github.com/klahnakoski/mo-math/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/klahnakoski/mo-math/actions/workflows/build.yml) |
|dev | [![Build Status](https://app.travis-ci.com/klahnakoski/mo-math.svg?branch=dev)](https://travis-ci.com/github/klahnakoski/mo-math) |
## 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](https://github.com/mozilla/ActiveData/blob/dev/docs/jx_decisive_operators.md#definitions) 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 `mod`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 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](https://github.com/mozilla/ActiveData/blob/dev/docs/jx_decisive_operators.md#definitions) 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.
Raw data
{
"_id": null,
"home_page": "https://github.com/klahnakoski/mo-math",
"name": "mo-math",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Kyle Lahnakoski",
"author_email": "kyle@lahnakoski.com",
"download_url": "https://files.pythonhosted.org/packages/c3/06/63cba2a3e186d31ffbdec20ef9ec947a6e0e242a1820d0b9f5b5a38f6263/mo_math-7.632.24139.tar.gz",
"platform": null,
"description": "\r\n# More Math! \r\n\r\nBasic math functions that have been stabilized to act well over `Null`/`None`/`NaN`\r\n\r\n\r\n|Branch |Status |\r\n|------------|---------|\r\n|master | [![Build Status](https://github.com/klahnakoski/mo-math/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/klahnakoski/mo-math/actions/workflows/build.yml) |\r\n|dev | [![Build Status](https://app.travis-ci.com/klahnakoski/mo-math.svg?branch=dev)](https://travis-ci.com/github/klahnakoski/mo-math) |\r\n\r\n\r\n\r\n## Overview\r\n\r\nMany of the basic math functions you know and love, with the additional benefit \r\nthat they do not throw exceptions and do not return `NaN`. \r\n\r\nThese functions are all module methods. Be sure you call the functions \r\nwith `mo_math.` prefix, like \r\n\r\n import mo_math\r\n\tmo_math.abs(-42)\r\n\r\nor rename the functions\r\n\r\n from mo_math import abs as mo_abs\r\n mo_abs(-42)\r\n\r\nThis prevents confusion with the `__builtin__` functions by the same name \r\n\r\n\r\n## Functions\r\n\r\nFunctions are generally [conservative](https://github.com/mozilla/ActiveData/blob/dev/docs/jx_decisive_operators.md#definitions) in the face of nulls: Specifically, they return `Null` if any of their operands are not a number.\r\n\r\nMost functions need no introduction, but some are interesting:\r\n\r\n- `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.\r\n- `floor(value, mod=1)` - The `mod`ulo parameter is used to specify the granularity of the floor function.\r\n- `ceiling(value, mod=1)` - Return the smallest value, that's equal or larger than `value`, with suitable granularity.\r\n- `mod(value, mod=1)` - Works on floats\r\n- `approx_str(value)` - Round values, and return `text` (`unicode` in py2, `str` in py3) \r\n- `sign(v)` - Missing from the Python library \r\n\r\n\r\nThe all-caps aggregate functions accept only one parameter; an iterable. They are [decisive](https://github.com/mozilla/ActiveData/blob/dev/docs/jx_decisive_operators.md#definitions) operators: Non-numbers are ignored, if no values are numbers then the aggregate will return `Null`.\r\n\r\n- `COUNT(values)`\r\n- `SUM(values)` \r\n- `PRODUCT(values)` \r\n- `MIN(values)` \r\n- `MAX(values)` \r\n\r\n## Crypto\r\n\r\nThe 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.\r\n",
"bugtrack_url": null,
"license": "MPL 2.0",
"summary": "More Math! Many of the aggregates you are familiar with, but null-safe",
"version": "7.632.24139",
"project_urls": {
"Homepage": "https://github.com/klahnakoski/mo-math"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1fc8f94191be99124874cdafe1de7f11c95d59dab2ea05c370e85b187a914eb8",
"md5": "ee91b761d4e52ef9fc1fb99e0e203aa4",
"sha256": "74b4edc3e67173d51a70f2a9432cff27d198a3eb511f0a98549a1cef35626ead"
},
"downloads": -1,
"filename": "mo_math-7.632.24139-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ee91b761d4e52ef9fc1fb99e0e203aa4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 55153,
"upload_time": "2024-05-18T03:33:56",
"upload_time_iso_8601": "2024-05-18T03:33:56.562615Z",
"url": "https://files.pythonhosted.org/packages/1f/c8/f94191be99124874cdafe1de7f11c95d59dab2ea05c370e85b187a914eb8/mo_math-7.632.24139-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c30663cba2a3e186d31ffbdec20ef9ec947a6e0e242a1820d0b9f5b5a38f6263",
"md5": "26032bbb3d1f645608ec63bfd3b74956",
"sha256": "f30312d0c96c6dd5c9eab50e7082eb4a3ab5b82d1d5b2f34a64207d38950f75a"
},
"downloads": -1,
"filename": "mo_math-7.632.24139.tar.gz",
"has_sig": false,
"md5_digest": "26032bbb3d1f645608ec63bfd3b74956",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 48256,
"upload_time": "2024-05-18T03:33:58",
"upload_time_iso_8601": "2024-05-18T03:33:58.920930Z",
"url": "https://files.pythonhosted.org/packages/c3/06/63cba2a3e186d31ffbdec20ef9ec947a6e0e242a1820d0b9f5b5a38f6263/mo_math-7.632.24139.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-18 03:33:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "klahnakoski",
"github_project": "mo-math",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "mo-math"
}