Name | extents JSON |
Version |
0.2.2
JSON |
| download |
home_page | None |
Summary | An intervals library implemented in pure python, meant to be a drop-in replacment for the pyinterval library. |
upload_time | 2024-07-06 19:05:33 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.7 |
license | MIT License Copyright (c) 2023 Michael Frank / SWAPP 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 |
interval
intervals
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Extents - An Intervals Library in Pure Python
`extents` is an intervals library implemented in pure python.
It draws its inspiration from the [`PyInterval`](https://pyinterval.readthedocs.io/en/latest/)
library ([github](https://github.com/taschini/pyinterval)).
This library is capable of representing open, closed and semi-open/closed intervals.
It also supports set operations on intervals (i.e., union, intersection and complement).
## Examples:
### Basic use cases:
Basic use of this library includes creating simple intervals, and manipulating them
through set operations
```python
from extents import interval # the interval class represents a collection of intervals
ival1 = interval([0, 1]) # the singleton interval set containing the closed interval [0, 1]
print(ival1) # Interval([0, 1])
print(~ival1) # Interval((-inf, 0), (1, inf)) -- the interval set of (-inf, 0) and (1, inf) --
# which compose the complement of [0, 1]
ival2 = interval((4, 5)) # the singleton interval set containing the open interval (4, 5)
print(ival2) # Interval((4, 5))
print(~ival2) # Interval((-inf, 4], [5, inf)) -- the interval set of (-inf, 4] and [5, inf) --
# which are the complement of (4, 5)]
ival3 = interval([0, 1], [5, 6]) # the interval set [0, 1] and [5, 6]
ival4 = interval([0, 3], [4, 5.5]) # the interval set [0, 3] and [4, 5.5]
print(ival3 | ival4) # the interval set [0, 3] and [4, 6], which is the union of ival3 and ival4
print(ival3 & ival4) # the interval set [0, 1] and [5, 5.5], which is the intersection of ival3 and ival4
ival5 = interval([0, 1], [0.5, 3]) # intervals are automatically union-ed during construction.
print(ival5) # resulting in the interval [0, 3]
```
The output of the commands above would be:
```
Interval([0, 1])
Interval((-inf, 0), (1, inf))
Interval((4, 5))
Interval((-inf, 4], [5, inf))
Interval([0, 3], [4, 6])
Interval([0, 1], [5, 5.5])
Interval([0, 3])
```
### Advanced use cases:
In order to construct a semi-open interval, you can import the `Component` and `ComponentType`,
and construct the internal interval components.
For example,
```python
from extents import interval, Component, ComponentType
ival = interval(Component(0, 1, ComponentType.HALF_CLOSED_LEFT),
Component(5, 6, ComponentType.HALF_CLOSED_RIGHT)
)
print(ival) # construct the interval set: [0, 1), (5, 6]
```
### Additional Examples:
See the `tests/extents_test.py` file.
## Installation:
From `github`:
```shell
$ pip install git+https://github.com/swapp-ai/extents
```
From source:
```shell
$ git clone https://github.com/swapp-ai/extents
$ cd extents
$ pip install .
```
Raw data
{
"_id": null,
"home_page": null,
"name": "extents",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "Michael Frank <michaelfrank@swapp.ai>",
"keywords": "interval, intervals",
"author": null,
"author_email": "Michael Frank <michaelfrank@swapp.ai>",
"download_url": "https://files.pythonhosted.org/packages/c0/2c/c86c7a2c407e19100aa7a9bf714a567476f17158ba5955306c23aaa1beb0/extents-0.2.2.tar.gz",
"platform": null,
"description": "# Extents - An Intervals Library in Pure Python\n\n`extents` is an intervals library implemented in pure python. \nIt draws its inspiration from the [`PyInterval`](https://pyinterval.readthedocs.io/en/latest/) \nlibrary ([github](https://github.com/taschini/pyinterval)).\n\nThis library is capable of representing open, closed and semi-open/closed intervals.\nIt also supports set operations on intervals (i.e., union, intersection and complement).\n\n\n## Examples:\n\n### Basic use cases:\n\nBasic use of this library includes creating simple intervals, and manipulating them \nthrough set operations\n\n\n```python\nfrom extents import interval # the interval class represents a collection of intervals\n\nival1 = interval([0, 1]) # the singleton interval set containing the closed interval [0, 1]\nprint(ival1) # Interval([0, 1])\nprint(~ival1) # Interval((-inf, 0), (1, inf)) -- the interval set of (-inf, 0) and (1, inf) -- \n # which compose the complement of [0, 1]\n\nival2 = interval((4, 5)) # the singleton interval set containing the open interval (4, 5)\nprint(ival2) # Interval((4, 5))\nprint(~ival2) # Interval((-inf, 4], [5, inf)) -- the interval set of (-inf, 4] and [5, inf) --\n # which are the complement of (4, 5)]\n\nival3 = interval([0, 1], [5, 6]) # the interval set [0, 1] and [5, 6]\nival4 = interval([0, 3], [4, 5.5]) # the interval set [0, 3] and [4, 5.5]\nprint(ival3 | ival4) # the interval set [0, 3] and [4, 6], which is the union of ival3 and ival4\nprint(ival3 & ival4) # the interval set [0, 1] and [5, 5.5], which is the intersection of ival3 and ival4\n\nival5 = interval([0, 1], [0.5, 3]) # intervals are automatically union-ed during construction.\nprint(ival5) # resulting in the interval [0, 3]\n```\n\nThe output of the commands above would be:\n\n```\nInterval([0, 1])\nInterval((-inf, 0), (1, inf))\nInterval((4, 5))\nInterval((-inf, 4], [5, inf))\nInterval([0, 3], [4, 6])\nInterval([0, 1], [5, 5.5])\nInterval([0, 3])\n```\n\n### Advanced use cases:\n\nIn order to construct a semi-open interval, you can import the `Component` and `ComponentType`,\nand construct the internal interval components.\n\nFor example,\n```python\nfrom extents import interval, Component, ComponentType\n\nival = interval(Component(0, 1, ComponentType.HALF_CLOSED_LEFT),\n Component(5, 6, ComponentType.HALF_CLOSED_RIGHT)\n )\nprint(ival) # construct the interval set: [0, 1), (5, 6]\n```\n\n### Additional Examples:\n\nSee the `tests/extents_test.py` file. \n\n## Installation:\n\nFrom `github`:\n```shell\n$ pip install git+https://github.com/swapp-ai/extents\n```\n\nFrom source:\n```shell\n$ git clone https://github.com/swapp-ai/extents\n$ cd extents\n$ pip install .\n```\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2023 Michael Frank / SWAPP 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": "An intervals library implemented in pure python, meant to be a drop-in replacment for the pyinterval library.",
"version": "0.2.2",
"project_urls": {
"Documentation": "https://github.com/swapp-ai/extents/blob/main/README.md",
"Homepage": "https://github.com/swapp-ai/extents",
"Issues": "https://github.com/swapp-ai/extents/issues",
"Repository": "https://github.com/swapp-ai/extents.git"
},
"split_keywords": [
"interval",
" intervals"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8fdbfcdc64c988b86e6c25b3d6e94455f7a5e00c113692ae3233f382017e11a2",
"md5": "921de66c74d78d3d181b97af6f235b81",
"sha256": "acd987b1d8a49dcc43b34d420055ace9d46fc7f1c6786dda58d183e724d8bf8c"
},
"downloads": -1,
"filename": "extents-0.2.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "921de66c74d78d3d181b97af6f235b81",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 7833,
"upload_time": "2024-07-06T19:05:30",
"upload_time_iso_8601": "2024-07-06T19:05:30.104593Z",
"url": "https://files.pythonhosted.org/packages/8f/db/fcdc64c988b86e6c25b3d6e94455f7a5e00c113692ae3233f382017e11a2/extents-0.2.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c02cc86c7a2c407e19100aa7a9bf714a567476f17158ba5955306c23aaa1beb0",
"md5": "5f1011234a104e8891f7e6ad91feed0e",
"sha256": "34f494fe8815bda4a017b880998f08600366ad47c9406d46269c195c15f6441b"
},
"downloads": -1,
"filename": "extents-0.2.2.tar.gz",
"has_sig": false,
"md5_digest": "5f1011234a104e8891f7e6ad91feed0e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 13515,
"upload_time": "2024-07-06T19:05:33",
"upload_time_iso_8601": "2024-07-06T19:05:33.830000Z",
"url": "https://files.pythonhosted.org/packages/c0/2c/c86c7a2c407e19100aa7a9bf714a567476f17158ba5955306c23aaa1beb0/extents-0.2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-06 19:05:33",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "swapp-ai",
"github_project": "extents",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "extents"
}