symbolite-array


Namesymbolite-array JSON
Version 0.1 PyPI version JSON
download
home_page
SummaryA minimalistic symbolic package.
upload_time2022-12-22 13:23:46
maintainer
docs_urlNone
author
requires_python>=3.8
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 No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # symbolite-array: an array extension from symbolite

______________________________________________________________________

[Symbolite](https://github.com/hgrecco/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

```python
>>> from symbolite.abstract import array
>>> arr = array.Array("arr")
>>> expr1 = arr + 1
>>> print(expr1)
(arr + 1)
```

and you can get one item.

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

```python
>>> expr3 = expr2.replace_by_name(arr=(1, 2, 3))
>>> print(expr3)
((1, 2, 3)[1] + 1)
```

and evaluate:

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

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

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

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

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

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "symbolite-array",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "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/2f/1a/694c8ad6ce174a56549719a25437592340eb26f285627674e0d6dc1bb841/symbolite-array-0.1.tar.gz",
    "platform": null,
    "description": "# symbolite-array: an array extension from symbolite\n\n______________________________________________________________________\n\n[Symbolite](https://github.com/hgrecco/symbolite) allows you to\ncreate symbolic mathematical expressions. Just create a symbol\n(or more) and operate with them as you will normally do in Python.\n\nThis extension allows you to use arrays\n\n```python\n>>> from symbolite.abstract import array\n>>> arr = array.Array(\"arr\")\n>>> expr1 = arr + 1\n>>> print(expr1)\n(arr + 1)\n```\n\nand you can get one item.\n\n```python\n>>> from symbolite.abstract import array\n>>> arr = array.Array(\"arr\")\n>>> expr2 = arr[1] + 1\n>>> print(expr2)\n(arr[1] + 1)\n```\n\nYou can easily replace the symbols by the desired value.\n\n```python\n>>> expr3 = expr2.replace_by_name(arr=(1, 2, 3))\n>>> print(expr3)\n((1, 2, 3)[1] + 1)\n```\n\nand evaluate:\n\n```python\n>>> print(expr3.eval())\n3\n```\n\nIncluded in this library are implementations for `sum` and `prod`,\nin the default implementation (based on python's math), NumPy, and\nSciPy. In SciPy, `Array` is also mapped to SciPy's `IndexedBase`.\n\n## Vectorizing expresion\n\nIf you have an expression with a number of scalars, you can convert it\ninto an expresion using a vector with scalar symbols occuping specific\nplaces within the array.\n\n```python\n>>> from symbolite.abstract import scalar\n>>> x = scalar.Scalar(\"x\")\n>>> y = scalar.Scalar(\"y\")\n>>> print(array.vectorize(x + scalar.cos(y), (\"x\", \"y\")))\n(arr[0] + libscalar.cos(arr[1]))\n```\n\nThe first argument is the expression and the second list (in order)\nthe scalars to be replaced by the array. You can also use a dictionary\nmapping scalars names to indices\n\n```python\n>>> print(array.vectorize(x + scalar.cos(y), dict(x=3, y=5)))\n(arr[3] + libscalar.cos(arr[5]))\n```\n\nIf you want to replace all scalars automatically, auto\n\n```python\n>>> from symbolite.abstract import scalar\n>>> x = scalar.Scalar(\"x\")\n>>> y = scalar.Scalar(\"y\")\n>>> names, vexpr = array.auto_vectorize(x + scalar.cos(y))\n>>> print(names) # names are given in the order of the array.\n('x', 'y')\n>>> print(vexpr)\n(arr[0] + libscalar.cos(arr[1]))\n```\n\n### Installing:\n\n```bash\npip install -U symbolite-array\n```\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.1",
    "split_keywords": [
        "symbolic"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "44e6d69781dd81aa5cc75a0ccce7f40a",
                "sha256": "4fc79686ab9354ecff0987e488f4fbb33ec30b3fe2abb58eaa18b31683f34d00"
            },
            "downloads": -1,
            "filename": "symbolite_array-0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "44e6d69781dd81aa5cc75a0ccce7f40a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 7365,
            "upload_time": "2022-12-22T13:23:45",
            "upload_time_iso_8601": "2022-12-22T13:23:45.799279Z",
            "url": "https://files.pythonhosted.org/packages/6c/76/8b3d15fc643a079062bcde90224acca755d08607749e31ead622b4d78cc7/symbolite_array-0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "74cf739a4db2162c416d30dd1b25dbea",
                "sha256": "1f4741eb98cc6bbf185403c1c690cb6a6999944e81056bac7ab2bef5684e1b0b"
            },
            "downloads": -1,
            "filename": "symbolite-array-0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "74cf739a4db2162c416d30dd1b25dbea",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 9865,
            "upload_time": "2022-12-22T13:23:46",
            "upload_time_iso_8601": "2022-12-22T13:23:46.948912Z",
            "url": "https://files.pythonhosted.org/packages/2f/1a/694c8ad6ce174a56549719a25437592340eb26f285627674e0d6dc1bb841/symbolite-array-0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-22 13:23:46",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "symbolite-array"
}
        
Elapsed time: 0.02578s