Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread A. M. Archibald
On 17/10/06, Charles R Harris <[EMAIL PROTECTED]> wrote:
>
>
> On 10/17/06, Travis Oliphant <[EMAIL PROTECTED]> wrote:

> > Thus, reshape does the equivalent of a Fortran ravel to [1,4,2,5,3,6]
> > and then a Fortran-order based fill of an empty (3,2) array:  giving you
> > the result.
>
> Why a Fortran ravel? I am thinking of it as preserving the memory layout,
> just messing with how it is addressed.

Because, to first order, the memory layout is totally irrelevant to a
python user.

array([[1,2,3],[4,5,6]],order='C')
array([[1,2,3],[4,5,6]],order='F')

should be nearly identical to the python user. If the storage order
mattered, you'd have to know, every time you used reshape, what order
your matrix was stored in (did it come from a transpose operation, for
example?).

As for why a Fortran ravel rather than a C ravel, that's a simplifying
decision. If you like, you can think of reshape as happening in two
steps:

o1='C'
o2='C'
A.reshape((6,),order=o1).reshape((2,3),order=o2)

The design could have allowed, as Travis Oliphant says, o1!=o2, but
explaining that would have been quite difficult (even more than now, I
mean). And in any case you can use the code above to achieve that, if
you really want.

A. M. Archibald

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread Charles R Harris
On 10/17/06, Charles R Harris <[EMAIL PROTECTED]> wrote:
On 10/17/06, Travis Oliphant <
[EMAIL PROTECTED]> wrote:
Charles R Harris wrote:>>> On 10/17/06, *Lisandro Dalcin* <[EMAIL PROTECTED]> [EMAIL PROTECTED]>> wrote:
>> I was surprised by this>> In [14]: array([[1,2,3],[4,5,6]]).reshape((3,2),order='F')> Out[14]:> array([[1, 5],>[4, 3],>[2, 6]])
>>> This one still looks wrong.>> In [15]: array([1,2,3,4,5,6]).reshape((3,2),order='F')> Out[15]:> array([[1, 2],>[3, 4],>[5, 6]])
  This one is fixed,>> In [3]: array([[1,2,3,4,5,6]]).reshape((3,2),order='F')> Out[3]:> array([[1, 4],>[2, 5],>[3, 6]])>

> I also don't understand why a copy is returned if 'F' just fiddles> with the indices and strides; the underlying data should be the same,> just the view changes. FWIW, I think both examples should be returning
> views.You are right, it doesn't need to.   My check is not general enough.It can be challenging to come up with a general way to differentiate theview-vs-copy situation and I struggled with it.  In this case, it's the
fact that while self->nd > 1, the other dimensions are only of shape 1and so don't really matter.   If you could come up with some kind ofstriding check that would distinguish the two cases, I would appreciate it.
I suppose the problem is mostly in discontiguous arrays. Hmmm..., this isn't too different that reshaping the transpose.a.reshape((m,n),order='F' ~ a.reshape((n,m)).T.reshape(m,n)
Erm, brainfart. Make that a.reshape((m,n),order='F') ~ a.reshape((n,m)).TThat's how I think of it, anyway. Actual layout in memory is not affected until something like ascontiguosarray is called.
Chuck
-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread Charles R Harris
On 10/17/06, Travis Oliphant <[EMAIL PROTECTED]> wrote:
Charles R Harris wrote:>>> On 10/17/06, *Lisandro Dalcin* <[EMAIL PROTECTED]> [EMAIL PROTECTED]>> wrote:
>> I was surprised by this>> In [14]: array([[1,2,3],[4,5,6]]).reshape((3,2),order='F')> Out[14]:> array([[1, 5],>[4, 3],>[2, 6]])
>>> This one still looks wrong.Why does this look wrong.  What do you want it to be?  Perhaps you arethinking about the input array as C-order and the output array asFortran order.   That's not what reshape does.   The order argument
specifies how you think about both the input and output.Thus, reshape does the equivalent of a Fortran ravel to [1,4,2,5,3,6]and then a Fortran-order based fill of an empty (3,2) array:  giving youthe result.
Why a Fortran ravel? I am thinking of it as preserving the memory layout, just messing with how it is addressed. Chuck
-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread Stefan van der Walt
On Tue, Oct 17, 2006 at 07:53:11PM -0600, Travis Oliphant wrote:
> Stefan van der Walt wrote:
> > Hi all,
> >
> > Some of you may have seen the interesting thread on Fortran-ordering
> > earlier.  I thought it might be fun to set up a short quiz which tests
> > your knowledge on the topic.
> >
> > If you're up for the challenge, take a look at
> >
> > http://mentat.za.net/numpy/quiz
> >
> > I won't be held liable for any emotional trauma caused, self-inflicted
> > wounds or brain-core meltdowns.
> >   
> 
> Cute (especially the comment if you get them all right).   I'm not sure 
> if this quiz is a veiled complaint about the rules for Fortran ordering 
> or not ;-)

If it is, it is very tactfully disguised ;) Actually, I was just
trying to figure out how Fortran ordering works and thought others
might be interested.

I reckoned you would be the only one to get 100%, although now you've
explained the rules so clearly a couple of other might grasp for the
holy grail too.

> In my mind the Fortran ordering rules are consistent (if not completely 
> bug-free).   You just have to get the right idea of what is meant by the 
> order argument when you use it.   If you think you are having trouble 
> figuring out the rules, think of the trouble it was to figure out what 
> they should be and then to code them up.

My sympathies (no, really).

> 2) On reshaping, the order argument specifies how you think the array is 
> organized.  Whenever you make a significant reshape you are telling the 
> computer to re-interpret the chunk of data in a different way, it makes 
> a big difference as to how you think about that chunk of data.  Do you 
> think of it as organized rows-first (C-order) or columns-first 
> (Fortran-order).   The order argument allows you to specify how you 
> think about it and indicates the 1-d indexing order of the array.  It 
> also fills in the newly-shaped array in exactly that same order.   
> Semantically, one could technically separate those two concepts and have 
> one order argument that specifies how you think about the input and 
> another that specifies how you think about the output.   But, I really 
> didn't want to go there and couldn't see a real advantage to that.  So, 
> the single order argument specifies how you think about both.

Thanks for the detailed overview (we should put it on the wiki).
Another thing I'm wondering about: when exactly does reshape need to
make copies?

One last case, which confuses me still (probably because it is
04:16am):

In [41]: x = N.array([[0,1,2],[3,4,5]],order='F')

In [42]: x
Out[42]: 
array([[0, 1, 2],
   [3, 4, 5]])

I assume the data is now stored in memory as

[0 3 1 4 2 5] (column-wise)

If I now do

x.reshape((3,2),order='C')

i.e. take that block of memory, assume it is in 'C' order, and make
its shape (3,2), I expect

[[0 3]
 [1 4]
 [2 5]]

but get

[[1 2]
 [3 4]
 [5 6]]

I'm obviously missing something trivial -- I'll try again tomorrow.

Cheers
Stéfan

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread Charles R Harris
On 10/17/06, Travis Oliphant <[EMAIL PROTECTED]> wrote:
Charles R Harris wrote:>>> On 10/17/06, *Lisandro Dalcin* <[EMAIL PROTECTED]> [EMAIL PROTECTED]>> wrote:
>> I was surprised by this>> In [14]: array([[1,2,3],[4,5,6]]).reshape((3,2),order='F')> Out[14]:> array([[1, 5],>[4, 3],>[2, 6]])
>>> This one still looks wrong.>> In [15]: array([1,2,3,4,5,6]).reshape((3,2),order='F')> Out[15]:> array([[1, 2],>[3, 4],>[5, 6]])
  This one is fixed,>> In [3]: array([[1,2,3,4,5,6]]).reshape((3,2),order='F')> Out[3]:> array([[1, 4],>[2, 5],>[3, 6]])>
> I also don't understand why a copy is returned if 'F' just fiddles> with the indices and strides; the underlying data should be the same,> just the view changes. FWIW, I think both examples should be returning
> views.You are right, it doesn't need to.   My check is not general enough.It can be challenging to come up with a general way to differentiate theview-vs-copy situation and I struggled with it.  In this case, it's the
fact that while self->nd > 1, the other dimensions are only of shape 1and so don't really matter.   If you could come up with some kind ofstriding check that would distinguish the two cases, I would appreciate it.
I suppose the problem is mostly in discontiguous arrays. Hmmm..., this isn't too different that reshaping the transpose.a.reshape((m,n),order='F' ~ a.reshape((n,m)).T.reshape(m,n)for instance:
In [26]: aOut[26]: 
array([[1, 2, 3],   [4, 5, 6]])
In [27]: a.reshape((3,2)).T.reshape((2,3))
Out[27]: array([[1, 3, 5],
   [2, 4, 6]])In [28]: a.reshape((2,3), order='F')
Out[28]: array([[1, 2, 3],
   [4, 5, 6]])Where I actually think the second reshape is correct and the third incorrect. This has the advantage that *all* the steps return views.
Chuck
-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread Travis Oliphant
Charles R Harris wrote:
>
>
> On 10/17/06, *Lisandro Dalcin* <[EMAIL PROTECTED] 
> > wrote:
>
> I was surprised by this
>
> In [14]: array([[1,2,3],[4,5,6]]).reshape((3,2),order='F')
> Out[14]:
> array([[1, 5],
>[4, 3],
>[2, 6]])
>
>
> This one still looks wrong.

Why does this look wrong.  What do you want it to be?  Perhaps you are 
thinking about the input array as C-order and the output array as 
Fortran order.   That's not what reshape does.   The order argument 
specifies how you think about both the input and output.

Thus, reshape does the equivalent of a Fortran ravel to [1,4,2,5,3,6] 
and then a Fortran-order based fill of an empty (3,2) array:  giving you 
the result.

-Travis


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread Travis Oliphant
Charles R Harris wrote:
>
>
> On 10/17/06, *Lisandro Dalcin* <[EMAIL PROTECTED] 
> > wrote:
>
> I was surprised by this
>
> In [14]: array([[1,2,3],[4,5,6]]).reshape((3,2),order='F')
> Out[14]:
> array([[1, 5],
>[4, 3],
>[2, 6]])
>
>
> This one still looks wrong.
>
> In [15]: array([1,2,3,4,5,6]).reshape((3,2),order='F')
> Out[15]:
> array([[1, 2],
>[3, 4],
>[5, 6]])
>
>
>  
>  This one is fixed,
>
> In [3]: array([[1,2,3,4,5,6]]).reshape((3,2),order='F')
> Out[3]:
> array([[1, 4],
>[2, 5],
>[3, 6]])
>
> I also don't understand why a copy is returned if 'F' just fiddles 
> with the indices and strides; the underlying data should be the same, 
> just the view changes. FWIW, I think both examples should be returning 
> views.

You are right, it doesn't need to.   My check is not general enough. 

It can be challenging to come up with a general way to differentiate the 
view-vs-copy situation and I struggled with it.  In this case, it's the 
fact that while self->nd > 1, the other dimensions are only of shape 1 
and so don't really matter.   If you could come up with some kind of 
striding check that would distinguish the two cases, I would appreciate it.

-Travis


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread Travis Oliphant
Stefan van der Walt wrote:
> Hi all,
>
> Some of you may have seen the interesting thread on Fortran-ordering
> earlier.  I thought it might be fun to set up a short quiz which tests
> your knowledge on the topic.
>
> If you're up for the challenge, take a look at
>
> http://mentat.za.net/numpy/quiz
>
> I won't be held liable for any emotional trauma caused, self-inflicted
> wounds or brain-core meltdowns.
>   

Cute (especially the comment if you get them all right).   I'm not sure 
if this quiz is a veiled complaint about the rules for Fortran ordering 
or not ;-)

In my mind the Fortran ordering rules are consistent (if not completely 
bug-free).   You just have to get the right idea of what is meant by the 
order argument when you use it.   If you think you are having trouble 
figuring out the rules, think of the trouble it was to figure out what 
they should be and then to code them up.

Two rules help you pass the quiz with a perfect score:

1) On array construction, the order argument allows you to specify how 
the array will be organized in memory.  This has no effect on what is 
printed as the user doesn't usually care how the array is stored in 
memory.   So, you can ignore all order=  expressions in the array 
construct for the quiz

2) On reshaping, the order argument specifies how you think the array is 
organized.  Whenever you make a significant reshape you are telling the 
computer to re-interpret the chunk of data in a different way, it makes 
a big difference as to how you think about that chunk of data.  Do you 
think of it as organized rows-first (C-order) or columns-first 
(Fortran-order).   The order argument allows you to specify how you 
think about it and indicates the 1-d indexing order of the array.  It 
also fills in the newly-shaped array in exactly that same order.   
Semantically, one could technically separate those two concepts and have 
one order argument that specifies how you think about the input and 
another that specifies how you think about the output.   But, I really 
didn't want to go there and couldn't see a real advantage to that.  So, 
the single order argument specifies how you think about both.

-Travis




-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread Charles R Harris
On 10/17/06, Lisandro Dalcin <[EMAIL PROTECTED]> wrote:
I was surprised by thisIn [14]: array([[1,2,3],[4,5,6]]).reshape((3,2),order='F')Out[14]:array([[1, 5],   [4, 3],   [2, 6]])This one still looks wrong. 
In [15]: array([1,2,3,4,5,6]).reshape((3,2),order='F')Out[15]:array([[1, 2],   [3, 4],   [5, 6]])  This one is fixed,
In [3]: array([[1,2,3,4,5,6]]).reshape((3,2),order='F')Out[3]: 
array([[1, 4],   [2, 5],
   [3, 6]])I also don't understand why a copy is returned if 'F' just fiddles with the indices and strides; the underlying data should be the same, just the view changes. FWIW, I think both examples should be returning views.
Chuck
-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread Stefan van der Walt
On Wed, Oct 18, 2006 at 10:30:26AM +0900, Bill Baxter wrote:
> I think the answer to #3 is wrong.
> 
> >From 1.0rc2 I get:
> >>> array([1,2,3,4,5,6],order='C').reshape((2,3),order='F')
> array([[1, 2, 3],
>[4, 5, 6]])
> 
> But the quiz wants me to answer something different.

This recently changed.  The quiz is correct for r3348.

Cheers
Stéfan

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread Travis Oliphant
Lisandro Dalcin wrote:
> I was surprised by this
>
> In [14]: array([[1,2,3],[4,5,6]]).reshape((3,2),order='F')
> Out[14]:
> array([[1, 5],
>[4, 3],
>[2, 6]])
>
> In [15]: array([1,2,3,4,5,6]).reshape((3,2),order='F')
> Out[15]:
> array([[1, 2],
>[3, 4],
>[5, 6]])
>   

This is a bug that was recently fixed in SVN.

-Travis


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread Bill Baxter
I think the answer to #3 is wrong.

>From 1.0rc2 I get:
>>> array([1,2,3,4,5,6],order='C').reshape((2,3),order='F')
array([[1, 2, 3],
   [4, 5, 6]])

But the quiz wants me to answer something different.

--bb

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread Lisandro Dalcin
I was surprised by this

In [14]: array([[1,2,3],[4,5,6]]).reshape((3,2),order='F')
Out[14]:
array([[1, 5],
   [4, 3],
   [2, 6]])

In [15]: array([1,2,3,4,5,6]).reshape((3,2),order='F')
Out[15]:
array([[1, 2],
   [3, 4],
   [5, 6]])


On 10/17/06, Stefan van der Walt <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> Some of you may have seen the interesting thread on Fortran-ordering
> earlier.  I thought it might be fun to set up a short quiz which tests
> your knowledge on the topic.
>
> If you're up for the challenge, take a look at
>
> http://mentat.za.net/numpy/quiz
>
> I won't be held liable for any emotional trauma caused, self-inflicted
> wounds or brain-core meltdowns.
>
> Cheers
> Stéfan
>
> -
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> ___
> Numpy-discussion mailing list
> Numpy-discussion@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>


-- 
Lisandro Dalcín
---
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] array repr

2006-10-17 Thread Andrew.MacKeith




Charles R Harris wrote:

  
  On 10/17/06, Andrew MacKeith <[EMAIL PROTECTED]>
wrote:
  Travis
Oliphant wrote:

>Ah!,  I get it.  You want to be able to reset to the C-defined
>array_repr function.  The one that gets over-written on
import.That
>makes sense.  And is definitely do-able.

>
>Please file a ticket.
>
>
Can you point me to how to file a ticket.
Thanks
  
Go to http://projects.scipy.org/scipy/numpy/report
  , login or register (required), then choose new ticket from the
menu at the top.
  
BTW, I wish all this was more transparent to the casual visitor to the
scipy site. There should be a link on the front page (numpy bugs or
something) and a short explanation about needing to register to file a
new ticket. Maybe something in the Cookbook would help.
  
  
Chuck
  
  

Thanks for the info.
I filed a ticket.

Andrew

  
  
  
  

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
  

___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion
  




-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] histogram complete makeover

2006-10-17 Thread Neal Becker
David Huard wrote:

> Hi all,
> 
> I'd like to poll the list to see what people want from numpy.histogram(),
> since I'm currently writing a contender.
> 
> My main complaints with the current version are:
> 1. upper outliers are stored in the last bin, while lower outliers are not
> counted at all,
> 2. cannot use weights.
> 
> The new histogram function is well under way (it address these issues and
> adds an axis keyword),
> but I want to know what is the preferred behavior regarding the function
> output, and your
> willingness to introduce a new behavior that will break some code.
> 
> Given a number of bins N and range (min, max), histogram constructs
> linearly spaced bin edges
> b0 (out-of-range)  | b1 | b2 | b3 |  | bN | bN+1 out-of-range
> and may return:
> 
> A.  H = array([N_b0, N_b1, ..., N_bN,  N_bN+1])
> The out-of-range values are the first and last values of the array. The
> returned array is hence N+2
> 
> B.  H = array([N_b0 + N_b1, N_b2, ..., N_bN + N_bN+1])
> The lower and upper out-of-range values are added to the first and last
> bin respectively.
> 
> C.  H = array([N_b1, ..., N_bN + N_bN+1])
> Current behavior: the upper out-of-range values are added to the last bin.
> 
> D.  H = array([N_b1, N_b2, ..., N_bN]),
> Lower and upper out-of-range values are given after the histogram array.
> 
> Ideally, the new function would not break the common usage: H =
> histogram(x)[0], so this exclude A.  B and C are not acceptable in my
> opinion, so only D remains, with the downsize that the outliers are not
> returned. A solution might be to add a keyword full_output=False, which
> when set to True, returns the out-of-range values in a dictionnary.
> 
> Also, the current function returns -> H, ledges
> where ledges is the array of left bin edges (N).
> I propose returning the complete array of edges (N+1), including the
> rightmost edge. This is a little bit impractical for plotting, as the
> edges array does not have the same length as the histogram array, but
> allows the use of user-defined non-uniform bins.
> 
> Opinions, suggestions ?
> 
> David

I have my own histogram that might interest you.  The core is modern c++,
with boost::python wrapper.

Out-of-bounds behavior is programmable.  I'll send it to you if you are
interested.


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


[Numpy-discussion] 1.0rc2 strange repeat behavior

2006-10-17 Thread Mike Rovner
Hi,

I got strange discrepance between 2.4+0.9.8 and 2.5+1.0rc2:

model_lib_pool %0 !5019$ python2.5
Python 2.5 (r25:51908, Oct 17 2006, 16:16:21)
[GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-14)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
f>>> from numpy import *
 >>> a=arange(12).reshape(4,3)
 >>> a
array([[ 0,  1,  2],
[ 3,  4,  5],
[ 6,  7,  8],
[ 9, 10, 11]])
 >>> a[:,2]
array([ 2,  5,  8, 11])
 >>> a[:,2].repeat(3)
array([2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5])
 >>> import numpy
 >>> numpy.__version__
'1.0rc2'
 >>>

Old version looks right:

