Thanks to visit codestin.com
Credit goes to github.com

Skip to content

np.ceil and np.floor are inconsistent with math.ceil and math.floor #9068

Open
@eric-wieser

Description

@eric-wieser

In Python 3, floor and ceil changed to return integers, rather than floats:

>>> math.floor(1.5), math.ceil(1.5)
(1, 2)
>>> np.floor(1.5), np.ceil(1.5)
(1.0, 2.0)   # also the output for the first case on 2.7

Should we update these function in numpy to also return integer types?

I think the deprecation path would be

  • add f->i loops to the ufunc, so that np.floor(1.5, dtype=int) is possible
  • on python 3, start FutureWarning on np.floor(1.5) with no dtype
  • on python 3, switch the default dtype to int

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions