Bases: object
Class used to represent a cutpoint in a range, such that any range can be represented by 2 Cuts
Methods
| aboveAll(theType) | Create a cut point outside the upper end of the domain |
| aboveValue(val[, theType]) | Create a cut point, where everything above some value is |
| belowAll(theType) | Create a cut point outside the lower end of the domain |
| belowValue(val[, theType]) | Create a cut point, where everything below some value is |
| isGreaterThan(val) | Returns whether the cutpoint is greater than a specified value |
| isLessThan(val) | Returns whether the cutpoint is less than a specified value |
Create a cut point outside the upper end of the domain
| Parameters: | theType : type
|
|---|---|
| Returns: | The cut object |
Create a cut point, where everything above some value is included
| Parameters: | val : value in the domain
theType : type
|
|---|---|
| Returns: | The cut object |
Create a cut point outside the lower end of the domain
| Parameters: | theType : type
|
|---|---|
| Returns: | The cut object |
Create a cut point, where everything below some value is included
| Parameters: | val : value in the domain
theType : type
Returns ——- The cut object |
|---|
Returns whether the cutpoint is greater than a specified value
| Parameters: | val : Comparable, of compatible type
|
|---|---|
| Returns: | True if the cutpoint is strictly greater than the specified value |
| Raises: | ValueError
|
Returns whether the cutpoint is less than a specified value
| Parameters: | val : Comparable, of compatible type
|
|---|---|
| Returns: | True if the cutpoint is strictly less than the specified value |
| Raises: | ValueError
|
Bases: object
Class used to represent a range along some 1-D domain. The range is represented by 2 cutpoints can can be unbounded by specifying an aboveAll or belowAll Cut.
Methods
| atLeast(val) | Makes range including all values greater than or equal to some value (i.e. |
| atMost(val) | Makes range including all values less than or equal to some value (i.e. |
| closed(lower, upper) | Creates a range including the endpoints (i.e. |
| closedOpen(lower, upper) | Creates a range including the lower endpoint (i.e. |
| contains(val) | Returns true if the range contains the value |
| containsAll(vals) | Returns True if the range contains all values in some |
| encloses(other) | Returns True if the bounds of the other range do not extend |
| getDistanceFromPoint(val[, distFunc]) | Returns the minimum distance of a Range from a Point, returning 0 if there is an overlap. |
| getDistanceFromRange(other[, distFunc]) | Returns the minimum distance of a Range from another Range, returning |
| greaterThan(val) | Makes range including all values greater than some value (i.e. |
| hasLowerBound() | Returns True if the range has a lower endpoint (not unbounded |
| hasUpperBound() | Returns True if the range has an upper endpoint (not unbounded |
| intersection(other) | Returns the maximal range enclosed by both this range and the |
| isConnected(other) | Returns True if there is a (possibly empty) range that is |
| isEmpty() | Returns True if the range is of form [v, v) or (v, v] |
| isLowerBoundClosed() | Returns whether the lower bound is closed (if there is a |
| isUpperBoundClosed() | Returns whether the upper bound is closed (if there is an |
| lessThan(val) | Makes range including all values less than some value (i.e. |
| lowerEndpoint() | Returns the lower endpoint of the range if it exists. |
| open(lower, upper) | Creates a range excluding the endpoints (i.e. |
| openClosed(lower, upper) | Creates a range including the upper (i.e. |
| span(other) | Returns the minimal range that encloses both this range and the other. |
| upperEndpoint() | Returns the upper endpoint of the range if it exists. |
Makes range including all values greater than or equal to some value (i.e. [val, inf))
| Parameters: | val : comparable
|
|---|---|
| Returns: | A Range object [val, inf) |
| Raises: | ValueError
|
Makes range including all values less than or equal to some value (i.e. (-inf, val])
| Parameters: | val : comparable
|
|---|---|
| Returns: | A Range object (-inf, val] |
| Raises: | ValueError
|
Creates a range including the endpoints (i.e. [lower, upper])
| Parameters: | lower : comparable, of same type as or subclass of upper type
upper : comparable, of same type as or subclass of lower type
|
|---|---|
| Returns: | A Range object [lower, upper] |
| Raises: | ValueError
|
Creates a range including the lower endpoint (i.e. [lower, upper))
| Parameters: | lower : comparable, of same type as or subclass of upper type
upper : comparable, of same type as or subclass of lower type
|
|---|---|
| Returns: | A Range object [lower, upper) |
| Raises: | ValueError
|
Returns true if the range contains the value
| Parameters: | val : Comparable object of the appropriate type for the range
|
|---|---|
| Returns: | True if the range contains the value |
| Raises: | ValueError
|
Returns True if the range contains all values in some iterable
| Parameters: | vals : Iterable of comparable object of appropriate type for range
|
|---|---|
| Returns: | True if the range contains all values |
| Raises: | ValueError
|
Returns True if the bounds of the other range do not extend outside the bounds of this range
| Parameters: | other : A Range
|
|---|---|
| Returns: | True if the bounds of the other range do not extend outside the bounds of this range |
| Raises: | ValueError
|
Returns the minimum distance of a Range from a Point, returning 0 if there is an overlap.
Note that both upper and lower bounds must be closed for this function to work
| Parameters: | val : comparable, compatible with cutpoint type
distFunc : callable
|
|---|---|
| Returns: | The minimum distance between the Range and the Point. Returns 0 if there is an overlap |
| Raises: | TypeError
|
Returns the minimum distance of a Range from another Range, returning 0 if there is any overlap
Note that both Ranges must be closed for this function to work
| Parameters: | other : Range, compatible with this Range’s domain
distFunc : callable
|
|---|---|
| Returns: | Minimum distance between the ranges |
| Raises: | TypeError
|
Makes range including all values greater than some value (i.e. (val, inf])
| Parameters: | val : comparable
|
|---|---|
| Returns: | A Range object (val, inf) |
| Raises: | ValueError
|
Returns True if the range has a lower endpoint (not unbounded at the lower end)
| Returns: | True if the range has a lower endpoint |
|---|
Returns True if the range has an upper endpoint (not unbounded at the upper end)
| Returns: | True if the range has an upper endpoint |
|---|
Returns the maximal range enclosed by both this range and the other range, if such a range exists
| Parameters: | other : A range
|
|---|---|
| Returns: | The intersection range |
| Raises: | ValueError
|
Returns True if there is a (possibly empty) range that is enclosed by both this range and other
| Parameters: | other : A range
|
|---|---|
| Returns: | True if there is a (possibly empty) range that is enclosed by both this range and other |
| Raises: | ValueError
|
Returns True if the range is of form [v, v) or (v, v]
| Returns: | True if the range is of the form [v,v) or (v,v] |
|---|
Returns whether the lower bound is closed (if there is a lower bound)
| Returns: | True if the lower bound is closed |
|---|---|
| Raises: | TypeError
|
Returns whether the upper bound is closed (if there is an upper bound)
| Returns: | True if the upper bound is closed |
|---|---|
| Raises: | TypeError
|
Makes range including all values less than some value (i.e. (-inf, val))
| Parameters: | val : comparable
|
|---|---|
| Returns: | A Range object (-inf, val) |
| Raises: | ValueError
|
Returns the lower endpoint of the range if it exists. Otherwise raises a TypeError
| Returns: | The lower endpoint of the range |
|---|---|
| Raises: | TypeError
|
Creates a range excluding the endpoints (i.e. (lower, upper))
| Parameters: | lower : comparable, of same type as or subclass of upper type
upper : comparable, of same type as or subclass of lower type
|
|---|---|
| Returns: | A Range object (lower, upper) |
| Raises: | ValueError
|
Creates a range including the upper (i.e. (lower, upper])
| Parameters: | lower : comparable, of same type as or subclass of upper type
upper : comparable, of same type as or subclass of lower type
|
|---|---|
| Returns: | A Range object (lower, upper] |
| Raises: | ValueError
|
Returns the minimal range that encloses both this range and the other. Note that if the input ranges are not connected, the span can contain values that are not contained within either input range
| Parameters: | other : A range
|
|---|---|
| Returns: | The minimal range enclosing both with and the other range |
| Raises: | ValueError
|