Interval [abstract class]

The splinekit.interval.Interval module provides the abstract base class from which concrete Interval classes are derived.

This abstract class handles intervals of real numbers.

Abstract Properties

Abstract Methods

Class Methods

Instance Methods

Abstract Operators

Operators

  • __eq__ == Equality of intervals: \(=\)

  • __ne__ != Inequality of intervals: \(\neq\)

  • __lt__ < Proper subset: \(\subset\)

  • __le__ <= Subset: \(\subseteq\)

  • __neg__ - Unary complement in RR(): \((\cdot)^{{\mathrm{c}}}\)

  • __sub__ - Pairwise difference: \(\setminus\)

  • __and__ & Intersection: \(\cap\)

  • __or__ | Union: \(\cup\)

  • __xor__ ^ Symmetric difference: \(\Delta\)

Concrete Classes


class splinekit.interval.interval.Interval

Bases: ABC

The abstract class that concrete intervals of real numbers must implement.

The known concrete classes that implement this abstract class are
  • RR All finite real numbers \({\mathbb{R}}=(-\infty,\infty)\)

  • Empty The empty interval \(\{x\in{\mathbb{R}}|x\neq x\}=\emptyset\)

  • Singleton The degenerate interval \(\{x\in{\mathbb{R}}|x=x_{0}\}=[x_{0},x_{0}]\)

  • Above The right-unbounded interval \(\{x\in{\mathbb{R}}|x>x_{0}\}=(x_{0},\infty)\)

  • NotBelow The right-unbounded interval \(\{x\in{\mathbb{R}}|x\geq x_{0}\}=[x_{0},\infty)\)

  • NotAbove The left-unbounded interval \(\{x\in{\mathbb{R}}|x\leq x_{0}\}=(—\infty,x_{0}]\)

  • Below The left-unbounded interval \(\{x\in{\mathbb{R}}|x<x_{0}\}=(—\infty,x_{0})\)

  • Open The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x<x_{1}\}=(x_{0},x_{1})\)

  • OpenClosed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x\leq x_{1}\}=(x_{0},x_{1}]\)

  • Closed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x\leq x_{1}\}=[x_{0},x_{1}]\)

  • ClosedOpen The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x<x_{1}\}=[x_{0},x_{1})\)


abstract property infimum: float

The value of the left endpoint of this interval.

Returns:

Left endpoint.

Return type:

float

Notes

infimum = float(“nan”) for the following class.
  • Empty The empty interval \(\{x\in{\mathbb{R}}|x\neq x\}=\emptyset\)

infimum = float(“-inf”) for the following classes.
  • RR All finite real numbers \({\mathbb{R}}=(-\infty,\infty)\)

  • NotAbove The left-unbounded interval \(\{x\in{\mathbb{R}}|x\leq x_{0}\}=(—\infty,x_{0}]\)

  • Below The left-unbounded interval \(\{x\in{\mathbb{R}}|x<x_{0}\}=(—\infty,x_{0})\)

math.isfinite(infimum) = True for the following classes.
  • Singleton The degenerate interval \(\{x\in{\mathbb{R}}|x=x_{0}\}=[x_{0},x_{0}]\)

  • Above The right-unbounded interval \(\{x\in{\mathbb{R}}|x>x_{0}\}=(x_{0},\infty)\)

  • NotBelow The right-unbounded interval \(\{x\in{\mathbb{R}}|x\geq x_{0}\}=[x_{0},\infty)\)

  • Open The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x<x_{1}\}=(x_{0},x_{1})\)

  • OpenClosed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x\leq x_{1}\}=(x_{0},x_{1}]\)

  • Closed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x\leq x_{1}\}=[x_{0},x_{1}]\)

  • ClosedOpen The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x<x_{1}\}=[x_{0},x_{1})\)


abstract property supremum: float

The value of the right endpoint of this interval.

Returns:

Right endpoint.

Return type:

float

Notes

supremum = float(“nan”) for the following class.
  • Empty The empty interval \(\{x\in{\mathbb{R}}|x\neq x\}=\emptyset\)

supremum = float(“inf”) for the following classes.
  • RR All finite real numbers \({\mathbb{R}}=(-\infty,\infty)\)

  • Above The right-unbounded interval \(\{x\in{\mathbb{R}}|x>x_{0}\}=(x_{0},\infty)\)

  • NotBelow The right-unbounded interval \(\{x\in{\mathbb{R}}|x\geq x_{0}\}=[x_{0},\infty)\)

math.isfinite(supremum) = True for the following classes.
  • Singleton The degenerate interval \(\{x\in{\mathbb{R}}|x=x_{0}\}=[x_{0},x_{0}]\)

  • NotAbove The left-unbounded interval \(\{x\in{\mathbb{R}}|x\leq x_{0}\}=(—\infty,x_{0}]\)

  • Below The left-unbounded interval \(\{x\in{\mathbb{R}}|x<x_{0}\}=(—\infty,x_{0})\)

  • Open The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x<x_{1}\}=(x_{0},x_{1})\)

  • OpenClosed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x\leq x_{1}\}=(x_{0},x_{1}]\)

  • Closed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x\leq x_{1}\}=[x_{0},x_{1}]\)

  • ClosedOpen The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x<x_{1}\}=[x_{0},x_{1})\)


abstract property isleftopen: bool

If the infimum of this interval is a finite number, tests whether it fails to be a member of the interval; else, the interval is vacuously said to be left-open.

Returns:

  • False if this interval is not open to the left.

  • True if this interval is open to the left.

Return type:

bool

Examples

Left-openness of some bounded interval.
>>> import splinekit.interval as ivl
>>> ivl.OpenClosed((1.0, 5.0)).isleftopen
True

Notes

