Present mathematical equality and inequality in symbol format.
Project description
Symbolipy
Symbolipy is a lightweight package to present mathematical equations, equality, and inequality in symbol format.
This package does not contain algebraic operations, but can be used with packages that support symbols.
The idea behind this package is to prevent default python equality operation on Operation
object. Unlike other Symbol packages, ==
will yield to equality equation.
Version History
0.1.0
- Initial release
Installation
The latest Symoblipy release is hosted on PyPI. The package can be installed using pip
command
pip install symbolipy
Python Version
Symbolipy will work on python version >= 3.8. No earlier version is officially supported.
Starting with Symbolipy
A symbol can be defined by following:
from symbolipy import Symbol
x = Symbol('X')
An equation is a combination of symbols, operands, and objects (including numbers). An equation can be formed by simply typing a mathematical equation.
>>> y = x**2 + 4*x + 6
>>> y
Add(((X ** 2) + (4 * X)), 6)
Similarly equality or inequality equation can be defined as following:
>>> z = y == x + 1
>>> z
Eq((((X ** 2) + (4 * X)) + 6), (X + 1))
The mathematical equation can be displayed by:
>>> str(y)
'(((X ** 2) + (4 * X)) + 6)'
the RHS and LHS of any equation can be accessed using .rhs
and .lhs
, respectively.
>>> y.rhs
6
>>> y.lhs
Add((X ** 2), (4 * X))
>>> y.lhs.lhs
Pow(X, 2)
>>> y.lhs.rhs
Mul(4, X)
>>> y.lhs.rhs.rhs
Symbol(X)
Symbols can be replaced by values using the .replace(values: dict[symbol_name, value])
.
Note: to replace a symbol with a value, the symbol name (string) should be given. This does not work with Symbol object (i.e., {x: 6}
does not work).
>>> y.replace({'X': 6})
66
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for symbolipy-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e0aa3e552222ec56f4c4d31a564fd4ebb7dcb7fc322cfc16d7f6c1b9aff9bbc |
|
MD5 | d503e4faefd20ecf2bf6a551a1aea908 |
|
BLAKE2b-256 | 120c64fd1262931c8aef2fea2f21ae6febcf2d36fd8bd02e5844e923bae411ce |