Interval

class hmf.core.domain.Interval(lower: float | None, upper: float | None, unit: UnitBase | None = None)[source]

A closed interval [lower, upper] of one variable.

Parameters:
  • lower (float) – The lower bound, inclusive. -inf (or None) for no lower bound.

  • upper (float) – The upper bound, inclusive. inf (or None) for no upper bound.

  • unit (astropy.units.core.UnitBase | None) – The unit of the bounds, for a dimensional variable; None if the variable is dimensionless.

Attributes

Methods

contains(x: Any, *, name: str = 'value') → bool | ndarray[tuple[Any, ...], dtype[bool]][source]

Whether x lies within the interval (bounds included).

Parameters:
  • x – A float or array; a Quantity if the interval has a unit.

  • name – The variable’s name, for error messages.

Returns:

False for NaN.

Return type:

bool or numpy.ndarray of bool