Skip to main content

Fast numerical expression evaluator for NumPy

Project description

Author:

Alexander K.

URL:

https://github.com/MrCheatak/numexpr_mod

What is NumExpr?

Please refer to the original Numexpr repo.

Installation

From wheels

NumExpr is available for install via pip for a wide range of platforms and Python versions (which may be browsed at: https://pypi.org/project/numexpr/#files). Installation can be performed as:

pip install numexpr_mod

From Source

On most *nix systems your compilers will already be present. However if you are using a virtual environment with a substantially newer version of Python than your system Python you may be prompted to install a new version of gcc or clang.

For Windows, you will need to install the Microsoft Visual C++ Build Tools (which are free) first. The version depends on which version of Python you have installed:

https://wiki.python.org/moin/WindowsCompilers

For Python 3.6+ simply installing the latest version of MSVC build tools should be sufficient. Note that wheels found via pip do not include MKL support. Wheels available via conda will have MKL, if the MKL backend is used for NumPy.

See requirements.txt for the required version of NumPy.

NumExpr is built in the standard Python way:

python setup.py build install

You can test numexpr_mod with:

python -c "import numexpr_mod; numexpr_mod.test()"

Do not test NumExpr in the source directory or you will generate import errors.

Usage

This modification of the Numexpr package enables storage of the previously compiled expressions. Stored expressions can be then called by their assigned name.

Note that precompiled expressions accept only the same variable names with the same types. Although, both arrays and single values can be used for the same expression variable.

Output destination, order and casting can be preset at compilation time or be specified at expression call.

>>> import numexpr_mod as ne
>>> import numpy as np

>>> a = np.array([1,2,3,4,5])
>>> b = np.array([6,7,8,9,0])

>>> ne.cache_expression('a + b', 'sum_ab')
{'ex': <numexpr_mod.NumExpr object at 0x1090e36b0>, 'argnames': ['a', 'b'], 'kwargs': {'out': None, 'order': 'K', 'casting': 'safe', 'ex_uses_vml': False}}
>>> ne.re_evaluate('sum_ab')
array([ 7,  9, 11, 13,  5], dtype=int64)
>>> ne.evaluate('a + b')
array([ 7,  9, 11, 13,  5], dtype=int64)

Additionally, cached expresion names can be retrieved:

>>>ne.get_expression_names()
['sum_ab']

License

NumExpr is distributed under the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

numexpr_mod-2.8.6.tar.gz (85.5 kB view hashes)

Uploaded Source

Built Distributions

numexpr_mod-2.8.6-cp311-cp311-win_amd64.whl (91.1 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

numexpr_mod-2.8.6-cp311-cp311-win32.whl (98.1 kB view hashes)

Uploaded CPython 3.11 Windows x86

numexpr_mod-2.8.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (381.9 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

numexpr_mod-2.8.6-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (413.7 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

numexpr_mod-2.8.6-cp311-cp311-macosx_11_0_arm64.whl (87.6 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

numexpr_mod-2.8.6-cp311-cp311-macosx_10_9_x86_64.whl (98.4 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

numexpr_mod-2.8.6-cp310-cp310-win_amd64.whl (91.2 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

numexpr_mod-2.8.6-cp310-cp310-win32.whl (98.1 kB view hashes)

Uploaded CPython 3.10 Windows x86

numexpr_mod-2.8.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (379.6 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

numexpr_mod-2.8.6-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (411.0 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

numexpr_mod-2.8.6-cp310-cp310-macosx_11_0_arm64.whl (87.6 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

numexpr_mod-2.8.6-cp310-cp310-macosx_10_9_x86_64.whl (98.3 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

numexpr_mod-2.8.6-cp39-cp39-win_amd64.whl (91.1 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

numexpr_mod-2.8.6-cp39-cp39-win32.whl (98.1 kB view hashes)

Uploaded CPython 3.9 Windows x86

numexpr_mod-2.8.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (379.1 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

numexpr_mod-2.8.6-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (410.0 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

numexpr_mod-2.8.6-cp39-cp39-macosx_11_0_arm64.whl (87.6 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

numexpr_mod-2.8.6-cp39-cp39-macosx_10_9_x86_64.whl (98.3 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

numexpr_mod-2.8.6-cp38-cp38-win_amd64.whl (91.1 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

numexpr_mod-2.8.6-cp38-cp38-win32.whl (98.1 kB view hashes)

Uploaded CPython 3.8 Windows x86

numexpr_mod-2.8.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (380.1 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

numexpr_mod-2.8.6-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (411.4 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

numexpr_mod-2.8.6-cp38-cp38-macosx_11_0_arm64.whl (87.6 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

numexpr_mod-2.8.6-cp38-cp38-macosx_10_9_x86_64.whl (98.3 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

numexpr_mod-2.8.6-cp37-cp37m-win_amd64.whl (91.1 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

numexpr_mod-2.8.6-cp37-cp37m-win32.whl (98.0 kB view hashes)

Uploaded CPython 3.7m Windows x86

numexpr_mod-2.8.6-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (377.9 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

numexpr_mod-2.8.6-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (409.0 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

numexpr_mod-2.8.6-cp37-cp37m-macosx_10_9_x86_64.whl (101.3 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page