Skip to main content

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


Download files

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

Source Distribution

symbolipy-1.0.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

symbolipy-1.0.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file symbolipy-1.0.0.tar.gz.

File metadata

  • Download URL: symbolipy-1.0.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.2

File hashes

Hashes for symbolipy-1.0.0.tar.gz
Algorithm Hash digest
SHA256 51b2588db26534aa39b8d57506634e68f943fcb40890462699998a112f375094
MD5 cb9df1a488e66147e74b02a289f720c0
BLAKE2b-256 6f57a838b4e94051c8967c6fd0996fca47a8a6eaabd0398c031889ccc704c01d

See more details on using hashes here.

File details

Details for the file symbolipy-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: symbolipy-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.2

File hashes

Hashes for symbolipy-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7e0aa3e552222ec56f4c4d31a564fd4ebb7dcb7fc322cfc16d7f6c1b9aff9bbc
MD5 d503e4faefd20ecf2bf6a551a1aea908
BLAKE2b-256 120c64fd1262931c8aef2fea2f21ae6febcf2d36fd8bd02e5844e923bae411ce

See more details on using hashes here.

Supported by

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