types8174%python.module
fault.range

Range classes for managing associations and sets whose items span ranges.

Engineering

Mapping, and a Stack thereof, are not yet implemented. Currently, there are some differences between the implementation of a Mapping and the extant Set. Notably, adjacent ranges can only be joined if the values are equivalent. Sets join adjacent ranges unconditionally.

operator
import

itertools0
import

typing0
import

collections0
import

builtins0
import

inclusive_range_set110%
function

inclusive_range_set(numbers)

Calculate the set of inclusive ranges.

Given a iterable of numbers, sort them and create ranges from the contiguous values.

inclusive_range_setParameters

numbers

Iterable of Integers.

combine0
function

combine(ranges)

Combine the ranges into a sequence of ranges reducing them according to their overlaps and contiguity. Used by Set to implement unions.

IRange0
class

Fully Inclusive range used for cases where the range length always is one or more.

IRange__slots__0
data

__slots__ = ()

IRangeType0
data
type

Type:(type) = int
	@property

IRangedirection40%
property

Returns -1 if the stop is less than the start. 1 if equal or greater than.

IRangestart20%
property

The beginning of the Range, inclusive.

IRangestop20%
property

The end of the Range, inclusive.

IRangenormal0
classmethod

normal(Class, *args)

Create a normal range using the given boundaries; the minimum given will be the start and the maximum will be the stop.

IRangesingle0
classmethod

single(Class, index)

Create a range consisting of a single unit.

IRangefrom_string0
classmethod

from_string(Class, string)

IRange__contains__0
method

__contains__(self, x)

Whether or not the range contains the given number.

IRange__str__0
method

__str__(self)

IRangerelation40%
method

relation(self, r)

The relation of r with respect to the self. Returns -1 if r is less than the start; 1 if r is greater than the stop, and 0 if it is contained.

WARNING

Does not compensate for negative direction ranges.

IRangecontiguous0
method

contiguous(self, r)

The given range is contiguous with the other, but does not overlaps.

IRangeoverlaps0
method

overlaps(self, r)

The ranges overlap onto each other.

IRangecontinuation0
method

continuation(self, r)

The ranges are continuous: overlaps or contiguous.

IRangejoin0
method

join(self, r)

Combine the ranges regardless of adjacency.

IRangefilter0
method

filter(self, ranges)

Modify (filter) the ranges to be outside of self. If a range is wholly contained, filter it entirely.

The filter is a generator and is applied to an iterable of ranges because it is the necessary framework for dropping wholly contained inclusive ranges. Inclusive ranges cannot represent zero length sizes, so it has to drop contained ranges entirely from the generated sequence.

IRangefilterParameters

self

Undocumented.

ranges
  • typing.Iterable["IRange"]

Sequence of IRange instances to be filtered.

IRangeintersect0
method
typing.Iterable["IRange"]

intersect(self, ranges)

Identify the parts of the ranges that intersect with self.

IRangeintersectParameters

self

Undocumented.

ranges
  • typing.Iterable["IRange"]

Sequence of IRange instances to intersect with self.

IRangeintersectReturns

Annotation

A iterable producing IRange instances.

IRangeexclusive20%
method

exclusive(self)

Return as an exclusive-end range pair.

IRangeunits420%
method

units(self)

Return an iterator to the units in the range.

Set0
class

A set of unique non-contiguous ranges.

Implemented using a pair of sequences containing the start and the stop of each range. For sets consisting of single unit ranges, regular set objects are more efficient. bisect is used as the search algorithm when checking for containment, so applications requiring high performance may need to convert the range set or portions thereof into a regular set.

Set__slots__0
data

__slots__ = ('starts', 'stops')
	@classmethod

Setfrom_string0
classmethod

from_string(Class, string)

Setfrom_set20%
classmethod

from_set(Class, iterable)

Setfrom_normal_sequence0
classmethod

from_normal_sequence(Class, ranges)

Low-level constructor building a Set from an ordered sequence of non-overlapping range instances.

Set__init__0
method

__init__(self, pair)

Set__repr__10%
method

__repr__(self)

Set__reduce__0
method

__reduce__(self)

Set__iter__0
method

__iter__(self)

Set__str__0
method

__str__(self)

Set__eq__0
method

__eq__(self, ns)

Set__len__0
method

__len__(self)

Total number of individual units held by the set.

Working with inclusive ranges, this means that spans from 0 to 100 will have a length of 101.

Setintersecting0
method

intersecting(self, range)

Get the ranges in the set that have intersections with the given range.

Setget40%
method

get(self, item)

Set__getitem__40%
method

__getitem__(self, item)

Set__contains__0
method

__contains__(self, item)

Setadd0
method

add(self, range)

Add a range to the set combining it with any continuations.

Setdiscard192%
method

discard(self, range)

Remove an arbitrary range from the set.

Setintersection0
method

intersection(self, range_set)

Calculate the intersection between two Set instances. Low-level method. Use | for high-level purposes.

Setdifference289%
method

difference(self, range_set)

Calculate the difference between two Set instances. Low-level method. Use - for high-level purposes.

Setunion0
method

union(self, range_set)

Calculate the union between two Set instances.

Set__add__0
data

__add__ = union

Set__sub__0
method

__sub__(self, range_set)

Set__or__10%
method

__or__(self, range_set)

XRange0
class

Exclusive numeric range. Only exclusive on the stop. Provides access to zero-sized ranges that need to maintain position.

XRange__slots__0
data

__slots__ = ()

XRangeType0
data
type

Type:(type) = int
	@property

XRangedirection40%
property

Returns -1 if the stop is less than the start.

XRangestart20%
property

The beginning of the Range, inclusive.

XRangestop20%
property

The end of the Range, inclusive.

XRangenormal20%
classmethod

normal(Class, *args)

Create a normal range using the given boundaries; the minimum given will be the start and the maximum will be the stop.

XRangesingle20%
classmethod

single(Class, index)

Create a range consisting of a single unit.

XRange__contains__20%
method

__contains__(self, x)

Whether or not the range contains the given number.

XRangerelation40%
method

relation(self, r)

The relation of r with respect to the self. Returns -1 if r is less than the start; 1 if r is greater than the stop, and 0 if it is contained.

WARNING

Does not compensate for negative direction ranges.

XRangecontiguous40%
method

contiguous(self, range)

Whether the given range is contiguous with self.

XRangejoin20%
method

join(self, r)

Combine the ranges.

XRangeexclusive20%
method

exclusive(self)

Returns self.

XRangeunits420%
method

units(self)

Return an iterator to the units in the range.

Mapping0
class

A tiered, finite map of ranges explicitly associated with values.

WARNING

Implementation is sensitive to the order in which items are set. Keys intending to contain other Ranges must be set before the narrow range is set.

MappingEngineering

Rewrite by vectorizing k-index and v-index to eliminate the recursive implementation. In cases of instances with large depths, a vectorized form should help with execution (fewer stack frames) and memory (fewer instances) performance.

Mapping__init__0
method

__init__(self)

Mappingkeys0
method

keys(self)

Mappingvalues0
method

values(self)

Mappingitems0
method

items(self)

Mappingget0
method

get(self, key)

Mapping__getitem__175%
method

__getitem__(self, key)

Mapping__setitem__0
method

__setitem__(self, key, value)

Mappingupdate0
method

update(self, vs)

Mapping__delitem__60%
method

__delitem__(self, key)

Mappingpath0
method

path(self, key)

For the given key, identify the containing range and its associated value at each level in the mapping.

Mappinglevels0
method

levels(self, key)

Mappinglast0
method

last(self, key)