Re: [Numpy-discussion] Getting 3-D array values from a 2-D array of indexes

2007-01-09 Thread Pau Gargallo
On 1/9/07, Jordan Dawe [EMAIL PROTECTED] wrote:
 I have a 3D array A of shape (nz, ny, nx) and a 2D array B of shape (ny,
 nx) that contains integer indexes.  I want to generate a 2D array C of
 shape (ny, nx) composed of the values of A at the z-indexes specified in
 B.  Is there an easy way to do this?

 Jordan

you can use integer indexing if you first generate a complete set of
coordinates.
In your case you have the z-indexes, so you can generate the y and x
indices and then use integer indexing:

 y,x = indices((ny,nx))
 C = A[B,y,x]

hope it helps,
pau
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Where's append in NumPy??

2007-01-09 Thread Lou Pecora
That may be it.  I'll get a newer version.

--- Robert Kern [EMAIL PROTECTED] wrote:

 Lou Pecora wrote:
  After import numpy as N
  
  In [10]: print N.__version__
  1.1.2881
  
  does that look right as a recent version?
 
 No, that's very old. The version number had briefly
 gotten bumped to 1.1 in the
 repository, but we backed that out quickly.
 
 -- 
 Robert Kern



-- Lou Pecora
  My views are my own.

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Where's append in NumPy?? Can't Installing NumPy.

2007-01-09 Thread Lou Pecora

--- Lou Pecora [EMAIL PROTECTED] wrote:

 That may be it.  I'll get a newer version.
 


No Luck.  

I downloaded numpy-1.0-py2.4-macosx10.4.dmg from the
MacOSX package site, but the installer kept telling me
there was nothing to install.  I removed the previous
NumPy and numpy.pth from the site packages and got the
same message.  How do I install numpy when another
version is there (apparently erroneously marked as a
later version)?



-- Lou Pecora
  My views are my own.

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] Need help for implementing a fast clip in numpy (was slow clip)

2007-01-09 Thread David Cournapeau
Hi,

I am finally implementing a C function to replace the current slow 
implementation of clip in python as promised a few weeks ago. The idea 
is to implement it as the following:

def clip(input, min, max):
a   = input.copy()
putmask(a, a = min, min)
putmask(a, a = max, max)
return a

I don't have that much experience in writing general numpy functions, so 
I was wondering of other people could advise me on the following points.

- should I care only about numeric types, eg something where 
PyArray_ISNUMBER returns true ?
- If input is an array of type T1, min a scalar of type T2 and max a 
scalar of type T3, which type should be the reference, assuming they are 
all basic numeric types (float, int, etc...). Eg, if T1 is integer, T2 
and T3 are float, what am I supposed to do ? Should I use the basic rule 
as told in numpy doc, and in that case, and do something like this to 
determine common datatype (pseudo code):

int typenum;
for each arg in arglist:
   typenum = PyArray_ObjectType(arg, typenum)

- PyArray_PutMask does not assume anything on the datatype of the 
input array nor this alignement, and treat its binary content as a 
buffer to char*. Do I need to do the same, or can I just use normal 
pointer arithmetic on arrays which elements can be casted to basic C types ?

cheers,

David
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Exported symbols and code reorganization.

2007-01-09 Thread Charles R Harris

On 1/9/07, David Cournapeau [EMAIL PROTECTED] wrote:


Charles R Harris wrote:


 On 1/7/07, *Robert Kern* [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED] wrote:

 Charles R Harris wrote:


 snip

 No, but as with mtrand, most of those arise from the fact that
 these functions
 are implemented in files other than the C file that contains the
 Python module
 code. In order for them to be called from the Python module code,
 they need to
 be exported, IIRMCC (If I Remember My C Correctly). This appears
 to be true of
 essentially every other extension module in my site-packages, so I
 don't think
 it's going to be much of a problem.


 I don't think unnecessary public symbols are much of a problem,
 either, but it bears on the question of breaking up the core numpy
 files. The parts could be treated in the same way, i.e., compiled
 separately and linked, or they could be treated as you suggested
 previously, declared static and the code included into one base file.
 I suspect the inclusion route is a bit easier from a portability
 standpoint, long link lists can be a problem and the making of
 libraries is platform dependent.

Bit late at joining the discussion... I started the same thing,
splitting up those files.

As Travis reminded me in a previous discussion, most symbols in numpy
extensions are private (eg static functions) because that's the way
python extension works:



I think we can do what the multiarray module does, provide a table of
function pointers in the _XXX_API module attribute. That way the random and
fft functions would be available to c extension modules for those who wanted
them while also being kept out of the module namespace.

Chuck
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] reduction

2007-01-09 Thread Charles R Harris

On 1/8/07, Robert Kern [EMAIL PROTECTED] wrote:


lorenzo bolla wrote:
 ops. I did it, too.
 should I delete it?? how??

I closed it as a duplicate. As a nondeveloper, you don't have the
permissions to
close tickets yourself.



Now that this bug is closed, maybe we should make another point release so
folks know they should upgrade.

Chuck
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Where's append in NumPy?? Can't Installing NumPy.

2007-01-09 Thread Christopher Barker
Lou,

This is odd. I've always been able to do it. I sure wish Apple had 
provided a decent package management system!

I have a dmg for 1.0.1 that seems to work well. I wonder where I got it?

$ python2.4
Python 2.4.3 (#1, Apr  7 2006, 10:54:33)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type help, copyright, credits or license for more information.
  import numpy
  numpy.__version__
'1.0.1'
 

  help(numpy.append)
Help on function append in module numpy.lib.function_base:

append(arr, values, axis=None)
 Append to the end of an array along axis (ravel first if None)


In any case, I'll send it straight to you in a separate email. Let me 
know how it works.

-Chris


Lou Pecora wrote:
 --- Lou Pecora [EMAIL PROTECTED] wrote:
 
 That may be it.  I'll get a newer version.

 
 
 No Luck.  
 
 I downloaded numpy-1.0-py2.4-macosx10.4.dmg from the
 MacOSX package site, but the installer kept telling me
 there was nothing to install.  I removed the previous
 NumPy and numpy.pth from the site packages and got the
 same message.  How do I install numpy when another
 version is there (apparently erroneously marked as a
 later version)?
 
 
 
 -- Lou Pecora
   My views are my own.
 
 __
 Do You Yahoo!?
 Tired of spam?  Yahoo! Mail has the best spam protection around 
 http://mail.yahoo.com 
 ___
 Numpy-discussion mailing list
 Numpy-discussion@scipy.org
 http://projects.scipy.org/mailman/listinfo/numpy-discussion

-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/ORR(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

[EMAIL PROTECTED]
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Where's append in NumPy?? Can't Installing NumPy.

2007-01-09 Thread Lou Pecora
Hi, Chris,   Some answers below (sort of):

--- Christopher Barker [EMAIL PROTECTED] wrote:

 Lou,
 
 This is odd. I've always been able to do it. I sure
 wish Apple had 
 provided a decent package management system!

Amen!

 I have a dmg for 1.0.1 that seems to work well. I
 wonder where I got it?

I got my original NumPy that wouldn't install from the
MacPython site.  It was a package with the usual
install dialog.  Even wiping the existing NumPy from
site-packages didn't work.  Go figure.

Finally got NumPy installed using the tarball from
http://www.scipy.org/Download.  Did the usual,

sudo python setup install

stuff and that worked.  I now have NumPy 1.01 and it
has 'append'. 

For others information:  I had to update SciPy and
Matplotlib, too.  SciPy turned out *not* to be doable
from its tarball on http://www.scipy.org/Download.  I
got the following error (after a whole LOT of output
from compiling, etc.):

/usr/local/bin/g77 -g -Wall -undefined
dynamic_lookup...blah,
blah.../scipy/fftpack/_fftpack.so

/usr/bin/ld: can't locate file for: -lcc_dynamic
collect2: ld returned 1 exit status

/usr/bin/ld: can't locate file for: -lcc_dynamic
collect2: ld returned 1 exit status

error: Command /usr/local/bin/g77 -g -Wall -undefined
dynamic_lookup ...blah,
blah.../scipy/fftpack/_fftpack.so failed with exit
status 1

Exit 1


Whatever collect2 is ld couldn;t find it.  I finally
got SciPy installed from the superpack at the
http://www.scipy.org/Download site.  That seems to
work, giving me version 0.5.3dev for SciPy.

Matplotlib installed fine from tarball and the setup
stuff.

I hope that's of use to someone out there.  Each time
I upgrade something it's an adventure.  Thanks for the
feedback.




-- Lou Pecora
  My views are my own.

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Where's append in NumPy?? Can't Installing NumPy.

2007-01-09 Thread Robert Kern
Lou Pecora wrote:

 /usr/local/bin/g77 -g -Wall -undefined
 dynamic_lookup...blah,
 blah.../scipy/fftpack/_fftpack.so
 
 /usr/bin/ld: can't locate file for: -lcc_dynamic

Yup. You can't use g77 with gcc 4. See the instructions I give in the thread
recompiling needed for binary module after numpy 1.0.

-- 
Robert Kern

I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth.
  -- Umberto Eco
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Where's append in NumPy?? Can't Installing NumPy.

2007-01-09 Thread Lou Pecora
Ah, that does ring a bell.  Sigh.  I need to upgrade
my memory banks.  Sure is tough keeping these packages
in sync.  Thanks.  I'll check it out.

--- Robert Kern [EMAIL PROTECTED] wrote:

 Lou Pecora wrote:
 
  /usr/local/bin/g77 -g -Wall -undefined
  dynamic_lookup...blah,
  blah.../scipy/fftpack/_fftpack.so
  
  /usr/bin/ld: can't locate file for: -lcc_dynamic
 
 Yup. You can't use g77 with gcc 4. See the
 instructions I give in the thread
 recompiling needed for binary module after numpy
 1.0.
 
 -- 
 Robert Kern


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion