Re: [Numpy-discussion] [C++-sig] Overloading sqrt(5.5)*myvector

2007-12-26 Thread Robert Kern
Bruce Sherwood wrote: > Thanks for the suggestion. It hadn't occurred to me to try to override > numpy as you suggest. However, when I try the code shown below as the > start of a test of this scheme, I get the following error: > > Traceback (most recent call last): > File "C:\Documents and Se

Re: [Numpy-discussion] Overloading sqrt(5.5)*myvector

2007-12-26 Thread Robert Kern
Gary Ruben wrote: > Sorry this isn't an answer, just noise, but for those here who don't > know, Bruce is the chief maintainer of the vpython project. I have found > vpython aka the visual module to be a highly attractive and useful > module for teaching physics. It would be great if someone wit

Re: [Numpy-discussion] [C++-sig] Overloading sqrt(5.5)*myvector

2007-12-26 Thread Bruce Sherwood
Thanks for the suggestion. It hadn't occurred to me to try to override numpy as you suggest. However, when I try the code shown below as the start of a test of this scheme, I get the following error: Traceback (most recent call last): File "C:\Documents and Settings\Bruce\My Documents\0VPytho

Re: [Numpy-discussion] how do I list all combinations

2007-12-26 Thread Zachary Pincus
Hi all, I use numpy's own ndindex() for tasks like these: > In: numpy.ndindex? > Type: type > Base Class: > String Form: > Namespace: Interactive > File: /Library/Frameworks/Python.framework/Versions/2.4/ > lib/python2.4/site-packages/numpy/lib/index_tricks.py >

Re: [Numpy-discussion] how do I list all combinations

2007-12-26 Thread Timothy Hochberg
Here's a baroque way to do it using generated code: def cg_combinations(seqs): n = len(seqs) chunks = ["def f(%s):" % ', '.join('s%s' % i for i in range(n))] for i in reversed(range(n)): chunks.append(" " * (n -i) + "for x%s in s%s:" % (i, i)) chunks

Re: [Numpy-discussion] how do I list all combinations

2007-12-26 Thread Mathew Yeates
Thanks Chuck. Charles R Harris wrote: > > > On Dec 26, 2007 2:30 PM, Charles R Harris <[EMAIL PROTECTED] > > wrote: > > > > On Dec 26, 2007 1:45 PM, Keith Goodman <[EMAIL PROTECTED] > > wrote: > > On Dec 26, 2007 12:22 PM, Mathew

Re: [Numpy-discussion] how do I list all combinations

2007-12-26 Thread Charles R Harris
On Dec 26, 2007 2:30 PM, Charles R Harris <[EMAIL PROTECTED]> wrote: > > > On Dec 26, 2007 1:45 PM, Keith Goodman <[EMAIL PROTECTED]> wrote: > > > On Dec 26, 2007 12:22 PM, Mathew Yeates <[EMAIL PROTECTED]> wrote: > > > I have an arbitrary number of lists. I want to form all possible > > > combina

Re: [Numpy-discussion] how do I list all combinations

2007-12-26 Thread Charles R Harris
On Dec 26, 2007 1:45 PM, Keith Goodman <[EMAIL PROTECTED]> wrote: > On Dec 26, 2007 12:22 PM, Mathew Yeates <[EMAIL PROTECTED]> wrote: > > I have an arbitrary number of lists. I want to form all possible > > combinations from all lists. So if > > r1=["dog","cat"] > > r2=[1,2] > > > > I want to ret

Re: [Numpy-discussion] how do I list all combinations

2007-12-26 Thread Mathew Yeates
Which reference manual? René Bastian wrote: > Le Mercredi 26 Décembre 2007 21:22, Mathew Yeates a écrit : > >> Hi >> I've been looking at "fromfunction" and itertools but I'm flummoxed. >> >> I have an arbitrary number of lists. I want to form all possible >> combinations from all lists. So if

Re: [Numpy-discussion] how do I list all combinations

2007-12-26 Thread Mathew Yeates
yes, I came up with this and may use it. Seems like it would be insanely slow but my problem is small enough that it might be okay. Thanks Keith Goodman wrote: > On Dec 26, 2007 12:22 PM, Mathew Yeates <[EMAIL PROTECTED]> wrote: > >> I have an arbitrary number of lists. I want to form all po

Re: [Numpy-discussion] how do I list all combinations

2007-12-26 Thread Stuart Brorson
Hi -- >> I have an arbitrary number of lists. I want to form all possible >> combinations from all lists. So if >> r1=["dog","cat"] >> r2=[1,2] >> >> I want to return [["dog",1],["dog",2],["cat",1],["cat",2]] Try this: In [25]: [(x, y) for x in r1 for y in r2] Out[25]: [('dog', 1), ('dog', 2), (

Re: [Numpy-discussion] how do I list all combinations

2007-12-26 Thread René Bastian
Le Mercredi 26 Décembre 2007 21:22, Mathew Yeates a écrit : > Hi > I've been looking at "fromfunction" and itertools but I'm flummoxed. > > I have an arbitrary number of lists. I want to form all possible > combinations from all lists. So if > r1=["dog","cat"] > r2=[1,2] > > I want to return [["dog

Re: [Numpy-discussion] how do I list all combinations

2007-12-26 Thread Charles R Harris
On Dec 26, 2007 1:22 PM, Mathew Yeates <[EMAIL PROTECTED]> wrote: > Hi > I've been looking at "fromfunction" and itertools but I'm flummoxed. > > I have an arbitrary number of lists. I want to form all possible > combinations from all lists. So if > r1=["dog","cat"] > r2=[1,2] > > I want to return

Re: [Numpy-discussion] how do I list all combinations

2007-12-26 Thread Keith Goodman
On Dec 26, 2007 12:22 PM, Mathew Yeates <[EMAIL PROTECTED]> wrote: > I have an arbitrary number of lists. I want to form all possible > combinations from all lists. So if > r1=["dog","cat"] > r2=[1,2] > > I want to return [["dog",1],["dog",2],["cat",1],["cat",2]] > > It's obvious when the number of

[Numpy-discussion] how do I list all combinations

2007-12-26 Thread Mathew Yeates
Hi I've been looking at "fromfunction" and itertools but I'm flummoxed. I have an arbitrary number of lists. I want to form all possible combinations from all lists. So if r1=["dog","cat"] r2=[1,2] I want to return [["dog",1],["dog",2],["cat",1],["cat",2]] It's obvious when the number of lists

Re: [Numpy-discussion] Overloading sqrt(5.5)*myvector

2007-12-26 Thread Charles R Harris
On Dec 26, 2007 3:49 AM, Gary Ruben <[EMAIL PROTECTED]> wrote: > Sorry this isn't an answer, just noise, but for those here who don't > know, Bruce is the chief maintainer of the vpython project. I have found > vpython aka the visual module to be a highly attractive and useful > module for teachin

Re: [Numpy-discussion] Overloading sqrt(5.5)*myvector

2007-12-26 Thread Gary Ruben
Sorry this isn't an answer, just noise, but for those here who don't know, Bruce is the chief maintainer of the vpython project. I have found vpython aka the visual module to be a highly attractive and useful module for teaching physics. It would be great if someone with Boost experience would