isleftopen = True for the following classes.
  • RR All finite real numbers \({\mathbb{R}}=(-\infty,\infty)\)

  • Empty The empty interval \(\{x\in{\mathbb{R}}|x\neq x\}=\emptyset\)

  • Above The right-unbounded interval \(\{x\in{\mathbb{R}}|x>x_{0}\}=(x_{0},\infty)\)

  • NotAbove The left-unbounded interval \(\{x\in{\mathbb{R}}|x\leq x_{0}\}=(—\infty,x_{0}]\)

  • Below The left-unbounded interval \(\{x\in{\mathbb{R}}|x<x_{0}\}=(—\infty,x_{0})\)

  • Open The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x<x_{1}\}=(x_{0},x_{1})\)

  • OpenClosed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x\leq x_{1}\}=(x_{0},x_{1}]\)

isleftopen = False for the following classes.
  • Singleton The degenerate interval \(\{x\in{\mathbb{R}}|x=x_{0}\}=[x_{0},x_{0}]\)

  • NotBelow The right-unbounded interval \(\{x\in{\mathbb{R}}|x\geq x_{0}\}=[x_{0},\infty)\)

  • Closed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x\leq x_{1}\}=[x_{0},x_{1}]\)

  • ClosedOpen The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x<x_{1}\}=[x_{0},x_{1})\)


abstract property isrightopen: bool

If the supremum of this interval is a finite number, tests whether it fails to be a member of the interval; else, the interval is vacuously said to be right-open.

Returns:

  • False if this interval is not open to the right.

  • True if this interval is open to the right.

Return type:

bool

Examples

Right-openness of some bounded interval.
>>> import splinekit.interval as ivl
>>> ivl.OpenClosed((1.0, 5.0)).isrightopen
False

Notes

isrightopen = True for the following classes.
  • RR All finite real numbers \({\mathbb{R}}=(-\infty,\infty)\)

  • Empty The empty interval \(\{x\in{\mathbb{R}}|x\neq x\}=\emptyset\)

  • Above The right-unbounded interval \(\{x\in{\mathbb{R}}|x>x_{0}\}=(x_{0},\infty)\)

  • NotBelow The right-unbounded interval \(\{x\in{\mathbb{R}}|x\geq x_{0}\}=[x_{0},\infty)\)

  • Below The left-unbounded interval \(\{x\in{\mathbb{R}}|x<x_{0}\}=(—\infty,x_{0})\)

  • Open The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x<x_{1}\}=(x_{0},x_{1})\)

  • ClosedOpen The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x<x_{1}\}=[x_{0},x_{1})\)

isrightopen = False for the following classes.
  • Singleton The degenerate interval \(\{x\in{\mathbb{R}}|x=x_{0}\}=[x_{0},x_{0}]\)

  • NotAbove The left-unbounded interval \(\{x\in{\mathbb{R}}|x\leq x_{0}\}=(—\infty,x_{0}]\)

  • OpenClosed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x\leq x_{1}\}=(x_{0},x_{1}]\)

  • Closed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x\leq x_{1}\}=[x_{0},x_{1}]\)


abstract property isopen: bool

Tests if this interval is jointly left-open and right-open.

Returns:

  • False if this interval is not open.

  • True if this interval is open.

Return type:

bool

Examples

Openness of some bounded interval.
>>> import splinekit.interval as ivl
>>> ivl.OpenClosed((1.0, 5.0)).isopen
False

Notes

isopen = True for the following classes.
  • RR All finite real numbers \({\mathbb{R}}=(-\infty,\infty)\)

  • Empty The empty interval \(\{x\in{\mathbb{R}}|x\neq x\}=\emptyset\)

  • Above The right-unbounded interval \(\{x\in{\mathbb{R}}|x>x_{0}\}=(x_{0},\infty)\)

  • Below The left-unbounded interval \(\{x\in{\mathbb{R}}|x<x_{0}\}=(—\infty,x_{0})\)

  • Open The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x<x_{1}\}=(x_{0},x_{1})\)

isopen = False for the following classes.
  • Singleton The degenerate interval \(\{x\in{\mathbb{R}}|x=x_{0}\}=[x_{0},x_{0}]\)

  • NotBelow The right-unbounded interval \(\{x\in{\mathbb{R}}|x\geq x_{0}\}=[x_{0},\infty)\)

  • NotAbove The left-unbounded interval \(\{x\in{\mathbb{R}}|x\leq x_{0}\}=(—\infty,x_{0}]\)

  • OpenClosed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x\leq x_{1}\}=(x_{0},x_{1}]\)

  • Closed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x\leq x_{1}\}=[x_{0},x_{1}]\)

  • ClosedOpen The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x<x_{1}\}=[x_{0},x_{1})\)


abstract property ishalfopen: bool

Tests if this interval is open at one end only.

Returns:

  • False if this interval is not half-open.

  • True if this interval is half-open.

Return type:

bool

Examples

Half-openness of some bounded interval.
>>> import splinekit.interval as ivl
>>> ivl.OpenClosed((1.0, 5.0)).ishalfopen
True

Notes

ishalfopen = True for the following classes.
  • NotBelow The right-unbounded interval \(\{x\in{\mathbb{R}}|x\geq x_{0}\}=[x_{0},\infty)\)

  • NotAbove The left-unbounded interval \(\{x\in{\mathbb{R}}|x\leq x_{0}\}=(—\infty,x_{0}]\)

  • OpenClosed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x\leq x_{1}\}=(x_{0},x_{1}]\)

  • ClosedOpen The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x<x_{1}\}=[x_{0},x_{1})\)

ishalfopen = False for the following classes.
  • RR All finite real numbers \({\mathbb{R}}=(-\infty,\infty)\)

  • Empty The empty interval \(\{x\in{\mathbb{R}}|x\neq x\}=\emptyset\)

  • Singleton The degenerate interval \(\{x\in{\mathbb{R}}|x=x_{0}\}=[x_{0},x_{0}]\)

  • Above The right-unbounded interval \(\{x\in{\mathbb{R}}|x>x_{0}\}=(x_{0},\infty)\)

  • Below The left-unbounded interval \(\{x\in{\mathbb{R}}|x<x_{0}\}=(—\infty,x_{0})\)

  • Open The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x<x_{1}\}=(x_{0},x_{1})\)

  • Closed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x\leq x_{1}\}=[x_{0},x_{1}]\)


