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 teaching

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

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 lists is not

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), ('cat', 1), ('cat', 2)]

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 r1=[dog,cat]

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

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 combinations from all

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 return

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] mailto:[EMAIL PROTECTED] wrote: On Dec 26, 2007 1:45 PM, Keith Goodman [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: On Dec 26, 2007 12:22 PM, Mathew Yeates [EMAIL

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))

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: type 'type' String Form:class 'numpy.lib.index_tricks.ndindex' Namespace: Interactive File: /Library/Frameworks/Python.framework/Versions/2.4/

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 with