{ "info": { "author": "", "author_email": "", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "Natural Language :: English", "Operating System :: Microsoft :: Windows", "Operating System :: Microsoft :: Windows :: Windows 7", "Operating System :: POSIX", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 3 :: Only", "Topic :: Utilities" ], "description": "Cyclic-Sequences\n################\n\nSequence type objects with cyclic indexing::\n\nDescription\n===========\n\nThe cyclic indexation works as for usual sequences, with the possible use \nof negative indexes. But it makes a jump-back to the beginning (or the end for \nnegative indexes) if the index is higher than the length of the sequence::\n\n \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n \u2502 \u25bc\n \u250f\u2501\u2502\u2501\u2533\u2501\u2501\u2501\u2533\u2501\u2501\u2501\u2533\u2501\u254d\u2505 \u2505\u254d\u2501\u2533\u2501\u2501\u2501\u2501\u2501\u2533\u2501\u2501\u2501\u2533\u2501\u2501\u2501\u2513\n \u2503 \u25cf \u2503 0 \u2503 1 \u2503 \u22c5\u22c5\u22c5 \u2503 N-1 \u2503 N \u2503 \u25cf \u2503\n \u2517\u2501\u2501\u2501\u253b\u2501\u2501\u2501\u253b\u2501\u2501\u2501\u253b\u2501\u254d\u2505 \u2505\u254d\u2501\u253b\u2501\u2501\u2501\u2501\u2501\u253b\u2501\u2501\u2501\u253b\u2501\u2502\u2501\u251b\n \u25b2 \u2502\n \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n\nIterating over a cyclic sequence is bounded (no infinite loop).\n\n\n.. note:: This module is based on a Chris Lawlor forum publication.\n\n\nContent\n=======\n\n:CyclicTuple:\n Class object.\n An immutable cyclic sequence based on built-in class *tuple*.\n\n:CyclicList:\n Class object.\n A mutable cyclic sequence based on built-in class *list*.\n\n:CyclicStr:\n Class object.\n An immutable cyclic sequence based on built-in class *str*.\n\n\nImmutable class methods\n-----------------------\n\n:with_first:\n foo.with_first(elt) -> new instance\n New instance of 'foo' with first occurence of 'elt' at first position.\n Raises ValueError if 'elt' is not present.\n\n:turned:\n foo.turned(step) -> new instance\n New instance of 'foo' with all elements shifted of given step.\n (default is 1 unit onward).\n\n\nMutable class methods\n---------------------\n\n:set_first:\n foo.set_first(elt) -> None\n Set first occurence of 'elt' at first position.\n Raises ValueError if 'elt' is not present.\n\n:turn:\n foo.turn(step) -> None\n Change all elements indexes of given step (default is 1 unit onward)\n Equivalent to set at first position the element at index 'step'.\n\n\nExamples\n========\n\nThe following examples are using CyclicList class for demonstration. CyclicTuple and CyclicStr classes get similar behaviours.\n\n- Construction from any iterable::\n\n >>> foo = CyclicList(['a', 'b', 'c', 'd', 'e'])\n >>> foo\n CyclicList(['a', 'b', 'c', 'd', 'e'])\n\n- Gets its specific string representation with chevrons figuring cycling::\n\n >>> print(foo)\n <['a', 'b', 'c', 'd', 'e']>\n\n- Accessing works like a regular list::\n\n >>> foo[1]\n 'b'\n >>> foo[-4]\n 'b'\n\n- Except indexes higher than length wraps around::\n\n >>> foo[6]\n 'b'\n >>> foo[11]\n 'b'\n >>> foo[-9]\n 'b'\n\n- Slices work and return list objects::\n\n >>> foo[1:4]\n ['b', 'c', 'd']\n >>> foo[3:0:-1]\n ['d', 'c', 'b']\n\n- Slices work also out of range with cyclic output::\n\n >>> foo[3:7]\n ['d', 'e', 'a', 'b']\n >>> foo[8:12]\n ['d', 'e', 'a', 'b']\n >>> foo[3:12]\n ['d', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b']\n >>> foo[-2:2]\n ['d', 'e', 'a', 'b']\n >>> foo[-7:-3]\n ['d', 'e', 'a', 'b']\n >>> foo[-7:2]\n ['d', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b']\n\n- Slices with non unitary steps work also::\n\n >>> foo[:7:2]\n ['a', 'c', 'e', 'b']\n >>> foo[:7:3]\n ['a', 'd', 'b']\n >>> foo[:7:5]\n ['a', 'a']\n\n- As well for reversed steps::\n\n >>> foo[1:-3:-1]\n ['b', 'a', 'e', 'd']\n >>> foo[-4:-8:-1]\n ['b', 'a', 'e', 'd']\n >>> foo[-4:-9:-2]\n ['b', 'e', 'c']\n >>> foo[-4:-9:-3]\n ['b', 'd']\n >>> foo[-5:-11:-5]\n ['a', 'a']\n\n- Incoherent slices return empty list::\n\n >>> foo[11:5]\n []\n\nEdge effects:\n\n- Indexing an empty CyclicList returns an IndexError.\n\n- Indexing on a unique element returns always this element.\n\n\nFirst element can be played with using specific methods:\n\n- **with_first**: return a new CyclicList with given element at first\n position::\n\n >>> foo.with_first('c')\n CyclicList(['c', 'd', 'e', 'a', 'b'])\n\n- **turned**: return a new CyclicList with all elements indexes changed\n of given step (default is 1 unit onward)::\n\n >>> foo.turned()\n CyclicList(['b', 'c', 'd', 'e', 'a'])\n >>> foo.turned(-3)\n CyclicList(['c', 'd', 'e', 'a', 'b'])\n >>> foo.turned(10)\n CyclicList(['a', 'b', 'c', 'd', 'e'])\n\n- **set_first**: put given element at first position::\n\n >>> foo.set_first('c')\n >>> foo\n CyclicList(['c', 'd', 'e', 'a', 'b'])\n\n- **turn**: change all elements index of given step\n (default is 1 unit onward)::\n\n >>> foo.turn()\n >>> foo\n CyclicList(['d', 'e', 'a', 'b', 'c'])\n >>> foo.turn(-3)\n >>> foo\n CyclicList(['a', 'b', 'c', 'd', 'e'])\n >>> foo.turn(11)\n >>> foo\n CyclicList(['b', 'c', 'd', 'e', 'a'])\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/bclmary/cyclic_sequences.git", "keywords": "cyclic sequence tuple list", "license": "GPL-3.0+", "maintainer": "BCL Mary", "maintainer_email": "bclmary@mailoo.org", "name": "cyclic-sequences", "package_url": "https://pypi.org/project/cyclic-sequences/", "platform": "any", "project_url": "https://pypi.org/project/cyclic-sequences/", "project_urls": { "Homepage": "https://github.com/bclmary/cyclic_sequences.git" }, "release_url": "https://pypi.org/project/cyclic-sequences/1.1.2/", "requires_dist": null, "requires_python": ">=3.4", "summary": "A collection of cyclic sequence objects.", "version": "1.1.2" }, "last_serial": 4274757, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "e1b0cfe2deea92f36306ef906fd56862", "sha256": "8619a4f096aeb8defab7549fee40a78c8fcfe19308e71a675ac4e6c13e46fb91" }, "downloads": -1, "filename": "cyclic_sequences-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "e1b0cfe2deea92f36306ef906fd56862", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.4", "size": 9933, "upload_time": "2018-03-09T10:45:31", "url": "https://files.pythonhosted.org/packages/5e/af/d3f071c76595486ec2e59d6177f23119471fff7cd4056be6dbe7fc7eeb64/cyclic_sequences-1.0.0-py3-none-any.whl" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "98200a71cfa2ce683a2f6c7e90eb2c7a", "sha256": "fad18c8da8ad67c39e5a42bdb1aa49f4f80993e74f3fb81b2738257ee6c6c1ec" }, "downloads": -1, "filename": "cyclic_sequences-1.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "98200a71cfa2ce683a2f6c7e90eb2c7a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.4", "size": 8234, "upload_time": "2018-09-07T16:37:18", "url": "https://files.pythonhosted.org/packages/f9/c8/66f60e37e3a0a31b2e3a6e7c9fe113f852dde2df4244dbc9affc0df32466/cyclic_sequences-1.1.0-py3-none-any.whl" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "a34a05c7e512b475498dbef5fd40b9d0", "sha256": "4cc1956b015d0a8e2b48f6c8a84a5eb711246ff6374e05f1511f3bbd70bf333e" }, "downloads": -1, "filename": "cyclic_sequences-1.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "a34a05c7e512b475498dbef5fd40b9d0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.4", "size": 8859, "upload_time": "2018-09-14T13:35:26", "url": "https://files.pythonhosted.org/packages/82/20/1f9dce861ff5690ed193187b699fd58ee82d386ccacd93e0ef5222cf2717/cyclic_sequences-1.1.1-py3-none-any.whl" } ], "1.1.2": [ { "comment_text": "", "digests": { "md5": "127d6a3b69038a23d1170d6424352e03", "sha256": "1e0aa2103d49c27c8e9f98b76bfee84de9a340e45af2643e07ca7552e8052ecd" }, "downloads": -1, "filename": "cyclic_sequences-1.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "127d6a3b69038a23d1170d6424352e03", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.4", "size": 8865, "upload_time": "2018-09-15T10:44:58", "url": "https://files.pythonhosted.org/packages/bf/d5/a8384de1ee2b69dc2270ec0a4509213fd4384e14eaf6b53ed6f3478422a4/cyclic_sequences-1.1.2-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "127d6a3b69038a23d1170d6424352e03", "sha256": "1e0aa2103d49c27c8e9f98b76bfee84de9a340e45af2643e07ca7552e8052ecd" }, "downloads": -1, "filename": "cyclic_sequences-1.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "127d6a3b69038a23d1170d6424352e03", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.4", "size": 8865, "upload_time": "2018-09-15T10:44:58", "url": "https://files.pythonhosted.org/packages/bf/d5/a8384de1ee2b69dc2270ec0a4509213fd4384e14eaf6b53ed6f3478422a4/cyclic_sequences-1.1.2-py3-none-any.whl" } ] }