clothesline
A library to handle sets, made of intervals over a continuous infinite axis (a "domain") such as the real numbers or date/times.
import clothesline
bld = clothesline.RealIntervalSet.builder()
set1 = bld[-10](10) - bld(0)[1]
set1 # [-10, 0] U (1, 10)
set1.extension() # 19
set2 = set1 + bld[100](...)
set2.complement() # (-inf, -10) U (0, 1] U [10, 100)
set2 + set2.complement() # (-inf, +inf)
Quickstart
Note: for the full documentation, visit clothesline.readthedocs.io.
Work with sets
The library provides ready-to-use
RealIntervalSet to deal with sets over a number line
and DatetimeIntervalSet for date intervals.
Start by importing the library and getting a builder
for interval sets on the real line:
import clothesline
bld = clothesline.RealIntervalSet.builder()
Create a couple of intervals:
set1 = bld(0)(10)
set2 = bld[0][1] + bld(2)(3) + bld[20](...)
print(set2)
Here, round brackets mean that the boundary is excluded; square brackets mean the point is included. Three dots stand for the point at infinity.
You can also get an utils object, to create standard sets such as open or closed intervals, point-like sets and so on:
uti = clothesline.RealIntervalSet.utils()
set3 = uti.open(0, 5)
set4 = uti.high_slice(10, included=True)
Most set operations are supported: from complement to difference, from inclusion tests to XOR. Interval Sets should be treated as immutable objects. Moreover, since the internal representation of a set is always normalized to a canonical form, equality tests work as you would expect:
set5 = set4.union(set2)
set4 - set2
set3 + bld[3](10) == set1 # True
For more ways to create and manipulate sets, have a look at the User Guide in the full documentation.
Store and retrieve
You can convert any interval set into a string (e.g. to store it into a database) and re-hydrate it later:
import json
serialized = json.dumps(set3.to_dict())
# ...
new_set3 = uti.from_dict(json.loads(serialized))
new_set3 == set3 # True
Datetimes
Support for datetimes is ready out-of-the-box:
from datetime import datetime
dbld = clothesline.DatetimeIntervalSet.builder()
timespan1 = dbld[datetime(2010, 10, 10)](datetime(2011, 2, 20))
print(timespan1.complement())
print(timespan1.extension())
That's it! For more, check the full documentation.
Contributing
Coming soon.
Metadata
Release files for clothesline 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| clothesline-0.1.1.tar.gz | 18.9 kB | Without provenance | Details for clothesline-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| clothesline-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for clothesline-0.1.1-py3-none-any.whl |
Total release size: 43.8 kB
Release files / clothesline-0.1.1.tar.gz
| Download URL | clothesline-0.1.1.tar.gz |
|---|---|
| Size | 18.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7845f5379462cee59170b3ffaf50ec61105547889cbfbb20de15d8e9916e2790
|
|
BLAKE2b-256 checksum How to use checksums |
6087aec8ebd633b94d14844caa320eaf7225120b84964fcbc9744c6cce7fee2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.7.5
|
Release files / clothesline-0.1.1-py3-none-any.whl
| Download URL | clothesline-0.1.1-py3-none-any.whl |
|---|---|
| Size | 24.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
49d9636aca4e4c75704941a70043aa0fd8c388f2246fb3125417d8bdf2865ce8
|
|
BLAKE2b-256 checksum How to use checksums |
1fe0ebdf1f0e582e5e169aac54d4aab840c18caea01b4a17d54955260f2f77d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.7.5
|
Security for clothesline 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.