Hi all,

I'm wondering if you think the following behavior in numpy.clip is a bug
(it certainly confused me for a while):
>>> x = np.arange(5.)
>>> xx = x.clip(None,3.)
>>> xx
array([0.0, 1.0, 2.0, 3.0, 3.0], dtype=object)
Since xx now has the dtype of object, doing things like
>>> np.exp(xx)
AttributeError                            Traceback (most recent call
last)
<ipython-input-6-30aa315cc2b1> in <module>()
----> 1 np.exp(xx)
Which, if you don't know about the change in the dtype is a very
confusing error message.  It seems to me that either clip should give an
error message when None is given for the a_min argument or, better,
should not change the dtype of the input array as it does.  This comes
up because I want to only clip the maximum.  Of course you can clip the
minimum by simply omitting the second argument.  The asymmetry of this
is not good, I think.  I suppose that using the maximum function is
better in this situation (as I recently found out), though the docs make
it seem that one needs to supply two arrays -- even though you don't.

Jon
-- 
______________________________________________________________
Jonathan D. Slavin              Harvard-Smithsonian CfA
jsla...@cfa.harvard.edu         60 Garden Street, MS 83
phone: (617) 496-7981           Cambridge, MA 02138-1516
 cell: (781) 363-0035           USA
______________________________________________________________

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to