diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2019-04-19 17:57:18 -0700 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2019-04-19 18:18:12 -0700 |
commit | 55c7ed2c6822b5a5b30db7472c863dc1fa0c338f (patch) | |
tree | e62d7d73229a2959bc9f8b16061631d39c072717 /doc/release | |
parent | 8f31f95910d27da75941bbbbde7ef1ecec9b0f74 (diff) | |
download | numpy-55c7ed2c6822b5a5b30db7472c863dc1fa0c338f.tar.gz |
BUG/ENH: Make floor, ceil, and trunc call the matching special methods
Previously `np.ceil` would call `o.ceil()` on each element of an object array.
This is inconsistent with the builtin python way of handling this, calling `o.__ceil__()`.
This changes these three functions to use the corresponding functions in the `math` module, which do the special method lookup.
As a result, they now work on arrays of `Fraction` and `Decimal` objects.
Diffstat (limited to 'doc/release')
-rw-r--r-- | doc/release/1.17.0-notes.rst | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/doc/release/1.17.0-notes.rst b/doc/release/1.17.0-notes.rst index 893ec9b45..47adb4efc 100644 --- a/doc/release/1.17.0-notes.rst +++ b/doc/release/1.17.0-notes.rst @@ -208,6 +208,12 @@ New keywords added to ``np.nan_to_num`` user to define the value to replace the ``nan``, positive and negative ``np.inf`` values respectively. +`floor`, `ceil`, and `trunc` now respect builtin magic methods +-------------------------------------------------------------- +These ufuncs now call the ``__floor__``, ``__ceil__``, and ``__trunc__`` +methods when called on object arrays, making them compatible with +`decimal.Decimal` and `fractions.Fraction` objects. + Changes ======= |