Re: Numpy Array of Sets

2014-05-25 Thread LJ
Thank you very much! -- https://mail.python.org/mailman/listinfo/python-list

Re: Numpy Array of Sets

2014-05-25 Thread Peter Otten
LJ wrote: > Thank you for the reply. > > So, as long as I access and modify the elements of, for example, > > A=array([[set([])]*4]*3) > > > as (for example): > > a[0][1] = a[0][1] | set([1,2]) > > or: > > a[0][1]=set([1,2]) > > then I should have no problems? As long as you set (i. e. re

Re: Numpy Array of Sets

2014-05-25 Thread LJ
Thank you for the reply. So, as long as I access and modify the elements of, for example, A=array([[set([])]*4]*3) as (for example): a[0][1] = a[0][1] | set([1,2]) or: a[0][1]=set([1,2]) then I should have no problems? -- https://mail.python.org/mailman/listinfo/python-list

Re: Numpy Array of Sets

2014-05-25 Thread Peter Otten
LJ wrote: > Wolfgang, thank you very much for your reply. > > Following the example in the link, the problem appears: > A = [[0]*2]*3 You can see this as a shortcut for value = 0 inner = [value, value] A = [inner, inner, inner] When the value is mutable (like your original set) a modific

Re: Numpy Array of Sets

2014-05-25 Thread LJ
Wolfgang, thank you very much for your reply. Following the example in the link, the problem appears: >>> A = [[0]*2]*3 >>> A [[0, 0], [0, 0], [0, 0]] >>> A[0][0] = 5 >>> A [[5, 0], [5, 0], [5, 0]] Now, if I use a numpy array: >>> d=array([[0]*2]*3) >>> d array([[0, 0], [0, 0], [0

Re: Numpy Array of Sets

2014-05-24 Thread Wolfgang Maier
On 25.05.2014 00:14, Robert Kern wrote: On 2014-05-24 23:05, Luis José Novoa wrote: Hi All, Hope you're doing great. One quick question. I am defining an array of sets using numpy as: a=array([set([])]*3) Has nothing to do with numpy, but the problem is exclusively with your innermost expr

Re: Numpy Array of Sets

2014-05-24 Thread Robert Kern
On 2014-05-24 23:05, Luis José Novoa wrote: Hi All, Hope you're doing great. One quick question. I am defining an array of sets using numpy as: a=array([set([])]*3) Now, if I want to add an element to the set in, lets say, a[0], and I use the .add(4) operation, which results in: array([set(

Numpy Array of Sets

2014-05-24 Thread Luis José Novoa
Hi All, Hope you're doing great. One quick question. I am defining an array of sets using numpy as: a=array([set([])]*3) Now, if I want to add an element to the set in, lets say, a[0], and I use the .add(4) operation, which results in: array([set([4]), set([4]), set([4])], dtype=object) whi