Skip to main content

MaExPa (__Ma__thematical __Ex__pression __Pa__rser) is library providing a simple algebraic expression analyser, with callbacks for variable replacement and function calls, and support for implicit support of NumPy arrays.

Aims

The goal of this library is to provide an easy way to do custom calculations on an existing dataset. If a dataset provides several fields, this library allows the end user to combine and transform fields to suit their whishes. Fields are exposed as variables in the expression, and are retrived by means of a callback function where the user-provided expression requests a mathematical variable.

Usage

MaExPa provides on main class, maexpa.Expression that compiles and executes user-provided mathematical expressions. A very simple use is this:

import maexpa

expr = maexpa.Expression( "3*5" )
print( expr() )

A more complicated use case with a replacement for variables is:

import numpy
import maexpa

expr = maexpa.Expression( "item/total*100." )

def vars_callback( name ):
	if name == "item":
		return numpy.asarray( [ 1., 2., 3. ] )

	if name == "total":
		return numpy.asarray( [ 10., 10., 10. ] )

	raise Exception( "Unknown variable {:s}".format( name ) )

print( expr( var = vars_callback ) )

which will show [10. 20. 30.].

License

The library is licensed under version 2.0 of the Apache License, see the LICENSE file for the full terms and conditions.

Metadata

Release files for maexpa 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for maexpa 0.1
File Size Uploaded
maexpa-0.1.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for maexpa 0.1
File Interpreter ABI Platform
maexpa-0.1-py3-none-any.whl Python 3 none any Details

Total release size: 15.4 kB

Release files / maexpa-0.1.tar.gz

Download URL maexpa-0.1.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d24015df21f33f84493bc7ed2f9cf2a126095d10cf0f7d3e730b3d2b70f46311
BLAKE2b-256 checksum
How to use checksums
dd1290e1003b5ae0589b00d154361589e4714dceb349bd23b5ba4bb204cc0201
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

Release files / maexpa-0.1-py3-none-any.whl

Download URL maexpa-0.1-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1525231fd982725ac85f99480bc306d5ac78db4c7385c97dca24cb1884c86cce
BLAKE2b-256 checksum
How to use checksums
c97294a9ca78b4e652ab8710a5d574a4a04b954d61823602fda21385e599af8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page