Python 2.4.2 (#5, Jun  2 2006, 18:33:20)
[GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-20)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> from numpy import *
 >>> a=arange(12).reshape(4,3)
 >>> a
array([[ 0,  1,  2],
[ 3,  4,  5],
[ 6,  7,  8],
[ 9, 10, 11]])
 >>> a[:,2]
array([ 2,  5,  8, 11])
 >>> a[:,2].repeat(3)
array([ 2,  2,  2,  5,  5,  5,  8,  8,  8, 11, 11, 11])
 >>> import numpy
 >>> numpy.__version__
'0.9.8'
 >>>

Thanks,
Mike


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


[Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread Stefan van der Walt
Hi all,

Some of you may have seen the interesting thread on Fortran-ordering
earlier.  I thought it might be fun to set up a short quiz which tests
your knowledge on the topic.

If you're up for the challenge, take a look at

http://mentat.za.net/numpy/quiz

I won't be held liable for any emotional trauma caused, self-inflicted
wounds or brain-core meltdowns.

Cheers
Stéfan

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] A reimplementation of MaskedArray

2006-10-17 Thread Michael Sorich
On 10/17/06, Pierre GM <[EMAIL PROTECTED]> wrote:
> On Monday 16 October 2006 22:08, Michael Sorich wrote:
> > Does this new MA class allow masking of rearray like arrays?
>
> Excellent question! Which is to say, I have no idea... I don't use
> recordarray, so I didn't think about testing them.
>
> So, a first test indicates that it doesn't work either. The mask for a3 is
> understood as having a size 6, when the data is seen as size 2 only (exactly
> the same problem as the original ma module).
> I gonna poke around and check whether I can come with a workaround. Just to
> make it clear: you want to be able to mask some fields in some records,
> right ? Not mask all the fields of a record ?

Yes, that is correct. It would be preferable to have more control over
masking than simply masking an entire record. I view the heterogenouse
arrays as 2D arrays in which it should be possible to mask individual
values.

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


[Numpy-discussion] Question about indexing arrays with boolean arrays

2006-10-17 Thread Daniel Arbuckle
Why does a[b1, b2] not mean the same thing as a[b1][:, b2], when "a"
is an array and "b1" and "b2" are appropriately sized arrays of
booleans?

Thanks

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


[Numpy-discussion] Significant letter. You must to read.

2006-10-17 Thread Molly Driscoll
Please read it. Today is the exact day to buy that stock. 
Please check that note attentively. Here you will find the intimate news about 
GDKI. Please Read this news. 

Goldmark Cipher  Established Hip Hop Creator Sean Combs A.K.A. Puff Daddy 
 Wednesday this month 18, 11:40 am ET

NEW YORK & LOS ANGELES & VANCOUVER, B.C.--(BUSINESS WIRE)-- October 18, 11:40 
am ET -- Goldmark Industries, Inc. (PINK SHEETS:GDKI.PK - Reports), is excited 
to declare that it has signed one of the 
hottest producers in the hip-hop and r&b  industry, Sean Combs A.K.A. Puff 
Daddy. 
In an aggressive attempt  to stay ahead of the game, the Corporation moved 
quickly  in 
taking on the already successful and rising famous person.
Sean Combs, also well-known as Puff Daddy is the founder of Bad Boys Records 
marker.
By contract the between Goldmark Industries, Inc and
Bad Boy Entertainment Inc, Goldmark has to get 78 000 000 $ for
the distributing of Sean Combs A.K.A. Puff Daddy fresh album Press
Play. Total about from that deal for Goldmark should be 
about 12 000 000$. After the establishing
of that deal Goldmark Industries, Inc will be the second biggest company in 
the industry of hip-hop & r&b music.

Hip Hop famous person Sean "P.Diddy" Combs sees a huge possibility for his 
company in collaboration with Goldmark inc. Sean "P.Diddy" Combs tells that it 
is enjoyably to treat with these guys. They as anybody else know entertainment 
industriousness and precisely know what is necessary for the American 
spectators. He also emphasizes exclusivity of his fresh album Press Play and 
tells that the presentation of this album on october 17 will make an effect of 
the blasted bomb.
Today the new album of Puff Daddy Press Play will be on the shelves. TAKE GDKI 
and you will earn from every sale of that
golden disc.  

Concerning Bad Boy International Entertainment
Group: is one of the world's pre-eminent urban entertainment 
companies, surrounding a wide variety of
businesses including recording, music publishing, artist
organization, television and film
production, recording facility, advertising and advertising, apparel and
restaurants. With a collection of businesses whose yearly
sales are quickly impending 300$ million
annually and an employee base that is 600 strong. Mr. Combs is
largely responsible for the pop appeal of urban
entertainment. In just eight years, founder and CEO Sean
"P.Diddy" Combs has  forever changed the entertainment
industry by catapulting the music and fashionof urban youth
culture into the American  mainstream and creating
what is measured by experts to be one of the most significant
 services in entertainment these days.

About Goldmark Industries, Inc. (Stock symbol: GDKI.PK)
Goldmark Industries is committed to providing the best in all forms of urban 
entertainment to the 45 Million Hip-Hop consumers in North America. The average 
North American spends health care & clothing on entertainment than they do on 
more cash, making entertainment the most attractive industry for investors and 
advertisers alike. Goldmark Industries is preparing to stand at the forefront 
of the Hip Hop consumer market, specializing in all aspects of entertainment, 
including Major Events ,Music ,Feature Films ,Television and Home Video/DVD . 
The strength of Goldmark Industries is the result of its highly reputable & 
continuously growing management team. The knowledge and experience that each 
team member brings consistently supports the growing success of each division 
at Goldmark Industries. In addition, they are associated with some of the 
world's leading entertainment companies and top distribution channels 
worldwide, providing Goldmark Industries with the relationships to 
 continually move forward. 

P.S We has started to promote GDKI yesterday and the price is up for 16.6% 
already. Today,october 17 2006, the price will be 100% up. Don't miss that 
opportunity to buy GDKI for a low price. Just buy it!



-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] matlab, filter function

2006-10-17 Thread Travis Oliphant
Kenny Ortmann wrote:

>just looking for some help, most of the time you guys are good with matlab 
>code, i am trying to use the filter function under this setting
>
>y = filter(b,a,X) filters the data in vector X with the filter described by 
>numerator coefficient vector b and denominator coefficient vector a. If a(1) 
>is not equal to 1, filter normalizes the filter coefficients by a(1). If 
>a(1) equals 0, filter returns an error.
>  
>

There is scipy.signal.lfilter which implements this algorithm.  It's doc 
string is

lfilter(b, a, x, axis=-1, zi=None)
Filter data along one-dimension with an IIR or FIR filter.

Description

  Filter a data sequence, x, using a digital filter.  This works for 
many
  fundamental data types (including Object type).  The filter is a 
direct
  form II transposed implementation of the standard difference equation
  (see "Algorithm").

Inputs:

  b -- The numerator coefficient vector in a 1-D sequence.
  a -- The denominator coefficient vector in a 1-D sequence.  If a[0]
   is not 1, then both a and b are normalized by a[0].
  x -- An N-dimensional input array.
  axis -- The axis of the input data array along which to apply the
  linear filter. The filter is applied to each subarray along
  this axis (*Default* = -1)
  zi -- Initial conditions for the filter delays.  It is a vector
(or array of vectors for an N-dimensional input) of length
max(len(a),len(b)).  If zi=None or is not given then initial
rest is assumed.  SEE signal.lfiltic for more information.

Outputs: (y, {zf})

  y -- The output of the digital filter.
  zf -- If zi is None, this is not returned, otherwise, zf holds the
final filter delay values.

Algorithm:

  The filter function is implemented as a direct II transposed 
structure.
  This means that the filter implements

  y[n] = b[0]*x[n] + b[1]*x[n-1] + ... + b[nb]*x[n-nb]
   - a[1]*y[n-1] + ... + a[na]*y[n-na]

  using the following difference equations:

  y[m] = b[0]*x[m] + z[0,m-1]
  z[0,m] = b[1]*x[m] + z[1,m-1] - a[1]*y[m]
  ...
  z[n-3,m] = b[n-2]*x[m] + z[n-2,m-1] - a[n-2]*y[m]
  z[n-2,m] = b[n-1]*x[m] - a[n-1]*y[m]

  where m is the output sample number and n=max(len(a),len(b)) is the
  model order.

  The rational transfer function describing this filter in the
  z-transform domain is
  -1   -nb
  b[0] + b[1]z  + ... + b[nb] z
  Y(z) = -- X(z)
  -1   -na
  a[0] + a[1]z  + ... + a[na] z


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


[Numpy-discussion] histogram complete makeover

2006-10-17 Thread David Huard
Hi all, I'd like to poll the list to see what people want from numpy.histogram(), since I'm currently writing a contender.My main complaints with the current version are:1. upper outliers are stored in the last bin, while lower outliers are not counted at all,
2. cannot use weights.The new histogram function is well under way (it address these issues and adds an axis keyword), but I want to know what is the preferred behavior regarding the function output, and your 
willingness to introduce a new behavior that will break some code. Given a number of bins N and range (min, max), histogram constructs linearly spaced bin edges b0 (out-of-range)  | b1 | b2 | b3 |  | bN | bN+1 out-of-range
and may return:A.  H = array([N_b0, N_b1, ..., N_bN,  N_bN+1])The out-of-range values are the first and last values of the array. The returned array is hence N+2B.  H = array([N_b0 + N_b1, N_b2, ..., N_bN + N_bN+1])
The lower and upper out-of-range values are added to the first and last bin respectively.C.  H = array([N_b1, ..., N_bN + N_bN+1])    Current behavior: the upper out-of-range values are added to the last bin.
D.  H = array([N_b1, N_b2, ..., N_bN]), Lower and upper out-of-range values are given after the histogram array. Ideally, the new function would not break the common usage: H = histogram(x)[0], so this exclude A.  B and C are not acceptable in my opinion, so only D remains, with the downsize that the outliers are not returned. A solution might be to add a keyword full_output=False, which when set to True, returns the out-of-range values in a dictionnary. 
Also, the current function returns -> H, ledges 
where ledges is the array of left bin edges (N). 
I propose returning the complete array of edges (N+1), including the
rightmost edge. This is a little bit impractical for plotting, as the
edges array does not have the same length as the histogram array, but
allows the use of user-defined non-uniform bins. 
Opinions, suggestions ?David
-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] array repr

2006-10-17 Thread Charles R Harris
On 10/17/06, Andrew MacKeith <[EMAIL PROTECTED]> wrote:
Travis Oliphant wrote:>Ah!,  I get it.  You want to be able to reset to the C-defined>array_repr function.  The one that gets over-written on import.That>makes sense.  And is definitely do-able.
>>Please file a ticket.>>Can you point me to how to file a ticket.ThanksGo to http://projects.scipy.org/scipy/numpy/report
, login or register (required), then choose new ticket from the menu at the top.BTW, I wish all this was more transparent to the casual visitor to the scipy site. There should be a link on the front page (numpy bugs or something) and a short explanation about needing to register to file a new ticket. Maybe something in the Cookbook would help.
Chuck
-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


[Numpy-discussion] recent ubuntu package

2006-10-17 Thread Sven Schreiber
Hi,
as suggested on the website I use the kindly provided pre-built
(unofficial) ubuntu debs. Recently there is a new one available with
version numbe 1.0+~dev3336-0ads1.

Apart from the slightly strange +~ thing in there, it very much seems to
be based on trac changeset 3336, which is somewhere between rc2 and now,
right?

And just checking, what are the matplotlib packages that are compatible?
The most recent from the same package source seems to be
0.87.5-r2781-0ads2, is that ok with the above numpy? Will the mpl ubuntu
package before that break with the latest numpy ubuntu package?

Thanks for your help, and for the build effort,
Sven

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] array repr

2006-10-17 Thread Andrew MacKeith
Travis Oliphant wrote:

>Ah!,  I get it.  You want to be able to reset to the C-defined 
>array_repr function.  The one that gets over-written on import.That 
>makes sense.  And is definitely do-able.
>
>Please file a ticket.
>  
>
Can you point me to how to file a ticket.
Thanks

Andrew

>
>
>-Travis
>
>
>-
>Using Tomcat but need to do more? Need to support web services, security?
>Get stuff done quickly with pre-integrated technology to make your job easier
>Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>___
>Numpy-discussion mailing list
>Numpy-discussion@lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>
>  
>

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] array repr

2006-10-17 Thread Travis Oliphant

Ah!,  I get it.  You want to be able to reset to the C-defined 
array_repr function.  The one that gets over-written on import.That 
makes sense.  And is definitely do-able.

Please file a ticket.



-Travis


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Accessing data buffers in numpy scalars

2006-10-17 Thread Travis Oliphant
Lisandro Dalcin wrote:

>On 10/17/06, Travis Oliphant <[EMAIL PROTECTED]> wrote:
>  
>
>>Or you can use the Python C-API
>>
>>const char *buffer;
>>Py_ssize_t buflen;
>>
>>PyObject_AsReadBuffer(scalar, (const void **)&buffer, &buflen)
>>
>>to retrieve a pointer to the data in buffer and the size of the data in
>>buflen.
>>
>>
>>
>
>Travis. Have numpy something similar to a mutable scalar, or the only
>way is using an array whit only one element?
>  
>

0-dim arrays are still mutable scalars.

-Travis


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] dtype always copies

2006-10-17 Thread Charles R Harris
On 10/13/06, Stefan van der Walt <[EMAIL PROTECTED]> wrote:
Hi all,I've noticed that 'astype' always forces a copy.  Is thisbehaviour intended?  It seems to conflict with 'asarray', thattries to avoid a copy.For example, when wrapping code in ctypes, the following snippet
would have been useful:def foo(x):# ensure x is an array of the right typex = N.ascontiguousarray(x).astype(N.intc)but that will cause a copy, so you'll have to dodef foo(x):
try:x = N.ascontiguousarray(x,N.intc)except:x = N.ascontiguousarray(x).astype(N.intc)This seems to work now:
In [21]: aOut[21]: 
array([[ 1.,  2.],   [ 3.,  4.]])
In [22]: ascontiguousarray(a, dtype=int)Out[22]: 
array([[1, 2],   [3, 4]]) Chuck

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


[Numpy-discussion] matlab, filter function

2006-10-17 Thread Kenny Ortmann
just looking for some help, most of the time you guys are good with matlab 
code, i am trying to use the filter function under this setting

y = filter(b,a,X) filters the data in vector X with the filter described by 
numerator coefficient vector b and denominator coefficient vector a. If a(1) 
is not equal to 1, filter normalizes the filter coefficients by a(1). If 
a(1) equals 0, filter returns an error.

I pretty much have the same as the example, except my data array is 
different
data = [1:0.2:4]';
windowSize = 5;
filter(ones(1,windowSize)/windowSize,1,data)
ans =
0.2000
0.4400
0.7200
1.0400
1.4000
1.6000
1.8000
2.
2.2000
2.4000
2.6000
2.8000
3.
3.2000
3.4000
3.6000

my question is does numpy/scipy have a function for this, if not the 
algorithm states
y(n) = b(1)*x(n) + b(2)*x(n-1) + ... + b(nb+1)*x(n-nb)
 - a(2)*y(n-1) - ... - a(na+1)*y(n-na)but a is a number not 
an arrayThanks for the help,~Kenny 


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Casting

2006-10-17 Thread Charles R Harris
On 10/12/06, Cristian Codorean <[EMAIL PROTECTED]> wrote:
Hello list,   I got some old code that uses Scientific and Numeric. Recently, these two packages were updated to the latest versions together with python and my code started failing. The first major problem I have is when downcasting. Code that used to work now fails because the array cannot be safely cast anymore to the required type. If anyone could help me please and direct me to some documentation about when this change happened (version), why it happened, is there any other solution but using astype, can numpy help me in anyway in this situation, because I got really lost ...
This seems related to a more recent thread. Travis says that numeric throwing an error on downcasting is traditional, so I am curious as to why the previous code should have worked.Chuck

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] array repr

2006-10-17 Thread Andrew MacKeith
Travis Oliphant wrote:

>Andrew MacKeith wrote:
>
>  
>
>>I would like to use the built-in array_repr in numpy, because
>>I need a fast repr that does not contain new line characters.
>>I see no way of doing this without editing the code in numeric.py,
>>and I hate to edit other people's libraries.
>>
>>
>>
>>from numpy import array
>  
>
>>causes numeric.py to be executed, which includes a call to
>>multiarray.set_string_function(array_repr, 1)
>>
>>If I want to "undo" this, there is no way of doing it.
>> 
>>
>>
>>
>Why do want to "undo" this? 
>
>  
>
>>I would like to unset the repr with:
>>numpy.set_string_function(None, 1)
>> 
>>
>>
>>
>I don't understand what you are trying to do.  Why don't you just set 
>the string function to an actual callable.  
>
Since arrayobject.c contains a fast repr function, I would like to use 
that. Why reinvent the wheel.

>What edits do you propose to 
>make?
>  
>
If you mean how would I propose to change the code, I would have
array_set_string_function recognise None as an acceptable argument
and PyArray_SetStringFunction would recognise this to set
PyArray_ReprFunction = array_repr;

These is the (untested) code.

multiarraymodule.c:
static PyObject *
array_set_string_function(PyObject *dummy, PyObject *args, PyObject *kwds)
{
PyObject *op;
int repr=1;
static char *kwlist[] = {"f", "repr", NULL};

if(!PyArg_ParseTupleAndKeywords(args, kwds, "O|i", kwlist,
&op, &repr)) return NULL;
if (!PyCallable_Check(op) and op != Py_None) {
PyErr_SetString(PyExc_TypeError,
"Argument must be callable.");
return NULL;
}
PyArray_SetStringFunction(op, repr);
Py_INCREF(Py_None);
return Py_None;
}

