symbolite-array: an array extension from symbolite
Symbolite allows you to create symbolic mathematical expressions. Just create a symbol (or more) and operate with them as you will normally do in Python.
This extension allows you to use arrays
>>> from symbolite.abstract import array
>>> arr = array.Array("arr")
>>> expr1 = arr + 1
>>> print(expr1)
(arr + 1)
and you can get one item.
>>> from symbolite.abstract import array
>>> arr = array.Array("arr")
>>> expr2 = arr[1] + 1
>>> print(expr2)
(arr[1] + 1)
You can easily replace the symbols by the desired value.
>>> expr3 = expr2.replace_by_name(arr=(1, 2, 3))
>>> print(expr3)
((1, 2, 3)[1] + 1)
and evaluate:
>>> print(expr3.eval())
3
Included in this library are implementations for sum and prod,
in the default implementation (based on python's math), NumPy, and
SciPy. In SciPy, Array is also mapped to SciPy's IndexedBase.
Vectorizing expresion
If you have an expression with a number of scalars, you can convert it into an expresion using a vector with scalar symbols occuping specific places within the array.
>>> from symbolite.abstract import scalar
>>> x = scalar.Scalar("x")
>>> y = scalar.Scalar("y")
>>> print(array.vectorize(x + scalar.cos(y), ("x", "y")))
(arr[0] + libscalar.cos(arr[1]))
The first argument is the expression and the second list (in order) the scalars to be replaced by the array. You can also use a dictionary mapping scalars names to indices
>>> print(array.vectorize(x + scalar.cos(y), dict(x=3, y=5)))
(arr[3] + libscalar.cos(arr[5]))
If you want to replace all scalars automatically, auto
>>> from symbolite.abstract import scalar
>>> x = scalar.Scalar("x")
>>> y = scalar.Scalar("y")
>>> names, vexpr = array.auto_vectorize(x + scalar.cos(y))
>>> print(names) # names are given in the order of the array.
('x', 'y')
>>> print(vexpr)
(arr[0] + libscalar.cos(arr[1]))
Installing:
pip install -U symbolite-array
Metadata
Release files for symbolite-array 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| symbolite-array-0.1.tar.gz | 9.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| symbolite_array-0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.2 kB
Release files / symbolite-array-0.1.tar.gz
| Download URL | symbolite-array-0.1.tar.gz |
|---|---|
| Size | 9.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1f4741eb98cc6bbf185403c1c690cb6a6999944e81056bac7ab2bef5684e1b0b
|
|
BLAKE2b-256 checksum How to use checksums |
2f1a694c8ad6ce174a56549719a25437592340eb26f285627674e0d6dc1bb841
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.1
|
Release files / symbolite_array-0.1-py3-none-any.whl
| Download URL | symbolite_array-0.1-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4fc79686ab9354ecff0987e488f4fbb33ec30b3fe2abb58eaa18b31683f34d00
|
|
BLAKE2b-256 checksum How to use checksums |
6c768b3d15fc643a079062bcde90224acca755d08607749e31ead622b4d78cc7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.1
|