abstract property isclosed: bool

If the infimum and the supremum of this interval are two finite numbers, tests if they are jointly members of the interval; else, the interval is vacuously said to be closed.

Returns:

  • False if this interval is not closed.

  • True if this interval is closed.

Return type:

bool

Examples

Closedness of some bounded interval.
>>> import splinekit.interval as ivl
>>> ivl.OpenClosed((1.0, 5.0)).isclosed
False

Notes

isclosed = True for the following classes.
  • RR All finite real numbers \({\mathbb{R}}=(-\infty,\infty)\)

  • Empty The empty interval \(\{x\in{\mathbb{R}}|x\neq x\}=\emptyset\)

  • Singleton The degenerate interval \(\{x\in{\mathbb{R}}|x=x_{0}\}=[x_{0},x_{0}]\)

  • NotBelow The right-unbounded interval \(\{x\in{\mathbb{R}}|x\geq x_{0}\}=[x_{0},\infty)\)

  • NotAbove The left-unbounded interval \(\{x\in{\mathbb{R}}|x\leq x_{0}\}=(—\infty,x_{0}]\)

  • Closed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x\leq x_{1}\}=[x_{0},x_{1}]\)

isclosed = False for the following classes.
  • Above The right-unbounded interval \(\{x\in{\mathbb{R}}|x>x_{0}\}=(x_{0},\infty)\)

  • Below The left-unbounded interval \(\{x\in{\mathbb{R}}|x<x_{0}\}=(—\infty,x_{0})\)

  • Open The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x<x_{1}\}=(x_{0},x_{1})\)

  • OpenClosed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x\leq x_{1}\}=(x_{0},x_{1}]\)

  • ClosedOpen The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x<x_{1}\}=[x_{0},x_{1})\)


abstract property isleftbounded: bool

Tests whether the infimum of this interval fails to be an infinite number.

Returns:

  • False if this interval is not bounded to the left.

  • True if this interval is bounded to the left.

Return type:

bool

Examples

Left-boundedness of some half-bounded interval.
>>> import splinekit.interval as ivl
>>> ivl.Above(3.0).isleftbounded
True

Notes

isleftbounded = True for the following classes.
  • Empty The empty interval \(\{x\in{\mathbb{R}}|x\neq x\}=\emptyset\)

  • Singleton The degenerate interval \(\{x\in{\mathbb{R}}|x=x_{0}\}=[x_{0},x_{0}]\)

  • Above The right-unbounded interval \(\{x\in{\mathbb{R}}|x>x_{0}\}=(x_{0},\infty)\)

  • NotBelow The right-unbounded interval \(\{x\in{\mathbb{R}}|x\geq x_{0}\}=[x_{0},\infty)\)

  • Open The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x<x_{1}\}=(x_{0},x_{1})\)

  • OpenClosed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x\leq x_{1}\}=(x_{0},x_{1}]\)

  • Closed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x\leq x_{1}\}=[x_{0},x_{1}]\)

  • ClosedOpen The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x<x_{1}\}=[x_{0},x_{1})\)

isleftbounded = False for the following classes.
  • RR All finite real numbers \({\mathbb{R}}=(-\infty,\infty)\)

  • NotAbove The left-unbounded interval \(\{x\in{\mathbb{R}}|x\leq x_{0}\}=(—\infty,x_{0}]\)

  • Below The left-unbounded interval \(\{x\in{\mathbb{R}}|x<x_{0}\}=(—\infty,x_{0})\)


abstract property isrightbounded: bool

Tests whether the supremum of this interval fails to be an infinite number.

Returns:

  • False if this interval is not bounded to the right.

  • True if this interval is bounded to the right.

Return type:

bool

Examples

Right-boundedness of some half-bounded interval.
>>> import splinekit.interval as ivl
>>> ivl.Above(3.0).isrightbounded
False

Notes

isrightbounded = True for the following classes.
  • Empty The empty interval \(\{x\in{\mathbb{R}}|x\neq x\}=\emptyset\)

  • Singleton The degenerate interval \(\{x\in{\mathbb{R}}|x=x_{0}\}=[x_{0},x_{0}]\)

  • NotAbove The left-unbounded interval \(\{x\in{\mathbb{R}}|x\leq x_{0}\}=(—\infty,x_{0}]\)

  • Below The left-unbounded interval \(\{x\in{\mathbb{R}}|x<x_{0}\}=(—\infty,x_{0})\)

  • Open The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x<x_{1}\}=(x_{0},x_{1})\)

  • OpenClosed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x\leq x_{1}\}=(x_{0},x_{1}]\)

  • Closed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x\leq x_{1}\}=[x_{0},x_{1}]\)

  • ClosedOpen The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x<x_{1}\}=[x_{0},x_{1})\)

isrightbounded = False for the following classes.
  • RR All finite real numbers \({\mathbb{R}}=(-\infty,\infty)\)

  • Above The right-unbounded interval \(\{x\in{\mathbb{R}}|x>x_{0}\}=(x_{0},\infty)\)

  • NotBelow The right-unbounded interval \(\{x\in{\mathbb{R}}|x\geq x_{0}\}=[x_{0},\infty)\)


abstract property ishalfbounded: bool

Tests if this interval is bounded at one end only.

Returns:

  • False if this interval is not half-bounded.

  • True if this interval is half-bounded.

Return type:

bool

Examples

Half-boundedness of some half-bounded interval.
>>> import splinekit.interval as ivl
>>> ivl.Above(3.0).ishalfbounded
True

Notes

ishalfbounded = True for the following classes.
  • Above The right-unbounded interval \(\{x\in{\mathbb{R}}|x>x_{0}\}=(x_{0},\infty)\)

  • NotBelow The right-unbounded interval \(\{x\in{\mathbb{R}}|x\geq x_{0}\}=[x_{0},\infty)\)

  • NotAbove The left-unbounded interval \(\{x\in{\mathbb{R}}|x\leq x_{0}\}=(—\infty,x_{0}]\)

  • Below The left-unbounded interval \(\{x\in{\mathbb{R}}|x<x_{0}\}=(—\infty,x_{0})\)

