Re: [Numpy-discussion] Inverting argsort(a, axis=0) to obtain column-wise ranks

2010-09-19 Thread John Schulman
D'oh, Zachary already gave that answer.

On Sun, Sep 19, 2010 at 10:17 PM, John Schulman  wrote:
> Argsort twice and you get the rank.
>
> a1.argsort(axis=0).argsort(axis=0)
>
> That's because argsort is it's own inverse when applied to the ranks.
>
> On Tue, Sep 7, 2010 at 1:01 PM, Alexander Michael  wrote:
>> Calculating ranks by inverting the results of an argsort is
>> straightforward and fast for 1D arrays:
>>
>> indices = argsort(a1)
>> ranks = zeros_like(indices)
>> ranks[indices] = arange(len(indices))
>>
>> I was wondering if there was an equally pithy way to do this for
>> multiple data samples stored column-wise in a 2D array. That is, is
>> there a trick to invert the results of argsort(a2, axis=0) without
>> iterating (in python) over the columns?
>>
>> Thanks,
>> Alex
>> ___
>> NumPy-Discussion mailing list
>> NumPy-Discussion@scipy.org
>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>
>>
>
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Inverting argsort(a, axis=0) to obtain column-wise ranks

2010-09-19 Thread John Schulman
Argsort twice and you get the rank.

a1.argsort(axis=0).argsort(axis=0)

That's because argsort is it's own inverse when applied to the ranks.

On Tue, Sep 7, 2010 at 1:01 PM, Alexander Michael  wrote:
> Calculating ranks by inverting the results of an argsort is
> straightforward and fast for 1D arrays:
>
> indices = argsort(a1)
> ranks = zeros_like(indices)
> ranks[indices] = arange(len(indices))
>
> I was wondering if there was an equally pithy way to do this for
> multiple data samples stored column-wise in a 2D array. That is, is
> there a trick to invert the results of argsort(a2, axis=0) without
> iterating (in python) over the columns?
>
> Thanks,
> Alex
> ___
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] Infix operators for numpy arrays

2010-04-18 Thread John Schulman
Hi all,
I just posted a recipe (http://code.activestate.com/recipes/577201/)
for infix operators that work with numpy arrays, so you can write X
*dot* Y. It works by making the Infix class a subclass of ndarray.

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


[Numpy-discussion] Scipy09 Sprints

2009-08-22 Thread John Schulman
For the numpy/scipyers at Caltech now:
I'm wondering what is happening with the scipy09 sprints. According to
the website, the sprints start at 8AM in Powell Booth, but that
building is locked and there's no sign of life.
Best,
John
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] switching to float32

2009-06-25 Thread John Schulman
I'm trying to reduce the memory used in a calculation, so I'd like to
switch my program to float32 instead of float64. Is it possible to
change the numpy default float size, so I don't have to explicitly
state dtype=np.float32 everywhere?

Thanks,
John
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] error with large memmap

2009-06-09 Thread John Schulman
What's the best way to install a 64-bit python alongside my existing
installation?


On Tue, Jun 9, 2009 at 7:32 AM, John Schulman wrote:
> OK looks like that was the issue
> $ python -c "import platform; print platform.machine()"
> i386
>
> Thanks
>
>
> On Tue, Jun 9, 2009 at 2:52 AM, David
> Cournapeau wrote:
>> Charles R Harris wrote:
>>>
>>>
>>> On Tue, Jun 9, 2009 at 2:32 AM, John Schulman >> <mailto:jos...@caltech.edu>> wrote:
>>>
>>>     I'm getting the error
>>>     OverflowError: cannot fit 'long' into an index-sized integer
>>>     when I try to memmap a 6gb file
>>>
>>>     top of the stack trace is
>>>     mm = mmap.mmap(fid.fileno(), bytes, access=acc)
>>>     where bytes = 652800L
>>>
>>>     I thought that 64-bit systems with python>2.5 could memmap large
>>>     files. I'm running the latest EPD python distribution (4.2.30201),
>>>     which uses python 2.5.4 and numpy 1.2.1
>>>     Macbook Pro Core 2 Duo, OS X 10.5.6
>>>
>>>
>>> Is your python 64 bits? Try:
>>>
>>> file `which python`
>>
>> This is even better:
>>
>> python -c "import platform; print platform.machine()"
>>
>> as mac os x can be confusing with fat binaries and all :)
>>
>> David
>> ___
>> Numpy-discussion mailing list
>> Numpy-discussion@scipy.org
>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>
>>
>
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] error with large memmap

2009-06-09 Thread John Schulman
OK looks like that was the issue
$ python -c "import platform; print platform.machine()"
i386

Thanks


On Tue, Jun 9, 2009 at 2:52 AM, David
Cournapeau wrote:
> Charles R Harris wrote:
>>
>>
>> On Tue, Jun 9, 2009 at 2:32 AM, John Schulman > <mailto:jos...@caltech.edu>> wrote:
>>
>>     I'm getting the error
>>     OverflowError: cannot fit 'long' into an index-sized integer
>>     when I try to memmap a 6gb file
>>
>>     top of the stack trace is
>>     mm = mmap.mmap(fid.fileno(), bytes, access=acc)
>>     where bytes = 652800L
>>
>>     I thought that 64-bit systems with python>2.5 could memmap large
>>     files. I'm running the latest EPD python distribution (4.2.30201),
>>     which uses python 2.5.4 and numpy 1.2.1
>>     Macbook Pro Core 2 Duo, OS X 10.5.6
>>
>>
>> Is your python 64 bits? Try:
>>
>> file `which python`
>
> This is even better:
>
> python -c "import platform; print platform.machine()"
>
> as mac os x can be confusing with fat binaries and all :)
>
> David
> ___
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] error with large memmap

2009-06-09 Thread John Schulman
I'm getting the error
OverflowError: cannot fit 'long' into an index-sized integer
when I try to memmap a 6gb file

top of the stack trace is
mm = mmap.mmap(fid.fileno(), bytes, access=acc)
where bytes = 652800L

I thought that 64-bit systems with python>2.5 could memmap large
files. I'm running the latest EPD python distribution (4.2.30201),
which uses python 2.5.4 and numpy 1.2.1
Macbook Pro Core 2 Duo, OS X 10.5.6
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion