[Numpy-discussion] PR adding support for object arrays to np.isinf, np.isnan, np.isfinite

Joseph Fox-Rabinovitz jfoxrabinovitz at gmail.com
Thu Mar 29 02:31:22 EDT 2018


I have opened PR #10820 to add support for `dtype=object` to
`np.isinf`, `np.isnan`, `np.isfinite`. The PR is a fairly minor
change, but I would like to make sure that I understand at least the
basics of ufuncs before I start adding support for datetimes and
timedeltas to `np.isfinite` and eventually to `np.histogram`. I have
left a few comments in areas I am not sure about, and would greatly
appreciate feedback, even if the PR is not found suitable for merging.

With this PR, object arrays containing any numerical or simulated
numerical types (implementing `__float__` or `__complex__` methods)
are processed as would be expected. While working on PR, I came up
with two questions for the gurus:

1. Am I correct in understanding that `isinf`, `isnan` and `isfinite`
currently cast integer inputs to float to process them? Why are
integer inputs not optimized to return arrays of all False, False,
True, respectively for those functions?

2. Why are `isneginf` and `isposinf` not ufuncs? Is there any reason
not to make them ufuncs (besides the renaming of the `y` parameter to
`out`, which technically breaks some backward compatibility)?

Regards,

- Joe


More information about the NumPy-Discussion mailing list