ishalfbounded = False for the following classes.
  • RR All finite real numbers \({\mathbb{R}}=(-\infty,\infty)\)

  • Empty The empty interval \(\{x\in{\mathbb{R}}|x\neq x\}=\emptyset\)

  • Singleton The degenerate interval \(\{x\in{\mathbb{R}}|x=x_{0}\}=[x_{0},x_{0}]\)

  • Open The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x<x_{1}\}=(x_{0},x_{1})\)

  • OpenClosed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x\leq x_{1}\}=(x_{0},x_{1}]\)

  • Closed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x\leq x_{1}\}=[x_{0},x_{1}]\)

  • ClosedOpen The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x<x_{1}\}=[x_{0},x_{1})\)


abstract property isbounded: bool

Tests if this interval is bounded at both ends jointly.

Returns:

  • False if this interval is not bounded.

  • True if this interval is bounded.

Return type:

bool

Examples

Boundedness of some half-bounded interval.
>>> import splinekit.interval as ivl
>>> ivl.Above(3.0).isbounded
False

Notes

isbounded = True for the following classes.
  • Empty The empty interval \(\{x\in{\mathbb{R}}|x\neq x\}=\emptyset\)

  • Singleton The degenerate interval \(\{x\in{\mathbb{R}}|x=x_{0}\}=[x_{0},x_{0}]\)

  • Open The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x<x_{1}\}=(x_{0},x_{1})\)

  • OpenClosed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x\leq x_{1}\}=(x_{0},x_{1}]\)

  • Closed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x\leq x_{1}\}=[x_{0},x_{1}]\)

  • ClosedOpen The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x<x_{1}\}=[x_{0},x_{1})\)

isbounded = False for the following classes.
  • RR All finite real numbers \({\mathbb{R}}=(-\infty,\infty)\)

  • Above The right-unbounded interval \(\{x\in{\mathbb{R}}|x>x_{0}\}=(x_{0},\infty)\)

  • NotBelow The right-unbounded interval \(\{x\in{\mathbb{R}}|x\geq x_{0}\}=[x_{0},\infty)\)

  • NotAbove The left-unbounded interval \(\{x\in{\mathbb{R}}|x\leq x_{0}\}=(—\infty,x_{0}]\)

  • Below The left-unbounded interval \(\{x\in{\mathbb{R}}|x<x_{0}\}=(—\infty,x_{0})\)


abstract property isdegenerate: bool

Tests if this interval contains a single number.

Returns:

  • False if this interval is not degenerate.

  • True if this interval is degenerate.

Return type:

bool

Examples

Degeneracy of the Empty interval.
>>> import splinekit.interval as ivl
>>> ivl.Empty().isdegenerate
False

Notes

isdegenerate = True for the following class.
  • Singleton The degenerate interval \(\{x\in{\mathbb{R}}|x=x_{0}\}=[x_{0},x_{0}]\)

isdegenerate = False for the following classes.
  • RR All finite real numbers \({\mathbb{R}}=(-\infty,\infty)\)

  • Empty The empty interval \(\{x\in{\mathbb{R}}|x\neq x\}=\emptyset\)

  • Above The right-unbounded interval \(\{x\in{\mathbb{R}}|x>x_{0}\}=(x_{0},\infty)\)

  • NotBelow The right-unbounded interval \(\{x\in{\mathbb{R}}|x\geq x_{0}\}=[x_{0},\infty)\)

  • NotAbove The left-unbounded interval \(\{x\in{\mathbb{R}}|x\leq x_{0}\}=(—\infty,x_{0}]\)

  • Below The left-unbounded interval \(\{x\in{\mathbb{R}}|x<x_{0}\}=(—\infty,x_{0})\)

  • Open The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x<x_{1}\}=(x_{0},x_{1})\)

  • OpenClosed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x\leq x_{1}\}=(x_{0},x_{1}]\)

  • Closed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x\leq x_{1}\}=[x_{0},x_{1}]\)

  • ClosedOpen The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x<x_{1}\}=[x_{0},x_{1})\)


abstract property isproper: bool

Tests if this interval contains a range of numbers.

Returns:

  • False if this interval is not proper.

  • True if this interval is proper.

Return type:

bool

Examples

Properness of the Singleton interval.
>>> import splinekit.interval as ivl
>>> ivl.Singleton(6.0).isproper
False

Notes

isproper = True for the following class.
  • RR All finite real numbers \({\mathbb{R}}=(-\infty,\infty)\)

  • Above The right-unbounded interval \(\{x\in{\mathbb{R}}|x>x_{0}\}=(x_{0},\infty)\)

  • NotBelow The right-unbounded interval \(\{x\in{\mathbb{R}}|x\geq x_{0}\}=[x_{0},\infty)\)

  • NotAbove The left-unbounded interval \(\{x\in{\mathbb{R}}|x\leq x_{0}\}=(—\infty,x_{0}]\)

  • Below The left-unbounded interval \(\{x\in{\mathbb{R}}|x<x_{0}\}=(—\infty,x_{0})\)

  • Open The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x<x_{1}\}=(x_{0},x_{1})\)

  • OpenClosed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x\leq x_{1}\}=(x_{0},x_{1}]\)

  • Closed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x\leq x_{1}\}=[x_{0},x_{1}]\)

  • ClosedOpen The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x<x_{1}\}=[x_{0},x_{1})\)

isproper = False for the following classes.
  • Empty The empty interval \(\{x\in{\mathbb{R}}|x\neq x\}=\emptyset\)

  • Singleton The degenerate interval \(\{x\in{\mathbb{R}}|x=x_{0}\}=[x_{0},x_{0}]\)


abstract property interior: Self

The largest open interval that is contained in this interval.

Returns:

The interior of this interval.

Return type:

Interval

Examples

The interior of an OpenClosed interval is an Open interval.
>>> import splinekit.interval as ivl
>>> ivl.OpenClosed((1.0, 5.0)).interior
Open((1.0, 5.0))

Notes

