Table of contents
Description
NUMAGR is a Python C extension offering efficient statistical methods for numerical data.
It's faster compared to standard and to other third party modules (use test.py for benchmarking).
It's also different in that it accepts and converts Python's numeric strings "on the fly" (using C strtod function), without having to initialize intermediate Python objects to hold the values.
For sumations the module implements Kahan algorithm to retain precission.
Usage
Inside iterables, all strings that cannot be evaluated to a number count as 0's, and all Python objects that do not evaluate to a number are ignored.
Examples:
numagr.sum([1,2,3,4,5,6,7,8,9]) # 45
numagr.sum([1,2,"3",4,"5",6,"7",8,9]) # 45
numagr.sum([None,1,"abc",2,"3",[],4,"5",6,"7",8,print,9]) # 45
numagr.amean([1,2,3,4]) # 2.5
numagr.amean([1,2,3,4, "abc", None]) # 2.0 ( "abc" became 0, None was ignored )
numagr.stdev([9,8.001,7,6.11,5]) # 1.564579560137483
numagr.stdev([9,[],8.001,"7","6.11",None,5]) # 1.564579560137483
numagr.stdev([9,"abc",[],8.001,"7","6.11",None,5]) # 3.190121653897648 ("abc" became 0)
Setting only_str to True will cause all non-strings in iterables to be ignored.
Setting only_num to True will cause all strings in iterables to be ignored.
numagr.count(5, [1,2,5,"5","5","5",6,7], only_str = True) # 3
numagr.count(5, [1,2,5,"5","5","5",6,7], only_num = True) # 1
The kwargs are mutually exclusive, they cannot be both True at the same time.
random_floats = [random.random() for _ in range(1_000_000)]
numagr.stdev(random_floats, only_str = True, only_num = True) # TypeError
# TypeError: Keyword arguments "str_only" and "num_only" are mutually exclusive.
API
sum
numagr.sum(*iterables, only_str = False, only_num = False)
Calculates the sum.
Return:
floatsum
Exceptions:
- built-in Python exceptions
max
numagr.max(*iterables, only_str = False, only_num = False)
Returns the largest value.
Return:
floatmax valuefloat-inf(if it's the largest value, if element count is zero, or if all elements arenan's)
Exceptions:
- built-in Python exceptions
min
numagr.min(*iterables, only_str = False, only_num = False)
Returns the smallest value.
Return:
floatmax valuefloatinf(if it's the smallest value, if element count is zero, or if all elements arenan's)
Exceptions:
- built-in Python exceptions
amean
numagr.amean(*iterables, only_str = False, only_num = False)
Calculates arithmetic mean.
Return:
floatarithmetic meanfloatnan (element count is0)
Exceptions:
numagr.CountOverflow(element count exceeds unsigned 64-bit integer capacity)- built-in Python exceptions
gmean
numagr.gmean(*iterables, only_str = False, only_num = False)
Calculates geometric mean.
Return:
floatgeometric meanfloatnan (element count is0)
Exceptions:
numagr.InvalidStringValue(one of the iterables contain a string that cannot be evaluated to a value greater than0)numagr.NegativeValue(the iterable contains a negative value)numagr.CountOverflow(element count exceeds unsigned 64-bit integer capacity)- built-in Python exceptions
hmean
numagr.hmean(*iterables, only_str = False, only_num = False)
Calculates harmonic mean.
Return:
floatharmonic meanfloatnan (element count is0)
Exceptions:
numagr.NegativeValue(one of the iterables contains a negative value)numagr.ZeroValue(one of the iterables contains a0)numagr.CountOverflow(element count exceeds unsigned 64-bit integer capacity)- built-in Python exceptions
nearest
numagr.nearest(target_value, *iterables, only_str = False, only_num = False)
Finds the value closest to a specified target value. The target value must be a finite number (int or float), passing inf or nan will raise TypeError.
Return:
floatnearest valuefloatinf(no finite values in the iterables)
Exceptions:
- built-in Python exceptions
count
numagr.count(target_value, *iterables, only_str = False, only_num = False)
Returns the number of occurences of a specified target value. The target value must be a finite number (int or float), passing inf or nan will raise TypeError.
Return:
intnumber of occurences
Exceptions:
numagr.CountOverflow(occurences count exceeds unsigned 64-bit integer capacity)- built-in Python exceptions
frac_below
numagr.frac_below(target_value, *iterables, only_str = False, only_num = False)
Returns fraction of values that are below a specified target value. The target value must be a finite number (int or float), passing inf or nan will raise TypeError.
Return:
floatfraction of values below the target value
Exceptions:
numagr.CountOverflow(element count exceeds unsigned 64-bit integer capacity)- built-in Python exceptions
frac_above
numagr.frac_above(target_value, *iterables, only_str = False, only_num = False)
Returns fraction of values that are above a specified target value. The target value must be a finite number (int or float), passing inf or nan will raise TypeError.
Return:
floatfraction of values above the target value
Exceptions:
numagr.CountOverflow(element count exceeds unsigned 64-bit integer capacity)- built-in Python exceptions
mode
numagr.mode(*iterables, only_str = False, only_num = False)
Calculates the mode. Ignores any nan's in the data. If the element count is 0, the function returns nan.
numagr.mode uses custom hash table internally (see the implementation src/methods/mode.c, src/floats_hash_table.h, src/floats_hash_table.c). If there is more than one most common value, it is not guaranteed to return the first one in order.
Return:
floatmode
Exceptions:
- built-in Python exceptions
var
numagr.var(*iterables, only_str = False, only_num = False)
Calculates the variance. If there are any inf's or nan's in the data, or if the element count is 0 or 1, the function returns nan.
Return:
floatvariance
Exceptions:
- built-in Python exceptions
pvar
numagr.pvar(*iterables, only_str = False, only_num = False)
Calculates the population variance. If there are any inf's or nan's in the data, or if the element count is 0, the function returns nan.
Return:
floatpopulation variance
Exceptions:
- built-in Python exceptions
stdev
numagr.stdev(*iterables, only_str = False, only_num = False)
Calculates standard deviation. If there are any inf's or nan's in the data, or if the element count is 0 or 1, the function returns nan.
Return:
floatstandard deviation
Exceptions:
- built-in Python exceptions
pstdev
numagr.pstdev(*iterables, only_str = False, only_num = False)
Calculates population standard deviation. If there are any inf's or nan's in the data, or if the element count is 0, the function returns nan.
Return:
floatpopulation standard deviation
Exceptions:
- built-in Python exceptions
Metadata
Release files for numagr 0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| numagr-0.9.tar.gz | 17.4 kB | Without provenance | Details for numagr-0.9.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| numagr-0.9-cp315-cp315-win_amd64.whl | CPython 3.15 | CPython 3.15 | Windows x86-64 | Details for numagr-0.9-cp315-cp315-win_amd64.whl |
| numagr-0.9-cp314-cp314-win_amd64.whl | CPython 3.14 | CPython 3.14 | Windows x86-64 | Details for numagr-0.9-cp314-cp314-win_amd64.whl |
| numagr-0.9-cp313-cp313-win_amd64.whl | CPython 3.13 | CPython 3.13 | Windows x86-64 | Details for numagr-0.9-cp313-cp313-win_amd64.whl |
| numagr-0.9-cp312-cp312-win_amd64.whl | CPython 3.12 | CPython 3.12 | Windows x86-64 | Details for numagr-0.9-cp312-cp312-win_amd64.whl |
| numagr-0.9-cp311-cp311-win_amd64.whl | CPython 3.11 | CPython 3.11 | Windows x86-64 | Details for numagr-0.9-cp311-cp311-win_amd64.whl |
Total release size: 165.7 kB
Release files / numagr-0.9.tar.gz
| Download URL | numagr-0.9.tar.gz |
|---|---|
| Size | 17.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4fde334ae76993b869fa688863ed7024b93e188f8d7fab6c594a6c243e59dab9
|
|
BLAKE2b-256 checksum How to use checksums |
1650b577eae66a9e63b78c32e66c4d94a3d530efcff12fa8d51109c6caba54f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Release files / numagr-0.9-cp315-cp315-win_amd64.whl
| Download URL | numagr-0.9-cp315-cp315-win_amd64.whl |
|---|---|
| Size | 30.4 kB |
| Tags | CPython 3.15 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
f569b8a4af04729b445149f4c5aa938898de3e928b0cfbf4399c18d4c7324ecc
|
|
BLAKE2b-256 checksum How to use checksums |
96a52ab05c325ec55a9b84e3b04ceeaf60d07f27e35a206b05152176c001bf36
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Release files / numagr-0.9-cp314-cp314-win_amd64.whl
| Download URL | numagr-0.9-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 30.4 kB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b14f198feac611856833895b197cd6a8bc6031b3e2fa7ca14e9e79cc4c9e548f
|
|
BLAKE2b-256 checksum How to use checksums |
5934b2c6f7770fa8e4a81337d8bfaf14e52a736e6ce45d9d9d9e6b5f1c9557e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Release files / numagr-0.9-cp313-cp313-win_amd64.whl
| Download URL | numagr-0.9-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 29.7 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
c001fd1720d7889229047706bf36ae49a3b82cde6e84ddfd64d413baf089aa6c
|
|
BLAKE2b-256 checksum How to use checksums |
a9421bf3e9a2c557f5eaac28d3c3748d2e91b229c944f6789bb8d63e3ec0ae6e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Release files / numagr-0.9-cp312-cp312-win_amd64.whl
| Download URL | numagr-0.9-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 29.7 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
f62a539b208f4d304b942f59e70cc1d22af54e18ebda33f5addd5a6cb1f1358b
|
|
BLAKE2b-256 checksum How to use checksums |
6542be9dc18974b990d9865dc945cbd74873e4f75f9adcbed1a9caad808eefe8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Release files / numagr-0.9-cp311-cp311-win_amd64.whl
| Download URL | numagr-0.9-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 28.2 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
74f47e5c52bbd5b2d4066e6ee3a9a9141f7de2078916bdda046b617ba7ab21c1
|
|
BLAKE2b-256 checksum How to use checksums |
25c0970c470a36d5704b9d19027c0bde8e261be8d96ab291b09b85dd73583a81
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Security for numagr 0.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.