arrayobject.c:
static void
PyArray_SetStringFunction(PyObject *op, int repr)
{
if (repr) {
/* Dispose of previous callback */
Py_XDECREF(PyArray_ReprFunction);
if (op == Py_None)
{
PyArray_ReprFunction = array_repr;
}
else
{
/* Add a reference to new callback */
Py_XINCREF(op);
/* Remember new callback */
PyArray_ReprFunction = op;
}
} else {
/* Dispose of previous callback */
Py_XDECREF(PyArray_StrFunction);
if (op == Py_None)
{
PyArray_StrFunction = array_str;
}
else
{
/* Add a reference to new callback */
Py_XINCREF(op);
/* Remember new callback */
PyArray_StrFunction = op;
}
}
}

>-Travis
>
>
>
>-
>Using Tomcat but need to do more? Need to support web services, security?
>Get stuff done quickly with pre-integrated technology to make your job easier
>Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>___
>Numpy-discussion mailing list
>Numpy-discussion@lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>
>  
>

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Accessing data buffers in numpy scalars

2006-10-17 Thread Lisandro Dalcin
On 10/17/06, Travis Oliphant <[EMAIL PROTECTED]> wrote:
> Or you can use the Python C-API
>
> const char *buffer;
> Py_ssize_t buflen;
>
> PyObject_AsReadBuffer(scalar, (const void **)&buffer, &buflen)
>
> to retrieve a pointer to the data in buffer and the size of the data in
> buflen.
>

Travis. Have numpy something similar to a mutable scalar, or the only
way is using an array whit only one element?


-- 
Lisandro Dalcín
---
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] What does Fortran order mean?

2006-10-17 Thread Lisandro Dalcin
On 10/17/06, Travis Oliphant <[EMAIL PROTECTED]> wrote:
> The require command can help you get the right kind of
> array for that purpose.
>

BTW, Travis

In [1]: numpy.__version__
Out[1]: '1.0rc2'

In [2]: print numpy.require.__doc__
None

What is this 'requirements' argument? What should user pass in?. I
seen sorce code at numpy.core.numeric.require. It seems this functions
expects an iterable producing string. I am right?


-- 
Lisandro Dalcín
---
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] array repr

2006-10-17 Thread Travis Oliphant
Andrew MacKeith wrote:

>I would like to use the built-in array_repr in numpy, because
>I need a fast repr that does not contain new line characters.
>I see no way of doing this without editing the code in numeric.py,
>and I hate to edit other people's libraries.
>
>from numpy import array
>causes numeric.py to be executed, which includes a call to
>multiarray.set_string_function(array_repr, 1)
>
>If I want to "undo" this, there is no way of doing it.
>  
>
Why do want to "undo" this? 

>I would like to unset the repr with:
>numpy.set_string_function(None, 1)
>  
>
I don't understand what you are trying to do.  Why don't you just set 
the string function to an actual callable.  What edits do you propose to 
make?

-Travis



-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Why doesn't array(a, dtype=single, copy=0) downcast a double array.

2006-10-17 Thread Charles R Harris
On 10/17/06, Travis Oliphant <[EMAIL PROTECTED]> wrote:
Travis Oliphant wrote:>Charles R Harris wrote:> 
>The long-standing behavior is to raise the error on possible-loss>conversion and so my opinion is that we should continue with that behavior.>>>But, on the other hand, it looks like numarray went the other direction
and allows a cast using the array call.Thusimport numarraya = numarray.array([1,2,3],'d')numarray.array(a, 'f')worksSo, I'm willing to go with the numarray behavior in numpy.
Thanks for the change, Travis. I'll wait a bit to make sure the API remains stable and then do some cleanups in linalg. Correctness before optimization and all that. I did note that the LaPack interface could throw an error at the fortran level that would issue an informative error message and dump me out of python. Is there anyway you know of to trap this behaviour?
Chuck 
-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


[Numpy-discussion] array repr

2006-10-17 Thread Andrew MacKeith
I would like to use the built-in array_repr in numpy, because
I need a fast repr that does not contain new line characters.
I see no way of doing this without editing the code in numeric.py,
and I hate to edit other people's libraries.

from numpy import array
causes numeric.py to be executed, which includes a call to
multiarray.set_string_function(array_repr, 1)

If I want to "undo" this, there is no way of doing it.

I would like to unset the repr with:
numpy.set_string_function(None, 1)
but this raises a TypeError because None is not callable.

This behavior was the same in Numeric, and in that case I edited the
code in Numeric.py but it would be nice if I didn't have to do that.

Should I submit a patch for this?

Andrew MacKeith


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Why doesn't array(a, dtype=single, copy=0) downcast a double array.

2006-10-17 Thread Travis Oliphant
Travis Oliphant wrote:

>Charles R Harris wrote:
>  
>
>>It seems to me that since the behaviour when copy=0 is to make a copy 
>>only if necessary, it should find it necessary and make the downcast. 
>>After all, array(a, dtype=single, copy=1) does just that without 
>>complaint. Some common code in linalg could be replaced if array and 
>>asarray would do that operation.
>>
>>
>>
>Well, the fact that it makes the copy without raising an error is 
>different behavior from Numeric and should be considered an unintended 
>change.
>
>We definitely should make this consistent for copy=0 or copy=1.  The 
>only question, is do we raise the error in both cases or allow the 
>conversion in both cases.
>
>The long-standing behavior is to raise the error on possible-loss 
>conversion and so my opinion is that we should continue with that behavior.
>
>  
>
But, on the other hand, it looks like numarray went the other direction 
and allows a cast using the array call.

Thus

import numarray
a = numarray.array([1,2,3],'d')
numarray.array(a, 'f')

works


So, I'm willing to go with the numarray behavior in numpy.


-Travis


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] What does Fortran order mean?

2006-10-17 Thread Travis Oliphant
Stefan van der Walt wrote:

>On Tue, Oct 17, 2006 at 10:01:51AM -0600, Travis Oliphant wrote:
>  
>
>>Charles R Harris wrote:
>>
>>
>>
>>>Travis,
>>>
>>>I note that
>>>
>>>  
>>>
>>a = arange(6).reshape(2,3,order='F')
>>a
>>
>>
>>>array([[0, 1, 2],
>>>   [3, 4, 5]])
>>>
>>>Shouldn't that be 3x2? Or maybe [[0,2,4],[1,3,5]]? Reshape is making a 
>>>copy, but flat, flatten, and tostring all show the elements in 'C' 
>>>order. I ask because I wonder if changing the order can be used to 
>>>prepare arrays for input into the LaPack routines.
>>>  
>>>
>>The order argument to reshape means (how should the big-chunk of data be 
>>interpreted when you reshape).  So, yes, this should be 
>>[[0,2,4],[1,3,5]].  It is a bug that it does not do the right thing in 
>>this case.
>>
>>
>
>A bit counter-ituitive (I somehow expect reshape to return an array
>that satisfies all the constraints specified as parameters -- i.e.
>shape and order in memory), but consistent with Numeric.
>  
>
Perhaps, but that is not what reshape does.  When you are reshaping an 
array, unless you are just adding ones to the shape somewhere or aren't 
actually changing the shape, then you are implicitly thinking about the 
array as a 1-d chunk of memory in some order.   The default is C-order.  
The order argument let's you think about it differently.

>What confuses me is that, if you call the array constructor, you get
>
>In [2]: N.array(N.array([[1,2,3],[4,5,6]]),order='F')
>Out[2]: 
>array([[1, 2, 3],
>   [4, 5, 6]])
>
>so here 'order' means something else.
>  
>

Not really.  I can't imagine what else you would expect here.  You have 
specified the array explicitly.  The order argument only specifies how 
the array will be arranged in memory.  It is an implementation detail.  
The user is allowed some control in order to interface to compiled code 
more effectively.

>So then you do
>
>x = N.array([[0,1,2],[3,4,5]],order='F')
>x.reshape((2,3),order='C')
>
>and you get
>
>array([[0, 1, 2],
>   [3, 4, 5]])
>
>  
>