The following class has RR() as interior.
  • RR All finite real numbers \({\mathbb{R}}=(-\infty,\infty)\)

The following classes have Empty() as interior.
  • Empty The empty interval \(\{x\in{\mathbb{R}}|x\neq x\}=\emptyset\)

  • Singleton The degenerate interval \(\{x\in{\mathbb{R}}|x=x_{0}\}=[x_{0},x_{0}]\)

The following classes have an object of class Above as interior.
  • Above The right-unbounded interval \(\{x\in{\mathbb{R}}|x>x_{0}\}=(x_{0},\infty)\)

  • NotBelow The right-unbounded interval \(\{x\in{\mathbb{R}}|x\geq x_{0}\}=[x_{0},\infty)\)

The following classes have an object of class Below as interior.
  • NotAbove The left-unbounded interval \(\{x\in{\mathbb{R}}|x\leq x_{0}\}=(—\infty,x_{0}]\)

  • Below The left-unbounded interval \(\{x\in{\mathbb{R}}|x<x_{0}\}=(—\infty,x_{0})\)

The following classes have an object of class Open as interior.
  • Open The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x<x_{1}\}=(x_{0},x_{1})\)

  • OpenClosed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x\leq x_{1}\}=(x_{0},x_{1}]\)

  • Closed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x\leq x_{1}\}=[x_{0},x_{1}]\)

  • ClosedOpen The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x<x_{1}\}=[x_{0},x_{1})\)


abstract property closure: Self

The smallest closed interval that contains this interval.

Returns:

The closure of this interval.

Return type:

Interval

Examples

The closure of an OpenClosed interval is a Closed interval.
>>> import splinekit.interval as ivl
>>> ivl.OpenClosed((1.0, 5.0)).closure
Closed((1.0, 5.0))

Notes

The following class has RR() as closure.
  • RR All finite real numbers \({\mathbb{R}}=(-\infty,\infty)\)

The following class has Empty() as closure.
  • Empty The empty interval \(\{x\in{\mathbb{R}}|x\neq x\}=\emptyset\)

The following class has Singleton() as closure.
  • Singleton The degenerate interval \(\{x\in{\mathbb{R}}|x=x_{0}\}=[x_{0},x_{0}]\)

The following classes have an object of class NotBelow as closure.
  • Above The right-unbounded interval \(\{x\in{\mathbb{R}}|x>x_{0}\}=(x_{0},\infty)\)

  • NotBelow The right-unbounded interval \(\{x\in{\mathbb{R}}|x\geq x_{0}\}=[x_{0},\infty)\)

The following classes have an object of class NotAbove as closure.
  • NotAbove The left-unbounded interval \(\{x\in{\mathbb{R}}|x\leq x_{0}\}=(—\infty,x_{0}]\)

  • Below The left-unbounded interval \(\{x\in{\mathbb{R}}|x<x_{0}\}=(—\infty,x_{0})\)

The following classes have an object of class Closed as closure.
  • Open The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x<x_{1}\}=(x_{0},x_{1})\)

  • OpenClosed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x\leq x_{1}\}=(x_{0},x_{1}]\)

  • Closed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x\leq x_{1}\}=[x_{0},x_{1}]\)

  • ClosedOpen The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x<x_{1}\}=[x_{0},x_{1})\)


abstract property diameter: float

The distance between the two endpoints of this interval.

Returns:

The diameter of this interval.

Return type:

float

Examples

Here is the diameter of an OpenClosed interval.
>>> import splinekit.interval as ivl
>>> ivl.OpenClosed((1.0, 5.0)).diameter
4.0

Notes

diameter = float(“nan”) for the following class.
  • Empty The empty interval \(\{x\in{\mathbb{R}}|x\neq x\}=\emptyset\)

diameter = float(“inf”) for the following classes.
  • RR All finite real numbers \({\mathbb{R}}=(-\infty,\infty)\)

  • Above The right-unbounded interval \(\{x\in{\mathbb{R}}|x>x_{0}\}=(x_{0},\infty)\)

  • NotBelow The right-unbounded interval \(\{x\in{\mathbb{R}}|x\geq x_{0}\}=[x_{0},\infty)\)

  • NotAbove The left-unbounded interval \(\{x\in{\mathbb{R}}|x\leq x_{0}\}=(—\infty,x_{0}]\)

  • Below The left-unbounded interval \(\{x\in{\mathbb{R}}|x<x_{0}\}=(—\infty,x_{0})\)

diameter = 0.0 for the following class.
  • Singleton The degenerate interval \(\{x\in{\mathbb{R}}|x=x_{0}\}=[x_{0},x_{0}]\)

math.isfinite(diameter) = True for the following classes.
  • Open The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x<x_{1}\}=(x_{0},x_{1})\)

  • OpenClosed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x\leq x_{1}\}=(x_{0},x_{1}]\)

  • Closed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x\leq x_{1}\}=[x_{0},x_{1}]\)

  • ClosedOpen The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x<x_{1}\}=[x_{0},x_{1})\)


abstract property midpoint: float

The midway point between the two endpoints of this interval.

Returns:

The midpoint of this interval.

Return type:

float

Examples

Here is the midpoint of an OpenClosed interval.
>>> import splinekit.interval as ivl
>>> ivl.OpenClosed((1.0, 5.0)).midpoint
3.0

Notes

midpoint = float(“nan”) for the following classes.
  • RR All finite real numbers \({\mathbb{R}}=(-\infty,\infty)\)

  • Empty The empty interval \(\{x\in{\mathbb{R}}|x\neq x\}=\emptyset\)

  • Above The right-unbounded interval \(\{x\in{\mathbb{R}}|x>x_{0}\}=(x_{0},\infty)\)

  • NotBelow The right-unbounded interval \(\{x\in{\mathbb{R}}|x\geq x_{0}\}=[x_{0},\infty)\)

  • NotAbove The left-unbounded interval \(\{x\in{\mathbb{R}}|x\leq x_{0}\}=(—\infty,x_{0}]\)

  • Below The left-unbounded interval \(\{x\in{\mathbb{R}}|x<x_{0}\}=(—\infty,x_{0})\)

math.isfinite(midpoint) = True for the following classes.
  • Singleton The degenerate interval \(\{x\in{\mathbb{R}}|x=x_{0}\}=[x_{0},x_{0}]\)

  • Open The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x<x_{1}\}=(x_{0},x_{1})\)

  • OpenClosed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x\leq x_{1}\}=(x_{0},x_{1}]\)

  • Closed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x\leq x_{1}\}=[x_{0},x_{1}]\)

  • ClosedOpen The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x<x_{1}\}=[x_{0},x_{1})\)


abstract sortorder() float

Convenience method to sort the intervals. This method is not consistent with equal.

Returns:

A scalar proxy of this interval.

Return type:

float

Notes

sortorder = float(“-inf”) for the following class.
  • Empty The empty interval \(\{x\in{\mathbb{R}}|x\neq x\}=\emptyset\)

sortorder = float(“inf”) for the following class.
  • RR All finite real numbers \({\mathbb{R}}=(-\infty,\infty)\)

sortorder is \(x_{0}\) for the following classes.
  • Singleton The degenerate interval \(\{x\in{\mathbb{R}}|x=x_{0}\}=[x_{0},x_{0}]\)

  • Above The right-unbounded interval \(\{x\in{\mathbb{R}}|x>x_{0}\}=(x_{0},\infty)\)

  • NotBelow The right-unbounded interval \(\{x\in{\mathbb{R}}|x\geq x_{0}\}=[x_{0},\infty)\)

  • NotAbove The left-unbounded interval \(\{x\in{\mathbb{R}}|x\leq x_{0}\}=(—\infty,x_{0}]\)

  • Below The left-unbounded interval \(\{x\in{\mathbb{R}}|x<x_{0}\}=(—\infty,x_{0})\)

sortorder is \(\left(x_{0}+x_{1}\right)/2\) for the following classes.
  • Open The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x<x_{1}\}=(x_{0},x_{1})\)

  • OpenClosed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}<x\leq x_{1}\}=(x_{0},x_{1}]\)

  • Closed The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x\leq x_{1}\}=[x_{0},x_{1}]\)

  • ClosedOpen The bounded interval \(\{x\in{\mathbb{R}}|x_{0}\leq x<x_{1}\}=[x_{0},x_{1})\)


abstract __contains__(x: float) bool

Tests if the number \(x\) is contained in this interval \(U,\) as in \(\left(x\in U\right).\)

Parameters:

x (float) – Real number whose membership is queried.

Returns:

  • False if x is not a member of this interval.

  • True if x is a member of this interval.

Return type:

bool

Examples

Load the library.
>>> import splinekit.interval as ivl
0.0 is in Singleton(0.0).
>>> 0.0 in ivl.Singleton(0.0)
True
float("inf") is not in RR().
>>> float("inf") in ivl.RR()
False

classmethod ismember(x: float, s: Set[Self]) bool

Tests the membership of a real number to a set of intervals.

Parameters:
  • x (float) – Real number whose membership is queried.

  • s (set of Interval) – Set of intervals that are interrogated for the membership of x.

Returns:

  • False if x does not belong to any interval in s.

  • True if x belongs to at least one interval in s.

Return type:

bool

Examples

Load the library.
>>> import splinekit.interval as ivl
Every finite number is a member of RR().
>>> ivl.Interval.ismember(1.0, {ivl.RR()})
True
Infinite numbers do not belong to RR().
>>> ivl.Interval.ismember(float("-inf"), {ivl.RR()})
False

classmethod enclosure(s: Set[Self]) Self

Determines the enclosure (or span) of a set of intervals.

Parameters:

s (set of Interval) – Set of intervals whose enclosure is sought for.

Returns:

The smallest interval that contains the numbers found in s.

Return type:

Interval

Examples

Load the library.
>>> import splinekit.interval as ivl
Here is the enclosure of a pair of bounded intervals.
>>> ivl.Interval.enclosure({ivl.Open((2.0, 3.0)), ivl.Closed((5.0, 8.0))})
OpenClosed([2.0, 8.0])
The enclosure of {RR()} is RR().
>>> ivl.Interval.enclosure({ivl.RR()})
RR()
The enclosure of {Empty()} is Empty().
>>> ivl.Interval.enclosure({ivl.Empty()})
Empty()
The enclosure of an empty set of intervals is Empty().
>>> ivl.Interval.enclosure({})
Empty()

classmethod complement(s: Set[Self]) Set[Self]

Determines the complement (with respect to the real numbers) of a set of intervals.

Parameters:

s (set of Interval) – Set of intervals whose complement is sought for.

Returns:

A set of nonoverlapping intervals that contain every number not found in s.

Return type:

set of Interval

Examples

Load the library.
>>> import splinekit.interval as ivl
Here is the complement of a pair of bounded intervals.
>>> ivl.Interval.complement({ivl.Open((2.0, 3.0)), ivl.Closed((5.0, 8.0))})
{Above(8.0), NotAbove(2.0), ClosedOpen([3.0, 5.0])}
The complement of the set {Empty()} is {RR()}.
>>> ivl.Interval.complement({ivl.Empty()})
{RR()}
The complement of an empty set of intervals is {RR()}.
>>> ivl.Interval.complement({})
{RR()}

classmethod intersection(s: Set[Self]) Self

Determines the intersection of a set of intervals.

Parameters:

s (set of Interval) – Set of intervals whose intersection is sought for.

Returns:

The smallest interval that contains all those numbers found jointly in every interval of s.

Return type:

Interval

Examples

Load the library.
>>> import splinekit.interval as ivl
Here is the intersection of a pair of overlapping intervals.
>>> ivl.Interval.intersection({ivl.Open((2.0, 8.0)), ivl.NotAbove((5.0))})
OpenClosed([2.0, 5.0])
The intersection of an empty set of intervals is {Empty()}.
>>> ivl.Interval.intersection({})
Empty()

classmethod union(s: Set[Self]) Set[Self]

Determines the union of a set of intervals.

Parameters:

s (set of Interval) – Set of intervals whose union is sought for.

Returns:

A set of nonoverlapping intervals that contain every number found in s and that contain no other number.

Return type:

set of Interval

Examples

Load the library.
>>> import splinekit.interval as ivl
Here is the union of a pair of overlapping intervals.
>>> ivl.Interval.union({ivl.Open((2.0, 8.0)), ivl.NotAbove((5.0))})
{Below(8.0)}
The union of the set {Empty()} is {Empty()}.
>>> ivl.Interval.union({ivl.Empty()})
{Empty()}
The union of an empty set of intervals is {Empty()}.
>>> ivl.Interval.union({})
{Empty()}

classmethod gravitycenter(ivls: List[Tuple[Self, float]]) float

Determines the center of gravity of a set of weighted intervals.

Parameters:

ivls (list of tuple (Interval, float)) – List of weighted intervals whose center of gravity is sought for. For nondegenerate intervals, the second member of the tuple gives the density of the interval, in mass per unit length; for Singleton intervals, the second memebr of the tuple gives the pointwise mass.

Returns:

The center of gravity.

Return type:

float

Examples

Load the library.
>>> import splinekit.interval as ivl
Here is the center of gravity of a pair of bounded intervals.
>>> ivl.Interval.gravitycenter([(ivl.Open((2.0, 8.0)), 1.0), (ivl.Singleton(3.0), 6.0)])
4.0
Here is the center of gravity of a balanced trio of unbounded intervals.
>>> ivl.Interval.gravitycenter([(ivl.Below(2.0), 1.0), (ivl.Below(9.0), 3.0), (ivl.Above(8.0), 4.0)])
1.5

Notes

The center of gravity \(g\) is such that \(0=S(g)+U(g)+V(g)+B(g),\) where the contribution of the \(S_{0}\) singletons of value \(x_{k}\) and weight \(w_{k}\) is \(S(g)=\sum_{k=1}^{S_{0}}\,w_{k}\,(x_{k}-g),\) the contribution of the \(U_{0}\) intervals that are not left-bounded, have threshold \(u_{k},\) and have linear density \(\mu_{k}\) is \(U(g)=\sum_{k=1}^{U_{0}}\, \int_{-\infty}^{u_{k}}\,\mu_{k}\,(u-g)\,{\mathrm{d}}u,\) the contribution of the \(V_{0}\) intervals that are not right-bounded, have threshold \(v_{k},\) and have linear density \(\nu_{k}\) is \(V(g)=\sum_{k=1}^{V_{0}}\, \int_{v_{k}}^{\infty}\,\nu_{k}\,(v-g)\,{\mathrm{d}}v,\) and the contribution of the \(B_{0}\) bounded intervals with infimum \(a_{k},\) supremum \(b_{k},\) and linear density \(\rho_{k}\) is \(B(g)=\sum_{k=1}^{B_{0}}\, \int_{a_{k}}^{b_{k}}\,\rho_{k}\,(x-g)\,{\mathrm{d}}x.\)

For intervals such that \(\sum_{k=1}^{U_{0}}\,\mu_{k}=\sum_{k=1}^{V_{0}}\,\nu_{k},\) the system is balanced and a center of gravity generally exists as a real number.

For intervals such that \(\sum_{k=1}^{U_{0}}\,\mu_{k}>\sum_{k=1}^{V_{0}}\,\nu_{k},\) the system is unbalanced and leans to the left. The center of gravity is returned as float("-inf").

For intervals such that \(\sum_{k=1}^{U_{0}}\,\mu_{k}<\sum_{k=1}^{V_{0}}\,\nu_{k},\) the system is unbalanced and leans to the right. The center of gravity is returned as float("inf").

In some cases, the center of gravity will fail to exist at all. If such is the case, float("nan") is returned.


iskissing(other: Self) bool

Tests if this interval self is neighboring the interval other, as in (self & other == Empty()) and (1 == len(union({self, other}))).

Parameters:

other (Interval) – Interval whose vicinity is queried.

Returns:

  • False if this interval is not kissing other.

  • True if this interval is kissing other.

Return type:

bool

Examples

Load the library.
>>> import splinekit.interval as ivl
Here are two kissing intervals.
>>> ivl.Closed((1.0, 3.0)).iskissing(ivl.Above(3.0))
True
Here are two non-kissing intervals.
>>> ivl.Below(0.0).iskissing(ivl.Above(0.0))
False

isoverlapping(other: Self) bool

Tests if this interval self and the interval other share at least one number.

Parameters:

other (Interval) – Interval whose intersection is queried.

Returns:

  • False if this interval is not overlapping other.

  • True if this interval is overlapping other.

Return type:

bool

Examples

Load the library.
>>> import splinekit.interval as ivl
Here are two overlapping intervals.
>>> ivl.Closed((1.0, 3.0)).isoverlapping(ivl.NotBelow(3.0))
True
Here are two non-overlapping intervals.
>>> ivl.Below(0.0).isoverlapping(ivl.Above(0.0))
False

partition(cuts: Set[float]) List[Self]

Creates a list of nonoverlapping intervals whose union is equal to this interval. The created list contains an alternance of open and degenerate intervals, where cuts imposes the values associated to the degenerate Singleton intervals.

Parameters:

cuts (set of float) – Endpoints of the proper intervals of the partition.

Returns:

Kissing intervals that partition this interval.

Return type:

list of Interval

Examples

Here is some partition of a left-unbounded interval. Observe that it

is not required that every element of cuts belong to this interval. >>> import splinekit.interval as ivl >>> ivl.NotAbove(5.0).partition({2.0, 4.0, 6.0}) [Below(2.0), Singleton(2.0), Open((2.0, 4.0)), Singleton(4.0), Open((4.0, 5.0)), Singleton(5.0)]


copy() Self

Creates a copy of this interval.

Returns:

A copy of this interval.

Return type:

Interval

Notes

The classes Empty and RR have a single instance.
>>> import splinekit.interval as ivl
>>> ivl.Empty() is ivl.Empty().copy()
True
>>> ivl.RR() is ivl.RR().copy()
True

