Hi, Le 14/01/2013 20:17, Alan G Isaac a écrit : > >>> a = np.tile(5,(1,2,3)) > >>> a > array([[[5, 5, 5], > [5, 5, 5]]]) > >>> np.tile(1,a.shape) > array([[[1, 1, 1], > [1, 1, 1]]]) > > I had not realized a scalar first argument was possible. I didn't know either ! I discovered this use in the thread of this discussion. Just like Ben, I've almost never used "np.tile" neither its cousin "np.repeat"...
Now, in the process of rediscovering those two functions, I was just wondering whether it would make sense to repackage them in order to allow the simple functionality of initializing a non-empty array. In term of choosing the name (or actually the verb), I prefer "repeat" because it's a more familiar concept than "tile". However, repeat may need more changes to make it work than tile. Indeed we currently have : >>> tile(nan, (3,3)) # works fine, but is pretty slow for that purpose, And doesn't accept a dtype arg array([[ nan, nan, nan], [ nan, nan, nan], [ nan, nan, nan]]) Doesn't work for that purpose: >>>repeat(nan, (3,3)) [...] ValueError: a.shape[axis] != len(repeats) So what people think of this "green" approach of recycling existing API into a slightly different function (without breaking current behavior of course) Best, Pierre
signature.asc
Description: OpenPGP digital signature
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion