I would rather suggest .is_integer(integer_dtype) signature because knowing 
that 1e300 is an integer is not very useful in the numpy world, since this 
integer number is not representable as a numpy.integer dtype.

Note that in python 

assert not f.is_integer() or int(f) == f

never fails because integers have unlimited precision but this does would not 
map into

assert ( ~f_arr.is_integer() | (np.int64(f_arr) == f.arr) ).all()

because of possible OverflowErrors.

Stefano

> On 31 Dec 2021, at 04:46, numpy-discussion-requ...@python.org wrote:
> 
> Is adding arbitrary optional parameters a thing with ufuncs? I could easily 
> add upper and lower bounds checks.
> 
> On Thu, Dec 30, 2021, 20:56 Brock Mendel <jbrockmen...@gmail.com 
> <mailto:jbrockmen...@gmail.com>> wrote:
> At least some of the commenters on that StackOverflow page need a slightly 
> stronger check: not only is_integer(x), but also "np.iinfo(dtype).min <= x <= 
> np.info <http://np.info/>(dtype).max" for some particular dtype.  i.e. "Can I 
> losslessly set these values into the array I already have?"
> 
> 
> 

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com

Reply via email to