[Numpy-discussion] upsample or scale an array

2011-12-03 Thread Robin Kraft
Thanks Warren, this is great, and even handles giant arrays just fine if you've got enough RAM. I also just found this StackOverflow post with another solution. a.repeat(2, axis=0).repeat(2, axis=1). http://stackoverflow.com/questions/7525214/how-to-scale-a-numpy-array np.kron lets you do

Re: [Numpy-discussion] upsample or scale an array

2011-12-03 Thread Olivier Delalleau
You can also use numpy.tile -=- Olivier 2011/12/3 Robin Kraft rkra...@gmail.com Thanks Warren, this is great, and even handles giant arrays just fine if you've got enough RAM. I also just found this StackOverflow post with another solution. a.repeat(2, axis=0).repeat(2, axis=1).

Re: [Numpy-discussion] upsample or scale an array

2011-12-03 Thread Robin Kraft
That does repeat the elements, but doesn't get them into the desired order. In [4]: print a [[1 2] [3 4]] In [7]: np.tile(a, 4) Out[7]: array([[1, 2, 1, 2, 1, 2, 1, 2], [3, 4, 3, 4, 3, 4, 3, 4]]) In [8]: np.tile(a, 4).reshape(4,4) Out[8]: array([[1, 2, 1, 2], [1, 2, 1, 2],

Re: [Numpy-discussion] upsample or scale an array

2011-12-03 Thread Olivier Delalleau
Ah sorry, I hadn't read carefully enough what you were trying to achieve. I think the double repeat solution looks like your best option then. -=- Olivier 2011/12/3 Robin Kraft rkra...@gmail.com That does repeat the elements, but doesn't get them into the desired order. In [4]: print a [[1

Re: [Numpy-discussion] upsample or scale an array

2011-12-03 Thread Derek Homeier
On 03.12.2011, at 6:22PM, Robin Kraft wrote: That does repeat the elements, but doesn't get them into the desired order. In [4]: print a [[1 2] [3 4]] In [7]: np.tile(a, 4) Out[7]: array([[1, 2, 1, 2, 1, 2, 1, 2], [3, 4, 3, 4, 3, 4, 3, 4]]) In [8]: np.tile(a,

Re: [Numpy-discussion] upsample or scale an array

2011-12-03 Thread Derek Homeier
On 03.12.2011, at 6:47PM, Olivier Delalleau wrote: Ah sorry, I hadn't read carefully enough what you were trying to achieve. I think the double repeat solution looks like your best option then. Considering that it is a lot shorter than fixing the tile() result, you are probably right (I've

Re: [Numpy-discussion] upsample or scale an array

2011-12-03 Thread Robin Kraft
Ha! I knew it had to be possible! Thanks Derek. So for and N = 2 (now on my laptop): In [70]: M = 1200 In [69]: N = 2 In [71]: a = np.random.randint(0, 255, (M**2)).reshape(M,-1) In [76]: timeit np.rollaxis(np.tile(a, N**2).reshape(M,N,-1), 2, 1).reshape(M*N,-1) 10 loops, best of 3: 99.1 ms

[Numpy-discussion] bug in PyArray_GetCastFunc

2011-12-03 Thread Geoffrey Irving
When attempting to cast to a user defined type, PyArray_GetCast looks up the cast function in the dictionary but doesn't check if the entry exists. This causes segfaults. Here's a patch. Geoffrey diff --git a/numpy/core/src/multiarray/convert_datatype.c

[Numpy-discussion] NumPy Governance

2011-12-03 Thread Travis Oliphant
Hi everyone, There have been some wonderfully vigorous discussions over the past few months that have made it clear that we need some clarity about how decisions will be made in the NumPy community. When we were a smaller bunch of people it seemed easier to come to an agreement and

[Numpy-discussion] failure to register ufunc loops for user defined types

2011-12-03 Thread Geoffrey Irving
Hello, I'm trying to add a fixed precision rational number dtype to numpy, and am running into an issue trying to register ufunc loops. The code in question looks like int npy_rational = PyArray_RegisterDataType(rational_descr); PyObject* equal = ... // extract equal object from the

Re: [Numpy-discussion] NumPy Governance

2011-12-03 Thread Matthew Brett
Hi Travis, On Sat, Dec 3, 2011 at 6:18 PM, Travis Oliphant teoliph...@gmail.com wrote: Hi everyone, There have been some wonderfully vigorous discussions over the past few months that have made it clear that we need some clarity about how decisions will be made in the NumPy community.

Re: [Numpy-discussion] NumPy Governance

2011-12-03 Thread Travis Oliphant
I like the idea of trying to reach consensus first. The only point of having a board is to have someway to resolve issues should consensus not be reachable. Believe me, I'm not that excited about a separate mailing list. It would be great if we could resolve everything on a single

[Numpy-discussion] Convert datetime64 to python datetime.datetime in numpy 1.6.1?

2011-12-03 Thread Warren Weckesser
In numpy 1.6.1, what's the most straightforward way to convert a datetime64 to a python datetime.datetime? E.g. I have In [1]: d = datetime64(2011-12-03 12:34:56.75) In [2]: d Out[2]: 2011-12-03 12:34:56.75 I want the same time as a datetime.datetime instance. My best hack so far is to

Re: [Numpy-discussion] NumPy Governance

2011-12-03 Thread Charles R Harris
On Sat, Dec 3, 2011 at 7:18 PM, Travis Oliphant teoliph...@gmail.comwrote: Hi everyone, There have been some wonderfully vigorous discussions over the past few months that have made it clear that we need some clarity about how decisions will be made in the NumPy community. When we were a