Re: [Numpy-discussion] block matrix and sums of blocks

2009-02-22 Thread Robert Kern
On Sun, Feb 22, 2009 at 19:39, Xavier Gnata wrote: > Hi, > > Let us consider one kN x kM array. > What is the fastest way to sum each k x k square block of A and to put > all these results into a NxM array B? > > For instance: > If A = > [112233 > 112233 > 223311 > 223311] > then B = > [4 8 12

Re: [Numpy-discussion] numpy.fix and subclasses

2009-02-22 Thread Darren Dale
On Sun, Feb 22, 2009 at 10:35 PM, Darren Dale wrote: > I've been finding some numpy functions that could maybe be improved to work > better with ndarray subclasses. For example: > > def fix(x, y=None): > x = nx.asanyarray(x) > if y is None: > y = nx.zeros_like(x) > y1 = nx.flo

[Numpy-discussion] numpy.fix and subclasses

2009-02-22 Thread Darren Dale
I've been finding some numpy functions that could maybe be improved to work better with ndarray subclasses. For example: def fix(x, y=None): x = nx.asanyarray(x) if y is None: y = nx.zeros_like(x) y1 = nx.floor(x) y2 = nx.ceil(x) y[...] = nx.where(x >= 0, y1, y2) re

Re: [Numpy-discussion] block matrix and sums of blocks

2009-02-22 Thread Charles R Harris
On Sun, Feb 22, 2009 at 6:39 PM, Xavier Gnata wrote: > Hi, > > Let us consider one kN x kM array. > What is the fastest way to sum each k x k square block of A and to put > all these results into a NxM array B? > > For instance: > If A = > [112233 > 112233 > 223311 > 223311] > then B = > [4 8 1

Re: [Numpy-discussion] block matrix and sums of blocks

2009-02-22 Thread Charles R Harris
On Sun, Feb 22, 2009 at 6:39 PM, Xavier Gnata wrote: > Hi, > > Let us consider one kN x kM array. > What is the fastest way to sum each k x k square block of A and to put > all these results into a NxM array B? > > For instance: > If A = > [112233 > 112233 > 223311 > 223311] > then B = > [4 8 1

[Numpy-discussion] block matrix and sums of blocks

2009-02-22 Thread Xavier Gnata
Hi, Let us consider one kN x kM array. What is the fastest way to sum each k x k square block of A and to put all these results into a NxM array B? For instance: If A = [112233 112233 223311 223311] then B = [4 8 12 4 12 4] No sanity checks on the arrays shapes are requiered. Only speed mat

Re: [Numpy-discussion] Import NumPy in Self-defined function script

2009-02-22 Thread Markus Rosenstihl
Am 23.02.2009 um 00:59 schrieb Stéfan van der Walt: > 2009/2/23 Markus Rosenstihl darmstadt.de>: >>> Another script "controller.py" calls this function as: >>> >>> [code]#! /usr/bin/env python >>> # from numpy import * >>^ This is a comment, you are not importing numpy! > > But he is also not

Re: [Numpy-discussion] small suggestion for numpy.testing utils

2009-02-22 Thread Stéfan van der Walt
2009/2/23 Darren Dale : > On Sun, Feb 22, 2009 at 5:12 PM, Stéfan van der Walt > wrote: >> >> Hi Darren >> >> 2009/2/22 Darren Dale : >> > I am using numpy's assert_array_equal and assert_array_almost_equal to >> > unit >> > test my physical quantities package. I made a single minor change to >> >

Re: [Numpy-discussion] possible bug: __array_wrap__ is not called during arithmetic operations in some cases

2009-02-22 Thread Darren Dale
On Sun, Feb 22, 2009 at 6:35 PM, Darren Dale wrote: > On Sun, Feb 22, 2009 at 6:28 PM, Pierre GM wrote: > >> >> On Feb 22, 2009, at 6:21 PM, Eric Firing wrote: >> >> > Darren Dale wrote: >> >> Does anyone know why __array_wrap__ is not called for subclasses >> >> during >> >> arithmetic operatio

Re: [Numpy-discussion] Import NumPy in Self-defined function script

2009-02-22 Thread Stéfan van der Walt
2009/2/23 Markus Rosenstihl : >> Another script "controller.py" calls this function as: >> >> [code]#! /usr/bin/env python >> # from numpy import * > ^ This is a comment, you are not importing numpy! But he is also not using numpy in controller. Cheers Stéfan _

Re: [Numpy-discussion] small suggestion for numpy.testing utils

2009-02-22 Thread Darren Dale
I think they are identical, its just that asanyarray appears to be targeted for exactly this use-case, so perhaps it is a little faster. I just posted that asanyarray would probably have been a better choice, the posts must have crossed. On Sun, Feb 22, 2009 at 6:52 PM, Andrew Straw wrote: > Dar

Re: [Numpy-discussion] small suggestion for numpy.testing utils

2009-02-22 Thread Andrew Straw
Darren, What's the difference between asanyarray(y) and array(y, copy=False, subok=True)? I thought asanyarray would also do what you want. -Andrew Darren Dale wrote: > On Sun, Feb 22, 2009 at 3:22 PM, Darren Dale > wrote: > > On Sun, Feb 22, 2009 at 3:17 PM, Dar

Re: [Numpy-discussion] small suggestion for numpy.testing utils

2009-02-22 Thread Darren Dale
On Sun, Feb 22, 2009 at 5:12 PM, Stéfan van der Walt wrote: > Hi Darren > > 2009/2/22 Darren Dale : > > I am using numpy's assert_array_equal and assert_array_almost_equal to > unit > > test my physical quantities package. I made a single minor change to > > assert_array_compare that I think might

Re: [Numpy-discussion] Import NumPy in Self-defined function script

2009-02-22 Thread Gael Varoquaux
On Mon, Feb 23, 2009 at 12:47:41AM +0100, Markus Rosenstihl wrote: You are definitely right with your suggestion not to use 'from foo import *' It took me a while to realise that the gain of explicite namespace was more than the cost of a few characters, but I definitely stand by this. > I always

Re: [Numpy-discussion] Import NumPy in Self-defined function script

2009-02-22 Thread Markus Rosenstihl
Am 23.02.2009 um 00:19 schrieb Tim: > Hi, > I am defining a function in file "trainer.py". It requires a module > called numpy as following: > > > Another script "controller.py" calls this function as: > > [code]#! /usr/bin/env python > # from numpy import * ^ This is a comment, you are no

Re: [Numpy-discussion] Import NumPy in Self-defined function script

2009-02-22 Thread Stéfan van der Walt
Hi Tim 2009/2/23 Tim : > I think zeros belongs to Module numpy, and I import it in my function file > "trainer.py". So I was wonering what's the mistake I am making? Thanks for > help! What is the output of the following (please execute this inside Python inside trainer.py's directory): import

Re: [Numpy-discussion] possible bug: __array_wrap__ is not called during arithmetic operations in some cases

2009-02-22 Thread Darren Dale
On Sun, Feb 22, 2009 at 6:28 PM, Pierre GM wrote: > > On Feb 22, 2009, at 6:21 PM, Eric Firing wrote: > > > Darren Dale wrote: > >> Does anyone know why __array_wrap__ is not called for subclasses > >> during > >> arithmetic operations where an iterable like a list or tuple > >> appears to > >> t

Re: [Numpy-discussion] possible bug: __array_wrap__ is not called during arithmetic operations in some cases

2009-02-22 Thread Pierre GM
On Feb 22, 2009, at 6:21 PM, Eric Firing wrote: > Darren Dale wrote: >> Does anyone know why __array_wrap__ is not called for subclasses >> during >> arithmetic operations where an iterable like a list or tuple >> appears to >> the right of the subclass? When I do "mine*[1,2,3]", array_wrap i

Re: [Numpy-discussion] possible bug: __array_wrap__ is not called during arithmetic operations in some cases

2009-02-22 Thread Stéfan van der Walt
2009/2/23 Eric Firing : > Darren Dale wrote: >> Does anyone know why __array_wrap__ is not called for subclasses during >> arithmetic operations where an iterable like a list or tuple appears to >> the right of the subclass? When I do "mine*[1,2,3]", array_wrap is not >> called and I get an ndarray

[Numpy-discussion] Import NumPy in Self-defined function script

2009-02-22 Thread Tim
Hi, I am defining a function in file "trainer.py". It requires a module called numpy as following: [code] from numpy import * import string def trainer(train_seqs):     nul_dict = {"A":0,"C":1,"G":2,"T":3}# nucleotide to index of array     init_prob = zeros(4,double)# initial prob at  1st col  

Re: [Numpy-discussion] possible bug: __array_wrap__ is not called during arithmetic operations in some cases

2009-02-22 Thread Eric Firing
Darren Dale wrote: > Does anyone know why __array_wrap__ is not called for subclasses during > arithmetic operations where an iterable like a list or tuple appears to > the right of the subclass? When I do "mine*[1,2,3]", array_wrap is not > called and I get an ndarray instead of a MyArray. "[1,

Re: [Numpy-discussion] small suggestion for numpy.testing utils

2009-02-22 Thread Darren Dale
On Sun, Feb 22, 2009 at 5:39 PM, Stéfan van der Walt wrote: > 2009/2/23 Darren Dale : > > That's great, thank you. I finally got the trac website to take the > ticket, > > by the way. > > Actually, it's been taking all your tickets... from 1016 through 1021 :) > Oops, sorry about that. (I was tak

[Numpy-discussion] possible bug: __array_wrap__ is not called during arithmetic operations in some cases

2009-02-22 Thread Darren Dale
Does anyone know why __array_wrap__ is not called for subclasses during arithmetic operations where an iterable like a list or tuple appears to the right of the subclass? When I do "mine*[1,2,3]", array_wrap is not called and I get an ndarray instead of a MyArray. "[1,2,3]*mine" is fine, as is "min

Re: [Numpy-discussion] small suggestion for numpy.testing utils

2009-02-22 Thread Stéfan van der Walt
2009/2/23 Darren Dale : > That's great, thank you. I finally got the trac website to take the ticket, > by the way. Actually, it's been taking all your tickets... from 1016 through 1021 :) Cheers Stéfan ___ Numpy-discussion mailing list Numpy-discussion

Re: [Numpy-discussion] small suggestion for numpy.testing utils

2009-02-22 Thread Darren Dale
On Sun, Feb 22, 2009 at 5:12 PM, Stéfan van der Walt wrote: > Hi Darren > > 2009/2/22 Darren Dale : > > I am using numpy's assert_array_equal and assert_array_almost_equal to > unit > > test my physical quantities package. I made a single minor change to > > assert_array_compare that I think might

Re: [Numpy-discussion] small suggestion for numpy.testing utils

2009-02-22 Thread Stéfan van der Walt
Hi Darren 2009/2/22 Darren Dale : > I am using numpy's assert_array_equal and assert_array_almost_equal to unit > test my physical quantities package. I made a single minor change to > assert_array_compare that I think might make these functions more useful to > ndarray subclasses, and thought may

Re: [Numpy-discussion] RFR: 991 - Make savez able to write ZIP64 files

2009-02-22 Thread Stéfan van der Walt
2009/2/22 Nils Wagner : >> You can just run "nosetests numpy.lib" on both a 2.4 and >>a 2.5 >> installation to see if it works. > > Done. I am using python2.6 now. > > patch io.py < 0001-Add-ZIP64-support.patch Thanks for testing! Cheers Stéfan ___ Nump

Re: [Numpy-discussion] RFR: 991 - Make savez able to write ZIP64 files

2009-02-22 Thread Nils Wagner
On Sun, 22 Feb 2009 22:18:32 +0200 Stéfan van der Walt wrote: > Hi Nils > > 2009/2/22 Nils Wagner : >>> http://scipy.org/scipy/numpy/ticket/991 >>> >>> which enables ZIP64 extensions when saving and loading >>>zipped data >>> under Python >= 2.5 > > You can just run "nosetests numpy.lib" on bo

Re: [Numpy-discussion] small suggestion for numpy.testing utils

2009-02-22 Thread Darren Dale
On Sun, Feb 22, 2009 at 3:22 PM, Darren Dale wrote: > On Sun, Feb 22, 2009 at 3:17 PM, Darren Dale wrote: > >> Hello, >> >> I am using numpy's assert_array_equal and assert_array_almost_equal to >> unit test my physical quantities package. I made a single minor change to >> assert_array_compare

Re: [Numpy-discussion] small suggestion for numpy.testing utils

2009-02-22 Thread Darren Dale
On Sun, Feb 22, 2009 at 3:17 PM, Darren Dale wrote: > Hello, > > I am using numpy's assert_array_equal and assert_array_almost_equal to unit > test my physical quantities package. I made a single minor change to > assert_array_compare that I think might make these functions more useful to > ndarr

Re: [Numpy-discussion] RFR: 991 - Make savez able to write ZIP64 files

2009-02-22 Thread Stéfan van der Walt
Hi Nils 2009/2/22 Nils Wagner : >> http://scipy.org/scipy/numpy/ticket/991 >> >> which enables ZIP64 extensions when saving and loading >>zipped data >> under Python >= 2.5 You can just run "nosetests numpy.lib" on both a 2.4 and a 2.5 installation to see if it works. Thanks! Stéfan

[Numpy-discussion] small suggestion for numpy.testing utils

2009-02-22 Thread Darren Dale
Hello, I am using numpy's assert_array_equal and assert_array_almost_equal to unit test my physical quantities package. I made a single minor change to assert_array_compare that I think might make these functions more useful to ndarray subclasses, and thought maybe they could be useful to numpy it

Re: [Numpy-discussion] RFR: 991 - Make savez able to write ZIP64 files

2009-02-22 Thread Nils Wagner
On Sun, 22 Feb 2009 18:37:05 +0200 Stéfan van der Walt wrote: > Hi all, > > Please review the patch attached to > > http://scipy.org/scipy/numpy/ticket/991 > > which enables ZIP64 extensions when saving and loading >zipped data > under Python >= 2.5 > > Thanks, > Stéfan Hi Stefan, Please

[Numpy-discussion] RFR: 991 - Make savez able to write ZIP64 files

2009-02-22 Thread Stéfan van der Walt
Hi all, Please review the patch attached to http://scipy.org/scipy/numpy/ticket/991 which enables ZIP64 extensions when saving and loading zipped data under Python >= 2.5 Thanks, Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http

Re: [Numpy-discussion] RFR: 995 - numpy.load can't handle gzip file handles

2009-02-22 Thread Nils Wagner
On Sun, 22 Feb 2009 13:03:03 +0200 Stéfan van der Walt wrote: > Hi Nils, > > 2009/2/22 Nils Wagner : >> Done. See http://www.scipy.org/scipy/numpy/ticket/995 >> for details. > > Thanks. Did you have a NumPy array stored with >numpy.save in test.gz? > I finally got access to a 2.4 machine and

Re: [Numpy-discussion] RFR: 995 - numpy.load can't handle gzip file handles

2009-02-22 Thread Stéfan van der Walt
Hi Nils, 2009/2/22 Nils Wagner : > Done. See http://www.scipy.org/scipy/numpy/ticket/995 > for details. Thanks. Did you have a NumPy array stored with numpy.save in test.gz? I finally got access to a 2.4 machine and the patch works there. Cheers Stéfan _

Re: [Numpy-discussion] RFR: 995 - numpy.load can't handle gzip file handles

2009-02-22 Thread Nils Wagner
On Sat, 21 Feb 2009 12:58:14 +0200 Stéfan van der Walt wrote: > Hi, > > Based on an example on Effbot, I implemented a >workaround for reverse > seeking in gzip files. I need someone with Python 2.4 >to review: > > http://www.scipy.org/scipy/numpy/ticket/995 > > Thanks! > Stéfan Done. Se