pyuncertainnumber.pba.intervals.number ====================================== .. py:module:: pyuncertainnumber.pba.intervals.number .. autoapi-nested-parse:: :####################################################### : Intervals Library originally created by Marco de Angelis : Continuesly developed and refactored by Leslie Yu Chen :####################################################### Attributes ---------- .. autoapisummary:: pyuncertainnumber.pba.intervals.number.MACHINE_EPS pyuncertainnumber.pba.intervals.number.NUMERIC_TYPES pyuncertainnumber.pba.intervals.number.INTEGERS Classes ------- .. autoapisummary:: pyuncertainnumber.pba.intervals.number.Interval pyuncertainnumber.pba.intervals.number.LightweightInterval Functions --------- .. autoapisummary:: pyuncertainnumber.pba.intervals.number.show pyuncertainnumber.pba.intervals.number.is_Interval pyuncertainnumber.pba.intervals.number.interval_degenerate pyuncertainnumber.pba.intervals.number.lo pyuncertainnumber.pba.intervals.number.hi pyuncertainnumber.pba.intervals.number.width pyuncertainnumber.pba.intervals.number.rad pyuncertainnumber.pba.intervals.number.mid pyuncertainnumber.pba.intervals.number.mig pyuncertainnumber.pba.intervals.number.mag Module Contents --------------- .. py:data:: MACHINE_EPS :value: 2.220446049250313e-16 .. py:data:: NUMERIC_TYPES .. py:data:: INTEGERS .. py:function:: show(x: Interval) -> str .. py:class:: Interval(lo: Union[float, numpy.ndarray], hi: Optional[Union[float, numpy.ndarray]] = None, do_heavy_checks: bool = True) Bases: :py:obj:`pyuncertainnumber.pba.mixins.NominalValueMixin` Interval is the main class .. py:attribute:: _lo .. py:attribute:: _hi :value: None .. py:method:: run_heavy_checks() Run heavy checks on the interval object .. py:method:: __repr__() .. py:method:: __str__() .. py:method:: __len__() .. py:method:: __iter__() .. py:method:: __contains__(item) Check if an item is enclosed within the interval. .. rubric:: Example >>> i = Interval(1,3) >>> 2 in i True >>> 4 in i False .. py:method:: __next__() .. py:method:: __getitem__(i: Union[int, slice]) .. py:method:: to_numpy() -> numpy.ndarray transform interval objects to numpy arrays .. py:method:: to_pbox() .. py:method:: lhs_sample(n) -> numpy.ndarray LHS sampling within the interval :param n: number of samples .. py:method:: endpoints_lhs_sample(n) -> numpy.ndarray LHS sampling within the interval plus the endpoints :param n: number of samples .. py:method:: plot(ax=None, **kwargs) .. py:method:: display() .. py:method:: is_degenerate() -> bool Check if the interval is degenerate (i.e., has zero width). .. py:method:: _compute_nominal_value() .. py:method:: ravel() Return a flattened (1D) interval object for multi-dimensional intervals .. rubric:: Example >>> A = np.random.rand(200, 200, 2) >>> i = pba.intervalise(A) >>> print(i.shape) >>> i2 = i.ravel() >>> print(i2.shape) .. py:property:: lo :type: Union[numpy.ndarray, float] .. py:property:: hi :type: Union[numpy.ndarray, float] .. py:property:: left .. py:property:: right .. py:property:: width .. py:property:: rad half width .. py:property:: mid .. py:property:: unsized .. py:property:: val seemingly equivalent to `self.to_numpy()` .. py:property:: scalar Check if the interval is wide sense scalar .. note:: wide sense: I(1,2) and I([1],[2]) are both scalars .. py: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 .. py:property:: shape .. py:property:: ndim .. py:method:: __neg__() .. py:method:: __pos__() .. py:method:: __add__(other) .. py:method:: __radd__(left) .. py:method:: __sub__(other) .. py:method:: __rsub__(left) .. py:method:: __mul__(other) .. py:method:: __rmul__(left) .. py:method:: __truediv__(other) .. py:method:: __rtruediv__(left) .. py:method:: __pow__(other) .. py:method:: __lt__(other) .. py:method:: __rlt__(left) .. py:method:: __gt__(other) .. py:method:: __rgt__(left) .. py:method:: __le__(other) .. py:method:: __rle__(left) .. py:method:: __ge__(other) .. py:method:: __rge__(left) .. py:method:: __eq__(other) .. py:method:: __ne__(other) .. py:method:: __array_ufunc__(ufunc, method, *inputs, **kwargs) .. py:method:: abs() .. py:method:: sqrt() .. py:method:: exp() .. py:method:: log() .. py:method:: sin() .. py:method:: cos() .. py:method:: tan() .. py:method:: from_meanform(x, half_width) :classmethod: .. py:method:: save_json(filename: str, comment: str = None, save_dir: str | pathlib.Path = '.') -> None Save the interval object to a JSON5 file. :param filename: The name of the file (without extension) to save the interval object to. :type filename: str :param comment: A comment to include at the top of the file. :type comment: str, optional :param save_dir: Directory where the file should be saved. Defaults to current directory. :type save_dir: str | Path, optional .. note:: The file is saved with a `.json5` extension. .. rubric:: Example >>> a.save_json("interval_data", comment="This is interval data", save_dir="results/") .. py:class:: LightweightInterval(lo, hi=None) Bases: :py:obj:`Interval` Interval is the main class .. py:method:: __repr__() .. py:property:: lo :type: Union[numpy.ndarray, float] .. py:property:: hi :type: Union[numpy.ndarray, float] .. py:function:: is_Interval(x: Any) -> bool .. py:function:: interval_degenerate(vec_interval) .. py:function:: lo(x: Interval) -> Union[float, numpy.ndarray] Return the left endpoint of an Interval object. If x is not of class Interval, input is returned. .. py:function:: hi(x: Interval) -> Union[float, numpy.ndarray] Return the right endpoint of an Interval object. If x is not of class Interval, input is returned. .. py:function:: width(x: Interval) -> Union[float, numpy.ndarray] Return the width of an Interval object. If x is not of class Interval, input is returned. .. py:function:: rad(x: Interval) -> Union[float, numpy.ndarray] Return the radius of an Interval object. If x is not of class Interval, input is returned. .. py:function:: mid(x: Interval) -> Union[float, numpy.ndarray] Return the midpoint of an Interval. If x is not of class Interval, input is returned. .. py:function:: mig(x) .. py:function:: mag(x)