Metadata-Version: 2.1
Name: symbolipy
Version: 1.0.0
Summary: Present mathematical equality and inequality in symbol format.
Author-email: Pouya Motakef <p.motakef@gmail.com>
Maintainer-email: Pouya Motakef <p.motakef@gmail.com>
License: BSD 2-Clause License
        
        Copyright (c) 2023, Pouya Motakef
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Project-URL: Homepage, https://github.com/pmotakef/symbolipy
Project-URL: Documentation, https://github.com/pmotakef/symbolipy
Project-URL: Repository, https://github.com/pmotakef/symbolipy
Project-URL: Issues, https://github.com/pmotakef/symbolipy/issues
Project-URL: Changelog, https://github.com/pmotakef/symbolipy/blob/main/CHANGELOG.md
Keywords: symbol
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: test
Requires-Dist: pytest ; extra == 'test'

# 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

```commandline
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:

```python
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.

```python
>>> y = x**2 + 4*x + 6
>>> y
Add(((X ** 2) + (4 * X)), 6)
```

Similarly equality or inequality equation can be defined as following:

```python
>>> z = y == x + 1
>>> z
Eq((((X ** 2) + (4 * X)) + 6), (X + 1))
```

The mathematical equation can be displayed by:

```python
>>> str(y)
'(((X ** 2) + (4 * X)) + 6)'
```

the RHS and LHS of any equation can be accessed using `.rhs` and `.lhs`, respectively.

```python
>>> 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).

```python
>>> y.replace({'X': 6})
66
```