I don't see the problem. 

The first line gives you an array:

[[0,1,2],
 [3,4,5]]

which in memory is laid out as [0,3,1,4,2,5]

The second line says reshape into a (2,3) array but this is exactly the 
same shape as the input array so in fact only a new view of the same 
data is given to you.   The fact that you specify order is 
inconsequential since you aren't really changing the shape, it doesn't 
matter.

The reshape command is not intended to alter the underlying ordering of 
an input array.   The ordering of an array is an implementation detail 
that shouldn't matter to the user unless you are trying to interface to 
compiled code.   The require command can help you get the right kind of 
array for that purpose.

In general, arrays can have arbitrary strides.  C-order and 
Fortran-order are just two special cases of that generality.   So, you 
cannot think of any array as just being either in C-order or 
Fortran-order. 

-Travis







-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] What does Fortran order mean?

2006-10-17 Thread Stefan van der Walt
On Tue, Oct 17, 2006 at 10:01:51AM -0600, Travis Oliphant wrote:
> Charles R Harris wrote:
> 
> > Travis,
> >
> > I note that
> >
> > >>> a = arange(6).reshape(2,3,order='F')
> > >>> a
> > array([[0, 1, 2],
> >[3, 4, 5]])
> >
> > Shouldn't that be 3x2? Or maybe [[0,2,4],[1,3,5]]? Reshape is making a 
> > copy, but flat, flatten, and tostring all show the elements in 'C' 
> > order. I ask because I wonder if changing the order can be used to 
> > prepare arrays for input into the LaPack routines.
> 
> 
> The order argument to reshape means (how should the big-chunk of data be 
> interpreted when you reshape).  So, yes, this should be 
> [[0,2,4],[1,3,5]].  It is a bug that it does not do the right thing in 
> this case.

A bit counter-ituitive (I somehow expect reshape to return an array
that satisfies all the constraints specified as parameters -- i.e.
shape and order in memory), but consistent with Numeric.

What confuses me is that, if you call the array constructor, you get

In [2]: N.array(N.array([[1,2,3],[4,5,6]]),order='F')
Out[2]: 
array([[1, 2, 3],
   [4, 5, 6]])

so here 'order' means something else.

So then you do

x = N.array([[0,1,2],[3,4,5]],order='F')
x.reshape((2,3),order='C')

and you get

array([[0, 1, 2],
   [3, 4, 5]])

Hmm.

Cheers
Stéfan

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Accessing data buffers in numpy scalars

2006-10-17 Thread Francesc Altet
A Dimarts 17 Octubre 2006 18:22, Travis Oliphant va escriure:
> >2.- Fetch the buffer in scalartype.data and use the buffer protocol in
> > order to access the pointer to data in memory. However, I lack experience
> > in buffer protocol, so suggestions for achieving this are welcome.
>
> This will also work.   A read-only buffer protocol is exported by all
> the scalars.
>
> scalar.data will return a buffer object.
>
> Or you can use the Python C-API
>
> const char *buffer;
> Py_ssize_t buflen;
>
> PyObject_AsReadBuffer(scalar, (const void **)&buffer, &buflen)

Oh, this one seems pretty easy, and as a plus, you don't have to book memory 
for copying the data area, so I'll use it.

Thanks,

-- 
>0,0<   Francesc Altet     http://www.carabos.com/
V   V   Cárabos Coop. V.   Enjoy Data
 "-"

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Accessing data buffers in numpy scalars

2006-10-17 Thread Travis Oliphant
Francesc Altet wrote:

>Hi,
>
>I'm looking for an easy way to access the data area of the numpy scalars no 
>matter its type.  I've seen that numpy/arrayscalars.h define a structure for 
>each scalar type, so I'd guess that it will not be possible to find a general 
>way for accessing the data buffer for each type. So, I've decided to look for 
>a workaround and I've devised a couple of possibilities:
>  
>
This problem showed up in writing NumPy several times.

One solution might be to use

PyArray_ScalarAsCtype(PyObject *scalar, void *ctypeptr)

which will copy the data into the area pointed to by ctypeptr (unless 
you have a "flexible scalar" in which case only a pointer to the 
data-area will be copied).


>2.- Fetch the buffer in scalartype.data and use the buffer protocol in order 
>to access the pointer to data in memory. However, I lack experience in buffer 
>protocol, so suggestions for achieving this are welcome.
>  
>
This will also work.   A read-only buffer protocol is exported by all 
the scalars.

scalar.data will return a buffer object.

Or you can use the Python C-API

const char *buffer;
Py_ssize_t buflen;

PyObject_AsReadBuffer(scalar, (const void **)&buffer, &buflen)

to retrieve a pointer to the data in buffer and the size of the data in 
buflen.


-Travis






-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


[Numpy-discussion] Accessing data buffers in numpy scalars

2006-10-17 Thread Francesc Altet
Hi,

I'm looking for an easy way to access the data area of the numpy scalars no 
matter its type.  I've seen that numpy/arrayscalars.h define a structure for 
each scalar type, so I'd guess that it will not be possible to find a general 
way for accessing the data buffer for each type. So, I've decided to look for 
a workaround and I've devised a couple of possibilities:

1.- Promote the scalar type to a ndarray object and use the regular ndarray C 
structure to access the data buffer.

2.- Fetch the buffer in scalartype.data and use the buffer protocol in order 
to access the pointer to data in memory. However, I lack experience in buffer 
protocol, so suggestions for achieving this are welcome.

If there is some other trivial way that I haven't devised (specially if usable 
from pyrex), please tell me about.

TIA,

-- 
>0,0<   Francesc Altet     http://www.carabos.com/
V   V   Cárabos Coop. V.   Enjoy Data
 "-"

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] What does Fortran order mean?

2006-10-17 Thread Travis Oliphant
Charles R Harris wrote:

> Travis,
>
> I note that
>
> >>> a = arange(6).reshape(2,3,order='F')
> >>> a
> array([[0, 1, 2],
>[3, 4, 5]])
>
> Shouldn't that be 3x2? Or maybe [[0,2,4],[1,3,5]]? Reshape is making a 
> copy, but flat, flatten, and tostring all show the elements in 'C' 
> order. I ask because I wonder if changing the order can be used to 
> prepare arrays for input into the LaPack routines.


The order argument to reshape means (how should the big-chunk of data be 
interpreted when you reshape).  So, yes, this should be 
[[0,2,4],[1,3,5]].  It is a bug that it does not do the right thing in 
this case.

I've committed a fix to SVN and a test for this case.

-Travis


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


[Numpy-discussion] hyper complex numbers

2006-10-17 Thread gary thompson
what is the best and most efficiednt way to deal with hyper complex numbers in numpy/scipye.g.for a 1d array we have a complex number containing real and imaginary pairs... conceptually we have((r,i),(r,i)...(r,i))
however, for a hypercomplex number in 2d we have quartets of numbers e.g.((rr,ir,ir,ii),rr,ir,ir,ii)),((rr,ir,ir,ii),rr,ir,ir,ii)),...((rr,ir,ir,ii),rr,ir,ir,ii)),
or planes of complex numbersr.((r,i),(r,i)...(r,i)),
((r,i),(r,i)...(r,i)),
.
.
.((r,i),(r,i)...(r,i))
i.
((r,i),(r,i)...(r,i)),

((r,i),(r,i)...(r,i)),

.

.

.
((r,i),(r,i)...(r,i))

that is the best way to deal with these in scipy/numpy especially with respect to 2D fourier transforms and data processingregardsgary


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Subversion

2006-10-17 Thread Jeff Strunk
This was a problem in Virtualmin when I created the mpi4py virtual server. I 
reverted the change, and everything seems to work now.

