symbolite


Namesymbolite JSON
Version 0.6.0 PyPI version JSON
download
home_page
SummaryA minimalistic symbolic package.
upload_time2024-01-19 11:22:47
maintainer
docs_urlNone
author
requires_python>=3.10
licenseMIT License Copyright (c) 2022 Hernán E. Grecco Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords symbolic
VCS
bugtrack_url
requirements typing_extensions
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![Package](https://img.shields.io/pypi/v/symbolite?label=symbolite)
![CodeStyle](https://img.shields.io/badge/code%20style-black-000000.svg)
![License](https://img.shields.io/pypi/l/symbolite?label=license)
![PyVersion](https://img.shields.io/pypi/pyversions/symbolite?label=python)
[![CI](https://github.com/hgrecco/symbolite/actions/workflows/ci.yml/badge.svg)](https://github.com/hgrecco/symbolite/actions/workflows/ci.yml)
[![Lint](https://github.com/hgrecco/symbolite/actions/workflows/lint.yml/badge.svg)](https://github.com/hgrecco/symbolite/actions/workflows/lint.yml)

# symbolite: a minimalistic symbolic python package

______________________________________________________________________

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.

```python
>>> from symbolite import Symbol
>>> x = Symbol("x")
>>> y = Symbol("y")
>>> expr1 = x + 3 * y
>>> print(expr1)
x + 3 * y
```

An expression is just an unnamed Symbol.
You can easily replace the symbols by the desired value.

```python
>>> expr2 = expr1.subs_by_name(x=5, y=2)
>>> print(expr2)
5 + 3 * 2
```

The output is still a symbolic expression, which you can evaluate:

```python
>>> expr2.eval()
11
```

Notice that we also got a warning (`No libsl provided, defaulting to Python standard library.`).
This is because evaluating an expression requires a actual library implementation,
name usually as `libsl`. The default one just uses python's math module.

You can avoid this warning by explicitely providing an `libsl` implementation.

```python
>>> from symbolite.impl import libstd
>>> expr2.eval(libstd)
11
```

You can also import it with the right name and it will be found

```python
>>> from symbolite.impl import libstd as libsl
>>> expr2.eval()
11
```

In addition to the `Symbol` class, there is also a `Scalar` and `Vector` classes
to represent integer, floats or complex numbers, and an array of those.

```python
>>> from symbolite import Scalar, Vector
>>> x = Scalar("x")
>>> y = Scalar("y")
>>> v = Vector("v")
>>> expr1 = x + 3 * y
>>> print(expr1)
x + 3 * y
>>> print(2 * v)
2 * v
```

Mathematical functions that operate on scalars are available in the `scalar` module.

```python
>>> from symbolite import scalar
>>> expr3 = 3. * scalar.cos(0.5)
>>> print(expr3)
3.0 * scalar.cos(0.5)
```

Mathematical functions that operate on vectors are available in the `vector` module.

```python
>>> from symbolite import vector
>>> expr4 = 3. * vector.sum((1, 2, 3))
>>> print(expr4)
3.0 * vector.sum((1, 2, 3))
```

Notice that functions are named according to the python math module.
Again, this is a symbolic expression until evaluated.

```python
>>> expr3.eval()
2.6327476856711
>>> expr4.eval()
18.0
```

Three other implementations are provided:
[NumPy](https://numpy.org/),
[SymPy](https://www.sympy.org),
[JAX](https://jax.readthedocs.io).

```python
>>> from symbolite.impl import libnumpy
>>> expr3.eval(libsl=libnumpy)
2.6327476856711
>>> from symbolite.impl import libsympy
>>> expr3.eval(libsl=libsympy)
2.6327476856711
```

(notice that the way that the different libraries round and
display may vary)

In general, all symbols must be replaced by values in order
to evaluate an expression. However, when using an implementation
like SymPy that contains a Scalar object you can still evaluate.

```python
>>> from symbolite.impl import libsympy as libsl
>>> (3. * scalar.cos(x).eval(libsl))
3.0*cos(x)
```

which is actually a SymPy expression with a SymPy symbol (`x`).

And by the way, checkout `vectorize` and `auto_vectorize` functions
in the vector module.

### Installing:

```bash
pip install -U symbolite
```

### FAQ

**Q: Is symbolite a replacement for SymPy?**

**A:** No

**Q: Does it aim to be a replacement for SymPy in the future?**

**A:** No

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "symbolite",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "symbolic",
    "author": "",
    "author_email": "\"Hern\u00e1n E. Grecco\" <hernan.grecco@gmail.com>, Mauro Silberberg <maurosilber@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/18/5e/acfdbb0f16a5276f9463803c34f558a0d4586b300a08e3cdc3a1da3be469/symbolite-0.6.0.tar.gz",
    "platform": null,
    "description": "![Package](https://img.shields.io/pypi/v/symbolite?label=symbolite)\n![CodeStyle](https://img.shields.io/badge/code%20style-black-000000.svg)\n![License](https://img.shields.io/pypi/l/symbolite?label=license)\n![PyVersion](https://img.shields.io/pypi/pyversions/symbolite?label=python)\n[![CI](https://github.com/hgrecco/symbolite/actions/workflows/ci.yml/badge.svg)](https://github.com/hgrecco/symbolite/actions/workflows/ci.yml)\n[![Lint](https://github.com/hgrecco/symbolite/actions/workflows/lint.yml/badge.svg)](https://github.com/hgrecco/symbolite/actions/workflows/lint.yml)\n\n# symbolite: a minimalistic symbolic python package\n\n______________________________________________________________________\n\nSymbolite allows you to create symbolic mathematical\nexpressions. Just create a symbol (or more) and operate with them as you\nwill normally do in Python.\n\n```python\n>>> from symbolite import Symbol\n>>> x = Symbol(\"x\")\n>>> y = Symbol(\"y\")\n>>> expr1 = x + 3 * y\n>>> print(expr1)\nx + 3 * y\n```\n\nAn expression is just an unnamed Symbol.\nYou can easily replace the symbols by the desired value.\n\n```python\n>>> expr2 = expr1.subs_by_name(x=5, y=2)\n>>> print(expr2)\n5 + 3 * 2\n```\n\nThe output is still a symbolic expression, which you can evaluate:\n\n```python\n>>> expr2.eval()\n11\n```\n\nNotice that we also got a warning (`No libsl provided, defaulting to Python standard library.`).\nThis is because evaluating an expression requires a actual library implementation,\nname usually as `libsl`. The default one just uses python's math module.\n\nYou can avoid this warning by explicitely providing an `libsl` implementation.\n\n```python\n>>> from symbolite.impl import libstd\n>>> expr2.eval(libstd)\n11\n```\n\nYou can also import it with the right name and it will be found\n\n```python\n>>> from symbolite.impl import libstd as libsl\n>>> expr2.eval()\n11\n```\n\nIn addition to the `Symbol` class, there is also a `Scalar` and `Vector` classes\nto represent integer, floats or complex numbers, and an array of those.\n\n```python\n>>> from symbolite import Scalar, Vector\n>>> x = Scalar(\"x\")\n>>> y = Scalar(\"y\")\n>>> v = Vector(\"v\")\n>>> expr1 = x + 3 * y\n>>> print(expr1)\nx + 3 * y\n>>> print(2 * v)\n2 * v\n```\n\nMathematical functions that operate on scalars are available in the `scalar` module.\n\n```python\n>>> from symbolite import scalar\n>>> expr3 = 3. * scalar.cos(0.5)\n>>> print(expr3)\n3.0 * scalar.cos(0.5)\n```\n\nMathematical functions that operate on vectors are available in the `vector` module.\n\n```python\n>>> from symbolite import vector\n>>> expr4 = 3. * vector.sum((1, 2, 3))\n>>> print(expr4)\n3.0 * vector.sum((1, 2, 3))\n```\n\nNotice that functions are named according to the python math module.\nAgain, this is a symbolic expression until evaluated.\n\n```python\n>>> expr3.eval()\n2.6327476856711\n>>> expr4.eval()\n18.0\n```\n\nThree other implementations are provided:\n[NumPy](https://numpy.org/),\n[SymPy](https://www.sympy.org),\n[JAX](https://jax.readthedocs.io).\n\n```python\n>>> from symbolite.impl import libnumpy\n>>> expr3.eval(libsl=libnumpy)\n2.6327476856711\n>>> from symbolite.impl import libsympy\n>>> expr3.eval(libsl=libsympy)\n2.6327476856711\n```\n\n(notice that the way that the different libraries round and\ndisplay may vary)\n\nIn general, all symbols must be replaced by values in order\nto evaluate an expression. However, when using an implementation\nlike SymPy that contains a Scalar object you can still evaluate.\n\n```python\n>>> from symbolite.impl import libsympy as libsl\n>>> (3. * scalar.cos(x).eval(libsl))\n3.0*cos(x)\n```\n\nwhich is actually a SymPy expression with a SymPy symbol (`x`).\n\nAnd by the way, checkout `vectorize` and `auto_vectorize` functions\nin the vector module.\n\n### Installing:\n\n```bash\npip install -U symbolite\n```\n\n### FAQ\n\n**Q: Is symbolite a replacement for SymPy?**\n\n**A:** No\n\n**Q: Does it aim to be a replacement for SymPy in the future?**\n\n**A:** No\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2022 Hern\u00e1n E. Grecco  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "A minimalistic symbolic package.",
    "version": "0.6.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/hgrecco/symbolite/issues",
        "Homepage": "https://github.com/hgrecco/symbolite"
    },
    "split_keywords": [
        "symbolic"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "df5576130f1711c3b0de951b2e916456cd02977aa3e2f2df30f6f2878489b257",
                "md5": "81f94b91b30212acad0ba3a9b96ecece",
                "sha256": "460aff143f2bee33a6785628460113cb11f8ebf1fb565a0a141ded0c196a09ca"
            },
            "downloads": -1,
            "filename": "symbolite-0.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "81f94b91b30212acad0ba3a9b96ecece",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 32173,
            "upload_time": "2024-01-19T11:22:46",
            "upload_time_iso_8601": "2024-01-19T11:22:46.286961Z",
            "url": "https://files.pythonhosted.org/packages/df/55/76130f1711c3b0de951b2e916456cd02977aa3e2f2df30f6f2878489b257/symbolite-0.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "185eacfdbb0f16a5276f9463803c34f558a0d4586b300a08e3cdc3a1da3be469",
                "md5": "ac20d1349568fd901ebe3f25dc5bb297",
                "sha256": "40fac5e23e7021ffb2d571e334e65c9a6cb9dbfd17af0408fb884007cce837a1"
            },
            "downloads": -1,
            "filename": "symbolite-0.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ac20d1349568fd901ebe3f25dc5bb297",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 24895,
            "upload_time": "2024-01-19T11:22:47",
            "upload_time_iso_8601": "2024-01-19T11:22:47.966944Z",
            "url": "https://files.pythonhosted.org/packages/18/5e/acfdbb0f16a5276f9463803c34f558a0d4586b300a08e3cdc3a1da3be469/symbolite-0.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-19 11:22:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hgrecco",
    "github_project": "symbolite",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "typing_extensions",
            "specs": []
        }
    ],
    "lcname": "symbolite"
}
        
Elapsed time: 0.17583s