A package for performing operations on numeric sets
Project description
numeric_sets
Allows you to perform all operations on sets of numeric intervals.
Usage example
Import classes from the main module of the package into your Python script.
from numeric_sets.main import Interval, NumericSet
main.main()
Feel free to perform any operation!
myset_1 = NumericSet()
myset_1.add(Interval(2, 4, True, True)) # [2, 4]
myset_1.add(Interval(5, 7)) # (5, 7)
myset_1.add(Interval(8, 10, is_end_inclusive=True)) # (8, 10]
myset_2 = NumericSet()
myset_2.add(Interval(2, 5)) # (2, 5)
myset_2.add(Interval(6, 9)) # (6, 9)
union = myset_1.union(
myset_2) # [2, 5) + (5, 10]
Methods description
Interval class
get_formatted
Returns formatted interval as a string.
Return
Interval as a formatted string.
is_overlapping
Determines whether the interval overlaps with the given interval.
Arguments
- interval a numeric interval
Return
True if intervals overlap, False otherweise.
is_almost_overlapping
Determines whether the interval almost overlaps with the given interval.
Arguments
- interval a numeric interval
Return
True if intervals almost overlap, False otherweise.
includes
Determines whether the interval includes the given point.
Arguments
- point a numeric point
Return
True if the interval includes the given point, False otherweise.
copy
Copies the interval.
Return
A copy of the interval.
difference [static]
Returns the difference between two given intervals.
Arguments
- interval_1 a numeric interval
- interval_2 a numeric interval
Return
Difference between two given intervals.
intersection [static]
Returns the intersection of two given intervals.
Arguments
- interval_1 a numeric interval
- interval_2 a numeric interval
Return
Intersection of two given intervals.
union [static]
Returns the union of two given intervals.
Arguments
- interval_1 a numeric interval
- interval_2 a numeric interval
Return
Union of two given intervals.
NumericSet methods
get_left_intervals
Constructs a list of intervals to the left from the interval.
Arguments
- interval a numeric interval
Return
A list of intervals to the left from the interval.
get_right_intervals
Constructs a list of intervals to the right from the interval.
Arguments
- interval a numeric interval
Return
A list of intervals to the right from the interval.
add
Adds a numeric interval to the set.
Arguments
- interval a numeric interval
clear
Clears the set from all numeric intervals.
copy
Copies the numeric set.
Return
A copy of the numric set.
difference
Constructs a set representing the difference between the set and the given set.
Arguments
- numeric_set a numeric set
Return
The difference between the set and the given set.
difference_update
Constructs a set representing the difference between the set and the given set and updates the set.
Arguments
- numeric_set a numeric set
intersection
Constructs a set representing the intersection of the set and the given set.
Arguments
- numeric_set a numeric set
Return
The intersection of the set and the given set.
intersection_update
Constructs a set representing the intersection of the set and the given set and updates the set.
Arguments
- numeric_set a numeric set
issubset
Determines whether the set is a subset of the given set.
Arguments
- numeric_set a numeric set
Return
True if the interval is a subset of the given interval, False otherweise.
issuperset
Determines whether the set is a superset of the given set.
Arguments
- numeric_set a numeric set
Return
True if the interval is a superset of the given interval, False otherweise.
pop
Removes the rightmost interval if such exists.
Return
The rightmost interval if such exists, None otherwise.
remove
Removes a numeric interval from the numeric set.
Arguments
- interval a numeric interval
symmetric_difference
Constructs a set representing the symmetric difference of two sets.
Arguments
- numeric_set a numeric set
Return
The symmetric difference of the set and the given set.
symmetric_difference_update
Constructs a set representing the symmetric difference of the set and the given set and updates the set.
Arguments
- numeric_set a numeric set
union
Constructs a set representing the union of two sets.
Arguments
- numeric_set a numeric set
Return
The union of the set and the given set.
update
Constructs a set representing the union of the set and the given set and updates the set.
Arguments
- numeric_set a numeric set
is_empty
Determines whether a set of intervals is empty.
Return
True if the set is empty, False otherweise.
save
Saves a set of numeric intervals in the given file.
Arguments
- filename the name of the file
read [static]
Reads a set of numerical intervals from the given file.
Arguments
- filename the name of the file
Meta
Dmytro Yaroshevych – dyaroshevych@gmail.com
Distributed under the MIT license. See LICENSE
for more information.
https://github.com/dyaroshevych/numeric_sets
Contributing
- Fork it (https://github.com/dyaroshevych/numeric_sets/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for numeric_sets_dyaroshevych-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b22d0c4db02bdbfe0e14d6df253c9bbcb76a08b79096c8ece231f6c2e8e9932 |
|
MD5 | 6830faaaeb492419333d309e3090311b |
|
BLAKE2b-256 | 070c918e111dd24ada4cfee4b482c3e3101c1ebf73ff4d55514e37a2be850f08 |
Hashes for numeric_sets_dyaroshevych-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2f4daee670a6eab5c462e5ac781b6d537bbee030b4becac8d380e6718c77f29 |
|
MD5 | 1bc4817a9c190e4c0d55438543d73fbc |
|
BLAKE2b-256 | 5a7ca8ef99373d9ee1409a9ae0a9557908de637cdb0c82995a62f25ebe82aae3 |