Sorry for the inconvenience,
Jeff

On Monday 16 October 2006 10:14 pm, Robert Kern wrote:
> Charles R Harris wrote:
> > Subversion seems to be down. I get the following message:
> >
> > Authentication realm:  mpi4py.scipy.org
> > 
> >
> > mpi4py? And I am asked for my password, which doesn't work. Scipy.org
> >  also seems to be down. You folks having trouble there?
>
> Apparently. I've contacted Jeff Strunk, the sysadmin.

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Testing numpy without doing an installation?

2006-10-17 Thread pearu

On Tue, 17 Oct 2006, Stefan van der Walt wrote:

> On Tue, Oct 17, 2006 at 10:03:03AM +0200, Francesc Altet wrote:
> > A Divendres 13 Octubre 2006 22:20, Lisandro Dalcin va escriure:
> > > On 10/13/06, Francesc Altet <[EMAIL PROTECTED]> wrote:
> > > > Is it possible to test a numpy version directly from the source
> > > > directory without having to install it?
> > >
> > > I usually do:
> > >
> > > $ python setup.py build
> > > $ python setup.py install --home=/tmp
> > > $ export PYTHONPATH=/tmp/lib/python
> > 
> > Thanks for your answer Lisandro, but what I want is to completely avoid an 
> > installation. The idea is to be able to test the local copy version of 
> > numpy 
> > in the development directory while doing small changes on it. Having to do 
> > the install step slows down the testing phase when doing small
> > changes.
> 
> It would be great if we could get this to work.  One problem is that
> distutils won't build the C-modules in place.  Does anyone know of a
> workaround?

Actually numpy.distutils supports in place builds of C modules.
However, its rather difficult to make numpy inplace to work for the
following reasons:
- to build a numpy based C extension, you'll need numpy header files
- numpy header files are generated during numpy build
So it is a chicken-egg problem.

One workaround for testing a numpy subpackage would be installing 
numpy and then doing inplace build in numpy subpackage directory. For
example:
  
  cd svn/numpy
  python setup.py install
  cd numpy/fft
  python setup.py build build_ext --inplace

Another workaround would be to install only numpy.core (that contains
numpy headers) and then doing inplace builds in numpy source directory ---
this, however, requires some setup.py modifications.

IMO, doing inplace builds has side effects that can easily lead to
shooting to a leg. While developing numpy, I would recommend always
installing numpy to some place, setting PYTHONPATH accordingly, write
unittests, and run them for testing. When test_*.py files are set up
properly then you don't need to install everytime you modify unittests,
they can be run inplace.

Pearu


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] What does Fortran order mean?

2006-10-17 Thread Stefan van der Walt
On Mon, Oct 16, 2006 at 02:20:04PM -0600, Charles R Harris wrote:
> Travis,
> 
> I note that
> 
> >>> a = arange(6).reshape(2,3,order='F')
> >>> a
> array([[0, 1, 2],
>[3, 4, 5]])
> 
> Shouldn't that be 3x2? Or maybe [[0,2,4],[1,3,5]]? Reshape is making a copy,
> but flat, flatten, and tostring all show the elements in 'C' order. I ask
> because I wonder if changing the order can be used to prepare arrays for input
> into the LaPack routines.

I think that the calculation of 'a' above is correct, but that the
memory representation is incorrect.  For example (see attached script
-- which is overkill, I know), these commands:

x = N.arange(6,dtype=float).reshape((2,3),order='F')
catmem(x)

x = N.array([[0,1,2],[3,4,5]],order='F',dtype=float)
catmem(x)

x = N.array(N.arange(6,dtype=float).reshape((2,3)),order='F')
catmem(x)

x = N.asfortranarray(N.arange(6,dtype=float).reshape((2,3)))
catmem(x)

yield the following results:

0.00 1.00 2.00 3.00 4.00 5.00 
0.00 3.00 1.00 4.00 2.00 5.00 
0.00 3.00 1.00 4.00 2.00 5.00 
0.00 3.00 1.00 4.00 2.00 5.00 

Regards
Stéfan
#include 

void catmem(int N, double* p)
{
   int i;
   for (i = 0; i < N; i++)
 printf("%f ", p[i]);
   printf("\n");
}
from glob import glob

env = Environment()
env.Replace(CCFLAGS=['-O2','-Wall','-ansi','-pedantic'])
env.SharedLibrary('catmem', ['catmem.c'])
import numpy as N
from ctypes import c_int
import sys

try:
_lib = N.ctypeslib.load_library('libcatmem',__file__)
except OSError:
print "Cannot load libcatmem.so, run 'scons' to compile."
sys.exit(1)

_lib.catmem.restype = None
_lib.catmem.argtypes = [c_int,N.ctypeslib.ndpointer(dtype=N.double)]

def catmem(x):
_lib.catmem(x.size,x)

x = N.arange(6,dtype=float).reshape((2,3),order='F')
catmem(x)

x = N.array([[0,1,2],[3,4,5]],order='F',dtype=float)
catmem(x)

x = N.array(N.arange(6,dtype=float).reshape((2,3)),order='F')
catmem(x)

x = N.asfortranarray(N.arange(6,dtype=float).reshape((2,3)))
catmem(x)
-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Testing numpy without doing an installation?

2006-10-17 Thread Stefan van der Walt
On Tue, Oct 17, 2006 at 10:03:03AM +0200, Francesc Altet wrote:
> A Divendres 13 Octubre 2006 22:20, Lisandro Dalcin va escriure:
> > On 10/13/06, Francesc Altet <[EMAIL PROTECTED]> wrote:
> > > Is it possible to test a numpy version directly from the source
> > > directory without having to install it?
> >
> > I usually do:
> >
> > $ python setup.py build
> > $ python setup.py install --home=/tmp
> > $ export PYTHONPATH=/tmp/lib/python
> 
> Thanks for your answer Lisandro, but what I want is to completely avoid an 
> installation. The idea is to be able to test the local copy version of numpy 
> in the development directory while doing small changes on it. Having to do 
> the install step slows down the testing phase when doing small
> changes.

It would be great if we could get this to work.  One problem is that
distutils won't build the C-modules in place.  Does anyone know of a
workaround?

At the moment, if you run numpy from the source directory, you see the
message

In [1]: import numpy
Running from numpy source directory.

after which you can't access any of the numpy functions.  This would
be due to this snippet in __init__.py:

try:
from __config__ import show as show_config
except ImportError:
show_config = None

if show_config is None:
import sys as _sys
print >> _sys.stderr, 'Running from numpy source directory.'
del _sys

If we declare set_package_path and restore_path in __init__.py, we can
wrap all imports in numpy with

set_package_path('../../..') # set path back required depth
from numpy import whatever, you, need
restore_path()

That would take care of things on the python side, at least.

Cheers
Stéfan

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Testing numpy without doing an installation?

2006-10-17 Thread Francesc Altet
A Divendres 13 Octubre 2006 22:20, Lisandro Dalcin va escriure:
> On 10/13/06, Francesc Altet <[EMAIL PROTECTED]> wrote:
> > Is it possible to test a numpy version directly from the source
> > directory without having to install it?
>
> I usually do:
>
> $ python setup.py build
> $ python setup.py install --home=/tmp
> $ export PYTHONPATH=/tmp/lib/python

Thanks for your answer Lisandro, but what I want is to completely avoid an 
installation. The idea is to be able to test the local copy version of numpy 
in the development directory while doing small changes on it. Having to do 
the install step slows down the testing phase when doing small changes.

Cheers,

-- 
>0,0<   Francesc Altet     http://www.carabos.com/
V   V   Cárabos Coop. V.   Enjoy Data
 "-"

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion