pyuncertainnumber.pba.intervals.number

:####################################################### : Intervals Library originally created by Marco de Angelis : Continuesly developed and refactored by Leslie Yu Chen :#######################################################

Attributes

Classes

Interval

Interval is the main class

LightweightInterval

Interval is the main class

Functions

show(→ str)

is_Interval(→ bool)

interval_degenerate(vec_interval)

lo(→ Union[float, numpy.ndarray])

Return the left endpoint of an Interval object.

hi(→ Union[float, numpy.ndarray])

Return the right endpoint of an Interval object.

width(→ Union[float, numpy.ndarray])

Return the width of an Interval object.

rad(→ Union[float, numpy.ndarray])

Return the radius of an Interval object.

mid(→ Union[float, numpy.ndarray])

Return the midpoint of an Interval.

mig(x)

mag(x)

Module Contents

pyuncertainnumber.pba.intervals.number.MACHINE_EPS = 2.220446049250313e-16
pyuncertainnumber.pba.intervals.number.NUMERIC_TYPES
pyuncertainnumber.pba.intervals.number.INTEGERS
pyuncertainnumber.pba.intervals.number.show(x: Interval) str
class pyuncertainnumber.pba.intervals.number.Interval(lo: float | numpy.ndarray, hi: float | numpy.ndarray | None = None, do_heavy_checks: bool = True)

Bases: pyuncertainnumber.pba.mixins.NominalValueMixin

Interval is the main class

_lo
_hi = None
run_heavy_checks()

Run heavy checks on the interval object

__repr__()
__str__()
__len__()
__iter__()
__contains__(item)

Check if an item is enclosed within the interval.

Example

>>> i = Interval(1,3)
>>> 2 in i
True
>>> 4 in i
False
__next__()
__getitem__(i: int | slice)
to_numpy() numpy.ndarray

transform interval objects to numpy arrays

to_pbox()
lhs_sample(n) numpy.ndarray

LHS sampling within the interval

Parameters:

n – number of samples

endpoints_lhs_sample(n) numpy.ndarray

LHS sampling within the interval plus the endpoints

Parameters:

n – number of samples

plot(ax=None, **kwargs)
display()
is_degenerate() bool

Check if the interval is degenerate (i.e., has zero width).

_compute_nominal_value()
ravel()

Return a flattened (1D) interval object for multi-dimensional intervals

Example

>>> A = np.random.rand(200, 200, 2)
>>> i = pba.intervalise(A)
>>> print(i.shape)
>>> i2 = i.ravel()
>>> print(i2.shape)
property lo: numpy.ndarray | float
property hi: numpy.ndarray | float
property left
property right
property width
property rad

half width

property mid
property unsized
property val

seemingly equivalent to self.to_numpy()

property scalar

Check if the interval is wide sense scalar

Note

wide sense: I(1,2) and I([1],[2]) are both scalars

property is_scalar

Check if the interval is a strict-sense scalar

Note

strict sense: I(1,2) is a scalar, but I([1],[2]) is not

property shape
property ndim
__neg__()
__pos__()
__add__(other)
__radd__(left)
__sub__(other)
__rsub__(left)
__mul__(other)
__rmul__(left)
__truediv__(other)
__rtruediv__(left)
__pow__(other)
__lt__(other)
__rlt__(left)
__gt__(other)
__rgt__(left)
__le__(other)
__rle__(left)
__ge__(other)
__rge__(left)
__eq__(other)
__ne__(other)
__array_ufunc__(ufunc, method, *inputs, **kwargs)
abs()
sqrt()
exp()
log()
sin()
cos()
tan()
classmethod from_meanform(x, half_width)
save_json(filename: str, comment: str = None, save_dir: str | pathlib.Path = '.') None

Save the interval object to a JSON5 file.

Parameters:
  • filename (str) – The name of the file (without extension) to save the interval object to.

  • comment (str, optional) – A comment to include at the top of the file.

  • save_dir (str | Path, optional) – Directory where the file should be saved. Defaults to current directory.

Note

The file is saved with a .json5 extension.

Example

>>> a.save_json("interval_data", comment="This is interval data", save_dir="results/")
class pyuncertainnumber.pba.intervals.number.LightweightInterval(lo, hi=None)

Bases: Interval

Interval is the main class

__repr__()
property lo: numpy.ndarray | float
property hi: numpy.ndarray | float
pyuncertainnumber.pba.intervals.number.is_Interval(x: Any) bool
pyuncertainnumber.pba.intervals.number.interval_degenerate(vec_interval)
pyuncertainnumber.pba.intervals.number.lo(x: Interval) float | numpy.ndarray

Return the left endpoint of an Interval object.

If x is not of class Interval, input is returned.

pyuncertainnumber.pba.intervals.number.hi(x: Interval) float | numpy.ndarray

Return the right endpoint of an Interval object.

If x is not of class Interval, input is returned.

pyuncertainnumber.pba.intervals.number.width(x: Interval) float | numpy.ndarray

Return the width of an Interval object.

If x is not of class Interval, input is returned.

pyuncertainnumber.pba.intervals.number.rad(x: Interval) float | numpy.ndarray

Return the radius of an Interval object.

If x is not of class Interval, input is returned.

pyuncertainnumber.pba.intervals.number.mid(x: Interval) float | numpy.ndarray

Return the midpoint of an Interval.

If x is not of class Interval, input is returned.

pyuncertainnumber.pba.intervals.number.mig(x)
pyuncertainnumber.pba.intervals.number.mag(x)