where#
- bamengine.ops.where(condition, true_val, false_val)[source]#
Vectorized if-then-else (ternary operator).
- Parameters:
- Returns:
Selected values based on condition.
- Return type:
Examples
>>> import bamengine.ops as ops >>> # Discount price if inventory > 0, premium otherwise >>> inventory = np.array([10, 0, 5]) >>> base_price = np.array([100, 100, 100]) >>> price = ops.where( ... inventory > 0, ... base_price * 0.95, # 5% discount ... base_price * 1.05, # 5% premium ... ) >>> # price: [95, 105, 95]