__eq__(other: object) bool

Tests if this interval \(U\) is equal to the interval \(V,\) as in \(\left(U=V\right)\Leftrightarrow \left(U\subseteq V\wedge V\subseteq U\right).\)

Parameters:

other (Interval) – Interval whose equality is queried.

Returns:

  • True if this interval and other have all the same members.

  • False otherwise.

Return type:

bool

Examples

Load the library.
>>> import splinekit.interval as ivl
Here are two equal intervals.
>>> ivl.Closed((3.0, 3.0)) == ivl.Singleton(3.0)
True
Here are two different intervals.
>>> ivl.OpenClosed((1.0, 3.0)) == ivl.ClosedOpen((1.0, 3.0))
False

__ne__(other: object) bool

Tests if this interval \(U\) differs from the interval \(V,\) as in \(\left(U\neq V\right)\Leftrightarrow\neg\left(U=V\right).\)

Parameters:

other (Interval) – Interval whose inequality is queried.

Returns:

  • True if this interval and other have all the same members.

  • False otherwise.

Return type:

bool

Examples

Load the library.
>>> import splinekit.interval as ivl
Here are two equal intervals.
>>> ivl.Closed((3.0, 3.0)) != ivl.Singleton(3.0)
False
Here are two different intervals.
>>> ivl.OpenClosed((1.0, 3.0)) != ivl.ClosedOpen((1.0, 3.0))
True

__lt__(other: Self) bool

< Proper subset: \(\subset\)

Tests if this interval \(U\) is a proper subset of the interval \(V,\) as in \(\left(U\subset V\right)\Leftrightarrow \left(U\subseteq V\wedge U\neq V\right).\)

Parameters:

other (Interval) – Interval that may or may not be a proper superset of this interval.

Returns:

  • False if this interval is not a proper subset of other.

  • True if this interval is a proper subset of other.

Return type:

bool

Examples

Load the library.
>>> import splinekit.interval as ivl
The positive numbers form a proper subset of the nonnegative numbers.
>>> ivl.Above(0.0) < ivl.NotBelow(0.0)
True
The empty interval is a proper subset of every interval except itself.
>>> ivl.Empty() < ivl.Empty()
False

__le__(other: Self) bool

<= Subset: \(\subseteq\)

Tests if this interval \(U\) is a subset of the interval \(V,\) as in \(\left(U\subseteq V\right)\Leftrightarrow \left(\forall x\in U:x\in V\right).\)

Parameters:

other (Interval) – Interval that may or may not be a superset of this interval.

Returns:

  • False if this interval is not a subset of other.

  • True if this interval is a subset of other.

Return type:

bool

Examples

The empty interval is a subset of every interval, including itself.
>>> import splinekit.interval as ivl
>>> ivl.Empty() <= ivl.Empty()
True

__neg__() Set[Self]

- Unary complement in RR(): \((\cdot)^{{\mathrm{c}}}\)

Creates a set of mutually nonoverlapping intervals that contain every real number except those found in this interval \(U,\) as in \(U^{{\mathrm{c}}}:=\{x\in{\mathbb{R}}|x\not\in U\}.\)

Returns:

The complement in RR() to this interval.

Return type:

set of Interval

Examples

The complement of the negative numbers is the nonnegative numbers.
>>> import splinekit.interval as ivl
>>> -ivl.Below(0.0)
{NotBelow(0.0)}

__sub__(other: Self) Set[Self]

- Pairwise difference: \(\setminus\)

Creates a set of nonoverlapping intervals that contains all elements of this interval \(U\) except those of the interval \(V,\) as in \(U\setminus V:=\{x\in U|x\not\in V\}.\)

Parameters:

other (Interval) – The interval been removed from this interval.

Returns:

The pairwise difference between this interval and other.

Return type:

set of Interval

Examples

The pairwise difference between the nonnegative numbers and the positive numbers is a single number.
>>> import splinekit.interval as ivl
>>> ivl.NotBelow(0.0) - ivl.Above(0.0)
{Singleton(0.0)}

__and__(other: Self) Self

& Intersection: \(\cap\)

Creates an interval that contains every element that is a member of both this interval \(U\) and the interval \(V,\) as in \(U\cap V:=\{x\in U|x\in V\}.\)

Parameters:

other (Interval) – The interval whose intersection with this interval is sought for.

Returns:

The intersection between this interval and other.

Return type:

Interval

Examples

The intersection between the negative numbers and the positive numbers is empty.
>>> import splinekit.interval as ivl
>>> ivl.Below(0.0) & ivl.Above(0.0)
Empty()

__or__(other: Self) Set[Self]

| Union: \(\cup\)

Creates a set of nonoverlapping intervals that contains all elements of this interval \(U\) and all elements of the the interval \(V,\) as in \(U\cup V:=\{x\in{\mathbb{R}}|x\in U\vee x\in V\}.\)

Parameters:

other (Interval) – The interval whose union with this interval is sought for.

Returns:

The union between this interval and other.

Return type:

set of Interval

Examples

The nonnegative numbers result from the union between the number 0.0 and the positive numbers.
>>> import splinekit.interval as ivl
>>> ivl.Singleton(0.0) | ivl.Above(0.0)
{NotBelow(0.0)}

__xor__(other: Self) Set[Self]

^ Symmetric difference: \(\Delta\)

Creates a set of nonoverlapping intervals that contains the elements that belong either to this interval \(U\) or to the interval \(V,\) as in \(U\Delta V:=\left(U\setminus V\right)\cup \left(V\setminus U\right).\)

Parameters:

other (Interval) – The interval whose symmetric difference with this interval is sought for.

Returns:

The symmetric difference between this interval and other.

Return type:

set of Interval

Examples

Here is the symmetric difference between two bounded intervals.
>>> import splinekit.interval as ivl
>>> ivl.Closed((-3.0, 1.0)) ^ ivl.Closed((-1.0, 3.0))
{OpenClosed((1.0, 3.0)), ClosedOpen((-3.0, -1.0))}