Le mardi 8 janvier 2013, Andrew Collette a écrit : > Hi Dag, > > > So you are saying that, for an array x, you want > > > > x + random.randint(100000) > > > > to produce an array with a random dtype? > > Under the proposed behavior, depending on the dtype of x and the value > from random, this would sometimes add-with-rollover and sometimes > raise ValueError. > > Under the 1.5 behavior, it would always add-with-rollover and preserve > the type of x. > > Under the 1.6 behavior, it produces a range of dtypes, each of which > is at least large enough to hold the random int. > > Personally, I prefer the third option, but I strongly prefer either > the second or the third to the first. > > Andrew >
Keep in mind that in the third option (current 1.6 behavior) the dtype is large enough to hold the random number, but not necessarily to hold the result. So for instance if x is an int16 array with only positive values, the result of this addition may contain negative values (or not, depending on the number being drawn). That's the part I feel is flawed with this behavior, it is quite unpredictable. -=- Olivier
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion