diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2016-02-19 09:17:55 -0700 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2016-02-19 09:25:49 -0700 |
commit | 542c88b8e10d4d7b9d80b31bb2f971b7e6d4cdb4 (patch) | |
tree | 55690acb1e3a0f3577ceaae9c918ebe6aa4199ac | |
parent | e8302fd038147f4689ae021d3b5c1a02f2a8cd76 (diff) | |
download | numpy-542c88b8e10d4d7b9d80b31bb2f971b7e6d4cdb4.tar.gz |
DOC: Document that floor_divide and remainder are complementary.
The floor_divide (//) and remainder (%) functions are complementary
in the sense that a ~= (a % b) + (a // b).
-rw-r--r-- | numpy/core/code_generators/ufunc_docstrings.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/numpy/core/code_generators/ufunc_docstrings.py b/numpy/core/code_generators/ufunc_docstrings.py index e3600406c..a017ca26d 100644 --- a/numpy/core/code_generators/ufunc_docstrings.py +++ b/numpy/core/code_generators/ufunc_docstrings.py @@ -1225,8 +1225,10 @@ add_newdoc('numpy.core.umath', 'floor', add_newdoc('numpy.core.umath', 'floor_divide', """ - Return the largest integer smaller or equal to the division of the - inputs. + Return the largest integer smaller or equal to the division of the inputs. + It is equivalent to the Python ``//`` operator and pairs with the + Python ``%`` (`remainder`), function so that ``b = a % b + b * (a // b)`` + up to roundoff. Parameters ---------- @@ -1243,6 +1245,7 @@ add_newdoc('numpy.core.umath', 'floor_divide', See Also -------- + remainder : Remainder complementary to floor_divide. divide : Standard division. floor : Round a number to the nearest integer toward minus infinity. ceil : Round a number to the nearest integer toward infinity. @@ -2689,9 +2692,9 @@ add_newdoc('numpy.core.umath', 'remainder', """ Return element-wise remainder of division. - Computes ``x1 - floor(x1 / x2) * x2``, the result has the same sign as - the divisor `x2`. It is equivalent to the Python modulus operator - ``x1 % x2`` and should not be confused with the Matlab(TM) ``rem`` + Computes the remainder complementary to the `floor_divide` function. It is + equivalent to the Python modulus operator``x1 % x2`` and has the same sign + as the divisor `x2`. It should not be confused with the Matlab(TM) ``rem`` function. Parameters @@ -2707,11 +2710,12 @@ add_newdoc('numpy.core.umath', 'remainder', Returns ------- y : ndarray - The remainder of the quotient ``x1/x2``, element-wise. Returns a - scalar if both `x1` and `x2` are scalars. + The element-wise remainder of the quotient ``floor_divide(x1, x2)``. + Returns a scalar if both `x1` and `x2` are scalars. See Also -------- + floor_divide : Equivalent of Python ``//`` operator. fmod : Equivalent of the Matlab(TM) ``rem`` function. divide, floor |