Between(low, high, bounds=Bounds.INCLUDED)
Source¶
Bases: Rule
Keep the values inside an interval.
Changed in version 0.2.0
Accepts Arrays as bounds, each value having the bounds at its position.
Version history (1)
Added in version 0.1.0
Parameters:
-
low(OrderedValue | Array)Low bound of the interval, an
OrderedValuesuch as10,"A"ordate(2026, 1, 1). Or an Array of the shape of the tested values, one value per row for a Table column, giving each value its own low bound. -
high(OrderedValue | Array)High bound of the interval, an
OrderedValuesuch as20,"M"ordate(2026, 12, 31), greater than or equal tolowand of a comparable kind. Or an Array, aslow. A value whose low or high bound is missing is not inside the interval. -
bounds(Bounds, default:Bounds.INCLUDED)Which bounds are part of the interval. Both are included by default.
Raises:
-
InvalidTypeErrorWhen a setting is not of the type its annotation names.
-
InvalidBoundsErrorWhen
lowis greater thanhigh, or when they cannot be compared, such as a number and a text, or a date and a datetime. With bounds given by Arrays, when the rule is used, at the first position whose low bound is greater than its high bound.
Examples:
import numdaplot as ndp
ages = ndp.Array.from_list([8, 10, 15, 20, 31])
ages.select(ndp.Between(low=10, high=20))
# Array([10, 15, 20], dtype=INT64)
ages.select(ndp.Between(low=10, high=20, bounds=ndp.Bounds.EXCLUDED))
# Array([15], dtype=INT64)
temperatures = ndp.Array.from_list([18.0, 25.0, 15.0])
lows = ndp.Array.from_list([10.0, 10.0, None])
highs = ndp.Array.from_list([20.0, 20.0, 20.0])
temperatures.check(ndp.Between(lows, highs))
# Array([ True, False, False], dtype=BOOL)