{ "info": { "author": "Michael Amrhein", "author_email": "michael@adrhinum.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", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "The package `ivalutils` provides classes for basic interval arithmetics as\nwell as classes for building sequences of adjacent intervals and for building\nmappings of intervals to arbitrary values.\n\nAn Interval defines a subset of a set of values by optionally giving a lower\nand / or an upper limit.\n\nThe base set of values - and therefore the given limits - must have a\ncommon base type which defines a total order on the values.\n\nCreating intervals\n==================\n\nThe simplest way is calling the class `Interval` without arguments, resulting\nin both endpoints to be infinite:\n\n >>> ival = Interval()\n >>> ival\n Interval()\n >>> str(ival)\n '(-inf .. +inf)'\n\nFor getting a more useful interval, it's neccessary to specify atleast one\nendpoint:\n\n >>> ival = Interval(LowerClosedLimit(0))\n >>> ival\n Interval(lower_limit=Limit(True, 0, True))\n >>> str(ival)\n '[0 .. +inf)'\n\n >>> ival = Interval(upper_limit=UpperClosedLimit(100.))\n >>> ival\n Interval(upper_limit=Limit(False, 100.0, True))\n >>> str(ival)\n '(-inf .. 100.0]'\n\n >>> ival = Interval(LowerClosedLimit(0), UpperOpenLimit(27))\n >>> ival\n Interval(lower_limit=Limit(True, 0, True), upper_limit=Limit(False, 27, False))\n >>> str(ival)\n '[0 .. 27)'\n\nAny type which defines a total ordering can be used for the limits:\n\n >>> ClosedInterval('a', 'zzz')\n Interval(lower_limit=Limit(True, 'a', True), upper_limit=Limit(False, 'zzz', True))\n\nSeveral factory functions can be used as shortcut. For example:\n\n >>> LowerClosedInterval(30)\n Interval(lower_limit=Limit(True, 30, True))\n >>> UpperOpenInterval(0)\n Interval(upper_limit=Limit(False, 0, False))\n >>> ClosedInterval(1, 3)\n Interval(lower_limit=Limit(True, 1, True), upper_limit=Limit(False, 3, True))\n >>> ChainableInterval(0, 5)\n Interval(lower_limit=Limit(True, 0, True), upper_limit=Limit(False, 5, False))\n\nOperations on intervals\n=======================\n\nThe limits of an interval can be retrieved via properties:\n\n >>> ival = ClosedInterval(0, 100)\n >>> ival.lower_limit\n Limit(True, 0, True)\n >>> ival.upper_limit\n Limit(False, 100, True)\n >>> ival.limits\n (Limit(True, 0, True), Limit(False, 100, True))\n\nSeveral methods can be used to test for specifics of an interval. For example:\n\n >>> ival.is_bounded()\n True\n >>> ival.is_finite()\n True\n >>> ival.is_left_open()\n False\n\nIntervals can be tested for including a value:\n\n >>> 74 in ival\n True\n >>> -4 in ival\n False\n\nIntervals can be compared:\n\n >>> ival2 = LowerOpenInterval(100)\n >>> ival3 = LowerClosedInterval(100)\n >>> ival < ival2\n True\n >>> ival < ival3\n True\n >>> ival2 < ival3\n False\n >>> ival2 == ival3\n False\n >>> ival3 < ival2\n True\n >>> ival2.is_adjacent(ival3)\n False\n >>> ival3.is_adjacent(ival2)\n False\n >>> ival4 = UpperClosedInterval(100)\n >>> ival4.is_adjacent(ival2)\n True\n >>> ival.is_overlapping(ival3)\n True\n >>> ival.is_subset(ival4)\n True\n\nCreating sequences of adjacent intervals\n========================================\n\nThe class `IntervalChain` is used to create sequences of adjacent intervals:\n\n >>> ic = IntervalChain(('a', 'd', 'g', 'z'))\n >>> ic\n IntervalChain(('a', 'd', 'g', 'z'))\n\nThe default is to create an interval sequence which is lower-bound and\nupper-infinite and containing lower-closed intervals:\n\n >>> str(ic)\n \"[['a' .. 'd'), ['d' .. 'g'), ['g' .. 'z'), ['z' .. +inf)]\"\n\nBy specifying additional parameters, you can determine which endpoints will be\nclosed and whether a lower and / or upper infinite endpoint will be added:\n\n >>> ic = IntervalChain(('a', 'd', 'g', 'z'), lower_closed = False, add_lower_inf=True, add_upper_inf=False)\n >>> str(ic)\n \"[(-inf .. 'a'], ('a' .. 'd'], ('d' .. 'g'], ('g' .. 'z']]\"\n\nOperations on interval chains\n=============================\n\nInterval chains can be indexed and iterated like lists ...:\n\n >>> ic[2]\n Interval(lower_limit=Limit(True, 'd', False), upper_limit=Limit(False, 'g', True))\n >>> [ival.upper_limit.value for ival in ic]\n ['a', 'd', 'g', 'z']\n\n... and can be searched for the index of the interval holding a specified\nvalue:\n\n >>> ic.map2idx('b')\n 1\n >>> ic.map2idx('a')\n 0\n >>> ic.map2idx('aa')\n 1\n\nCreating interval mappings\n==========================\n\nThe class `IntervalMapping` is used to create a mapping from intervals to\narbitrary values.\n\nInstances can be created by giving an IntervalChain and a sequence of\nassociated values ...:\n\n >>> im1 = IntervalMapping(IntervalChain((0, 300, 500, 1000)), (0., .10, .15, .20))\n\n... or a sequence of limiting values and a sequence of associated values ...:\n\n >>> im2 = IntervalMapping((0, 300, 500, 1000), (0., .10, .15, .20))\n\n... or a sequence of tuples, each holding a limiting value and an associated\nvalue:\n\n >>> im3 = IntervalMapping(((0, 0.), (300, .10), (500, .15), (1000, .20)))\n >>> im1 == im2 == im3\n True\n\nOperations on IntervalMappings\n==============================\n\nInterval mappings behave like ordinary mappings:\n\n >>> list(im3.keys())\n [Interval(lower_limit=Limit(True, 0, True), upper_limit=Limit(False, 300, False)),\n Interval(lower_limit=Limit(True, 300, True), upper_limit=Limit(False, 500, False)),\n Interval(lower_limit=Limit(True, 500, True), upper_limit=Limit(False, 1000, False)),\n Interval(lower_limit=Limit(True, 1000, True))]\n >>> list(im3.values())\n [0.0, 0.1, 0.15, 0.2]\n >>> im3[Interval(lower_limit=Limit(True, 300, True), upper_limit=Limit(False, 500, False))]\n 0.1\n\nIn addition they can be looked-up for the value associated with the interval\nwhich contains a given value:\n\n >>> im3.map(583)\n 0.15\n\nAs a short-cut, the interval mapping can be used like a function:\n\n >>> im3(412)\n 0.1\n\nUse cases for interval mappings are for example:\n\n* determine the discount to be applied depending on an order value,\n* rating customers depending on their sales turnover,\n* classifying cities based on the number of inhabitants,\n* mapping booking dates to accounting periods,\n* grouping of measured values in discrete ranges.\n\nFor more details see the documentation on GitHub or at http://ivalutils.readthedocs.io.\n\nHistory\n=======\n\n=========== ==================================================================\nVersion Changes\n=========== ==================================================================\n0.8.1 Additional tests (enhanced coverage).\n0.8.0 First public release.\n=========== ==================================================================", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/mamrhein/ivalutils", "keywords": "interval", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "ivalutils", "package_url": "https://pypi.org/project/ivalutils/", "platform": "all", "project_url": "https://pypi.org/project/ivalutils/", "project_urls": { "Homepage": "https://github.com/mamrhein/ivalutils" }, "release_url": "https://pypi.org/project/ivalutils/0.8.1/", "requires_dist": null, "requires_python": "", "summary": "Basic interval arithmetic, sequences of intervals and mappings on intervals", "version": "0.8.1" }, "last_serial": 3147753, "releases": { "0.1.0": [], "0.8": [ { "comment_text": "", "digests": { "md5": "6fdcd54eea6887e96f0bc6aa757868c8", "sha256": "4b876d732dabae2c8cc025f03b2211d4687d7db9a8282a0568a9eb5051b8754c" }, "downloads": -1, "filename": "ivalutils-0.8.tar.gz", "has_sig": false, "md5_digest": "6fdcd54eea6887e96f0bc6aa757868c8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 213687, "upload_time": "2017-09-03T13:47:12", "url": "https://files.pythonhosted.org/packages/d5/e8/ea9a2189b4d53d962957df64328a537282c47acc94d9847ad63d91bc9226/ivalutils-0.8.tar.gz" } ], "0.8.1": [ { "comment_text": "", "digests": { "md5": "71b65b788c9c29e317dde9008220cfad", "sha256": "658646ca4f835bd0fd798cc5abf4ef18075fedbd288c53890814554ebffd2938" }, "downloads": -1, "filename": "ivalutils-0.8.1.tar.gz", "has_sig": false, "md5_digest": "71b65b788c9c29e317dde9008220cfad", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 217949, "upload_time": "2017-09-04T14:58:43", "url": "https://files.pythonhosted.org/packages/74/ea/3d3accb6a8346bc9f6a6f4d109650461d15c6e4a10467f8e47c6820aaef2/ivalutils-0.8.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "71b65b788c9c29e317dde9008220cfad", "sha256": "658646ca4f835bd0fd798cc5abf4ef18075fedbd288c53890814554ebffd2938" }, "downloads": -1, "filename": "ivalutils-0.8.1.tar.gz", "has_sig": false, "md5_digest": "71b65b788c9c29e317dde9008220cfad", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 217949, "upload_time": "2017-09-04T14:58:43", "url": "https://files.pythonhosted.org/packages/74/ea/3d3accb6a8346bc9f6a6f4d109650461d15c6e4a10467f8e47c6820aaef2/ivalutils-0.8.1.tar.gz" } ] }