{ "info": { "author": "Dieter Maurer", "author_email": "dieter@handshake.de", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Software Development", "Topic :: Utilities" ], "description": "dm.iter\n=======\n\nA small collection of iterator utilities.\n\nCurrently, there is a single utility family related to relations.\n\n\nRelation utilities\n------------------\n\nThese utilies are implemented in ``dm.iter.relation``.\n\nThe relation is represented by a map from an element to an\niterator of its directly related elements.\nThe map is either an object with ``__getitem__`` method,\na callable raising ``ValueError`` for undefined\ninput arguments or an object supporting subscription.\nElements must be allowed as set elements.\n\nAvailable utilies are ``depth_first_search`` and ``breath_first_search``.\nThey take as arguments a relation and an element iterator ''roots''\nand generate the relation's transitive closure for ''roots''\nin depth first or breath first order, respectively.\n\nLets look at a trivial example. Our relation has the integers between\n0 and 11 as domain and maps an element to three times this element.\n\n>>> def relation(x):\n... if not (isinstance(x, int) and 0 <= x < 11): raise ValueError\n... return (3 * x,)\n...\n>>> from dm.iter.relation import depth_first_search, breadth_first_search\n>>> tuple(depth_first_search(relation, ()))\n()\n>>> tuple(breadth_first_search(relation, ()))\n()\n>>> tuple(depth_first_search(relation, (1, 2, 3)))\n(1, 3, 9, 27, 2, 6, 18)\n>>> tuple(breadth_first_search(relation, (1, 2, 3)))\n(1, 2, 3, 6, 9, 18, 27)\n>>> dfs = depth_first_search(relation, (1, 2, 3))\n>>> dfs.next()\n1\n>>> dfs.next()\n3\n\nWe now let our relation map ``x`` to ``(2*x, 3*x)``.\n\n>>> def relation(x):\n... if not (isinstance(x, int) and 0 <= x < 11): raise ValueError\n... return (2 * x, 3 * x)\n...\n>>> tuple(depth_first_search(relation, (1,)))\n(1, 2, 4, 8, 16, 24, 12, 6, 18, 3, 9, 27)\n>>> tuple(breadth_first_search(relation, (1,)))\n(1, 2, 3, 4, 6, 9, 8, 12, 18, 27, 16, 24)\n\nThe relation can also be specified by a dictionary.\n\n>>> relation = dict((i, (2*i, 3*i)) for i in range(11))\n>>> tuple(depth_first_search(relation, (1,)))\n(1, 2, 4, 8, 16, 24, 12, 6, 18, 3, 9, 27)\n>>> tuple(breadth_first_search(relation, (1,)))\n(1, 2, 3, 4, 6, 9, 8, 12, 18, 27, 16, 24)\n\nOr an object with ``__getitem__`` method:\n\n>>> from UserDict import UserDict\n>>> relation = UserDict(relation)\n>>> tuple(depth_first_search(relation, (1,)))\n(1, 2, 4, 8, 16, 24, 12, 6, 18, 3, 9, 27)\n>>> tuple(breadth_first_search(relation, (1,)))\n(1, 2, 3, 4, 6, 9, 8, 12, 18, 27, 16, 24)", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pypi.python.org/pypi/dm.iter", "keywords": "iter closure", "license": "BSD (see \"dm/iter/LICENSE.txt\", for details)", "maintainer": null, "maintainer_email": null, "name": "dm.iter", "package_url": "https://pypi.org/project/dm.iter/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/dm.iter/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://pypi.python.org/pypi/dm.iter" }, "release_url": "https://pypi.org/project/dm.iter/1.0/", "requires_dist": null, "requires_python": null, "summary": "Some iterator utilities", "version": "1.0" }, "last_serial": 791251, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "432d59acda7abd4a5a020c0efad8752c", "sha256": "477a91c39c88862e9e28173ef262dc4588c2742fb335f71da1a8d748a88f6f3a" }, "downloads": -1, "filename": "dm.iter-1.0.tar.gz", "has_sig": false, "md5_digest": "432d59acda7abd4a5a020c0efad8752c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3691, "upload_time": "2010-02-04T08:05:10", "url": "https://files.pythonhosted.org/packages/d0/bb/76d3c8737de516f3a908c4aa0f1023e579a91198ae5cdad5f3155c531f5d/dm.iter-1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "432d59acda7abd4a5a020c0efad8752c", "sha256": "477a91c39c88862e9e28173ef262dc4588c2742fb335f71da1a8d748a88f6f3a" }, "downloads": -1, "filename": "dm.iter-1.0.tar.gz", "has_sig": false, "md5_digest": "432d59acda7abd4a5a020c0efad8752c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3691, "upload_time": "2010-02-04T08:05:10", "url": "https://files.pythonhosted.org/packages/d0/bb/76d3c8737de516f3a908c4aa0f1023e579a91198ae5cdad5f3155c531f5d/dm.iter-1.0.tar.gz" } ] }