{ "info": { "author": "Peter Roger", "author_email": "", "bugtrack_url": null, "classifiers": [], "description": "*****\npyrel\n*****\n\nPyrel is an efficient python library for working with and manipulating `binary relations`_. Pyrel exposes the C library `Kure`_ which provides a very fast implementation of binary relations based on `Binary Decision Diagrams`_.\n\nThe following operations of relation algebra are provided:\n\n* empty\n* universal\n* identity\n* meet (intersection)\n* join (union)\n* transpose (converse)\n* complement (negation)\n* compose (multiplication)\n* equals\n* isSuperset\n* isSubset\n* isStrictSuperset\n* isStrictSubset\n\nInstallation\n============\nusing pip:\n\n.. code-block:: bash\n\n pip3 install pyrel\n\nor downloading with git:\n\n.. code-block:: bash\n\n git clone https://github.com/Peter-Roger/pyrel.git\n cd pyrel/\n python3 setup.py build install\n\nRequirements\n------------\n\nPyrel works on Ubuntu and macOS. It has not been tested on other systems\nbut it is possible it could work, perhaps with some modification.\n\nC Library Dependencies:\n\n* glib-2.0\n* gmp\n\nIf you are missing these libraries just install them with your package manager.\n\nPyrel includes a modified version of Kure and its dependency Cudd-2.5.1\n(Colorado University Decision Diagram) as source. As long as the aforementioned dependencies are installed in standard locations on your system, Kure will be\nbuilt automatically during installation.\n\n\nQuick Start\n===========\n\nThe following provides some examples as a tutorial on how to use pyrel.\nFor a complete description you should consult the documented module `source code`_.\n\nRelations are represented as boolean matrices and can be visualised by printing them. An 'X' at *col x* and *row y* denotes that *x* is related to *y* in the relation. Contrariwise a '.' denotes that *x* is not related to *y*.\n\n\nCreating relations\n------------------\n.. code-block:: python\n\n import pyrel\n\n # create a pyrel context\n context = pyrel.PyrelContext()\n\n # create a new 3x3 empty relation\n rel = context.new(3,3)\n print(rel)\n\n.. code-block:: bash\n\n ...\n ...\n ...\n\nSetting bits\n------------\n.. code-block:: python\n\n # a list of ordered pairs\n bits = [(0,0),(0,1),(0,2)]\n rel = context.new(3,3)\n rel.set_bits(bits)\n print(rel)\n\n # set bits at random\n rel.random()\n print(rel)\n\n # unsets all bits\n rel.clear()\n print(rel)\n\n.. code-block:: bash\n\n XXX\n ...\n ...\n\n .X.\n ..X\n X.X\n\n ...\n ...\n ...\n\n.. code-block:: python\n\n # set bits at creation\n bits = [(0,0),(0,1),(0,2)]\n rel = context.new(3,3,bits)\n print(rel)\n\n # set single bit\n rel.set_bit(2,2)\n print(rel)\n\n # unset bit\n rel.set_bit(0,1,yesno=False)\n print(rel)\n\n # unset bits\n rel.set_bits([(0,0),(2,2)],yesno=False)\n print(rel)\n\n.. code-block:: bash\n\n XXX\n ...\n ...\n\n XXX\n ...\n ..X\n\n X.X\n ...\n ..X\n\n ..X\n ...\n ...\n\nOperations\n----------\n.. code-block:: python\n\n rel = context.new(3,3).identity()\n print(rel)\n\n r = context.new(3,3, [(0,0),(0,1),(0,2)])\n print(r)\n\n s = r.transpose()\n print(s)\n\n m = r1.meet(r2)\n print(m)\n\n j = r1.join(r2)\n print(j)\n\n.. code-block:: bash\n\n X..\n .X.\n ..X\n\n XXX\n ...\n ...\n\n X..\n X..\n X..\n\n X..\n ...\n ...\n\n XXX\n X..\n X..\n\n.. code-block:: python\n\n r = context.new(3,3, [(0,1),(0,2),(2,1)])\n print(r)\n\n s = context.new(3,3, [(1,1),(2,2)])\n print(s)\n\n g = r.composition(s)\n print(g)\n\n g.isSubset(g.universal())\n\n.. code-block:: bash\n\n .XX\n ...\n .X.\n\n ...\n .X.\n ..X\n\n .XX\n ...\n .X.\n\n >>> True\n\nVectors\n-------\n\nA vector is a row constant relation. All columns are identical. It represents a subset.\n\n.. code-block:: python\n\n rel = new(5,5)\n rel.vector(2) # row 2 (0-indexed)\n print(rel)\n rel.vector_next()\n print(rel)\n\n.. code-block:: bash\n\n .....\n .....\n XXXXX\n .....\n .....\n\n .....\n .....\n .....\n XXXXX\n .....\n\n\nPossible Future Work\n--------------------\n\n* import relations from a file\n* export relations to a file\n* extend support for more relation operations\n\n\n.. _binary relations: https://en.wikipedia.org/wiki/Binary_relation\n.. _Kure: https://www.informatik.uni-kiel.de/~progsys/kure2/\n.. _Binary Decision Diagrams: https://en.wikipedia.org/wiki/Binary_decision_diagram\n.. _source code: https://github.com/Peter-Roger/pyrel/blob/master/pyrel/pyrel.py", "description_content_type": "text/x-rst", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Peter-Roger/pyrel", "keywords": "", "license": "GPLv3", "maintainer": "", "maintainer_email": "", "name": "pyrel", "package_url": "https://pypi.org/project/pyrel/", "platform": "darwin", "project_url": "https://pypi.org/project/pyrel/", "project_urls": { "Homepage": "https://github.com/Peter-Roger/pyrel" }, "release_url": "https://pypi.org/project/pyrel/0.2.0/", "requires_dist": null, "requires_python": "", "summary": "An efficient python library for working with and manipulating binary relations.", "version": "0.2.0" }, "last_serial": 5127561, "releases": { "0.1.4": [ { "comment_text": "", "digests": { "md5": "12a06ca0f01e6d1a58cca29d51ee9405", "sha256": "c1285d122b761f91e11db8dbbb94893d04fc597b92c622045c83046eaa380b7d" }, "downloads": -1, "filename": "pyrel-0.1.4.tar.gz", "has_sig": false, "md5_digest": "12a06ca0f01e6d1a58cca29d51ee9405", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2860512, "upload_time": "2019-03-26T23:35:19", "url": "https://files.pythonhosted.org/packages/5a/0f/1f94fb8657a01450a9aa07e65fe23a53357bab5c67f8da0a947977e614ca/pyrel-0.1.4.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "676e19172c0ee8cb1872b06b82ebdcd6", "sha256": "0619806cfdaa5dec6de36dfd21ba6aeecd95ed07616449da1a70b8c7798dc3f3" }, "downloads": -1, "filename": "pyrel-0.2.0.tar.gz", "has_sig": false, "md5_digest": "676e19172c0ee8cb1872b06b82ebdcd6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2861244, "upload_time": "2019-04-11T07:39:33", "url": "https://files.pythonhosted.org/packages/d4/a1/6ad8134086b376c40ea3ec590cfdda2754bfa73a0d706c7e569251719505/pyrel-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "676e19172c0ee8cb1872b06b82ebdcd6", "sha256": "0619806cfdaa5dec6de36dfd21ba6aeecd95ed07616449da1a70b8c7798dc3f3" }, "downloads": -1, "filename": "pyrel-0.2.0.tar.gz", "has_sig": false, "md5_digest": "676e19172c0ee8cb1872b06b82ebdcd6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2861244, "upload_time": "2019-04-11T07:39:33", "url": "https://files.pythonhosted.org/packages/d4/a1/6ad8134086b376c40ea3ec590cfdda2754bfa73a0d706c7e569251719505/pyrel-0.2.0.tar.gz" } ] }