divmod

Contents

divmod#

class saiunit.math.divmod(x, y, **kwargs)#

Return element-wise quotient and remainder simultaneously.

Equivalent to (x // y, x % y), but faster because it avoids redundant work. The quotient carries unit x.unit / y.unit and the remainder carries x.unit.

Parameters:
  • x (saiunit.Quantity | Array | ndarray | bool | number | bool | int | float | complex) – Dividend array.

  • y (saiunit.Quantity | Array | ndarray | bool | number | bool | int | float | complex) – Divisor array. If x.shape != y.shape, they must be broadcastable to a common shape.

Return type:

Tuple[saiunit.Quantity | Array | ndarray | bool | number | bool | int | float | complex, saiunit.Quantity | Array | ndarray | bool | number | bool | int | float | complex]

Returns:

  • out1 (ndarray or Quantity) – Element-wise quotient resulting from floor division. Unit is x.unit / y.unit.

  • out2 (ndarray or Quantity) – Element-wise remainder from floor division. Unit is x.unit.

Examples

>>> import saiunit as u
>>> a = u.math.array([7.0, 9.0]) * u.meter
>>> b = u.math.array([2.0, 4.0]) * u.second
>>> quotient, remainder = u.math.divmod(a, b)