Thanks Diez,
It will take a little while for this one to sink in but it gets the job
done now and will for future cases.
/Sheldon
Diez B. Roggisch skrev:
> >> print [i for i, _ in enumerate((None for x, y in zip(a, b) where x ==
> >> y))]
> >>
> >> instead.
> >>
> >> Diez
> >
> > Hi Diez,
> >
>
Thanks Diez,
It will take a little while for this one to sink in but it gets the job
done now and will for future cases.
/Sheldon
Diez B. Roggisch skrev:
> >> print [i for i, _ in enumerate((None for x, y in zip(a, b) where x ==
> >> y))]
> >>
> >> instead.
> >>
> >> Diez
> >
> > Hi Diez,
> >
>
Diez B. Roggisch wrote:
> Maric Michaud wrote:
>
>> Le Mardi 20 Juin 2006 12:09, Diez B. Roggisch a écrit :
>>> [i for i, equals in enumerate((x == y for x, y in zip(a, b))) if equals]
>> No needs to nest comprehensions, should be :
>> [ i for i, v in enumerate(zip(a, b)) if v[0] == v[1] ]
>
> Yo
Maric Michaud wrote:
> Le Mardi 20 Juin 2006 12:09, Diez B. Roggisch a écrit :
>> [i for i, equals in enumerate((x == y for x, y in zip(a, b))) if equals]
>
> No needs to nest comprehensions, should be :
>
> [ i for i, v in enumerate(zip(a, b)) if v[0] == v[1] ]
You're right, that design stemme
Le Mardi 20 Juin 2006 12:09, Diez B. Roggisch a écrit :
> [i for i, equals in enumerate((x == y for x, y in zip(a, b))) if equals]
No needs to nest comprehensions, should be :
[ i for i, v in enumerate(zip(a, b)) if v[0] == v[1] ]
--
_
Maric Michaud
_
Aristote - www.a
>> print [i for i, _ in enumerate((None for x, y in zip(a, b) where x ==
>> y))]
>>
>> instead.
>>
>> Diez
>
> Hi Diez,
>
> I wish I say that I understood what you wrote here but I can't.
> Do you mind explaining a little more?
I actually made a typo, instead of "where" in the above use "if". an
Diez B. Roggisch skrev:
> Diez B. Roggisch wrote:
>
> > print [i for i, _ in enumerate((None for v in zip(a, b) where v ==
> > (1,1)))]
> >
> > should give you the list of indices.
>
> I musunderstood your question. Use
>
>
> print [i for i, _ in enumerate((None for x, y in zip(a, b) where x == y
Bas wrote:
> You are comparing a normal python list to a constant, which are
> obviously unequal. Try converting your lists to arrays first
> (untested):
>
> import numeric/numpy as N
> a =N.array([0,1,2,5,6,6])
> b = N.array([5,4,1,6,4,6])
> print a==6 and b==6
> print N.where(a==6 and b==6)
Car
Diez B. Roggisch wrote:
> print [i for i, _ in enumerate((None for v in zip(a, b) where v ==
> (1,1)))]
>
> should give you the list of indices.
I musunderstood your question. Use
print [i for i, _ in enumerate((None for x, y in zip(a, b) where x == y))]
instead.
Diez
--
http://mail.python.
You are comparing a normal python list to a constant, which are
obviously unequal. Try converting your lists to arrays first
(untested):
import numeric/numpy as N
a =N.array([0,1,2,5,6,6])
b = N.array([5,4,1,6,4,6])
print a==6 and b==6
print N.where(a==6 and b==6)
hth,
Bas
Sheldon wrote:
> Hi,
Sheldon wrote:
> Hi,
>
> I have two arrays that are identical and contain 1s and zeros. Only the
Obviously they aren't identical. They may be of same size.
> ones are valid and I need to know where both arrays have ones in the
> same position. I thought logical_and would work but this example p
Hi,
I have two arrays that are identical and contain 1s and zeros. Only the
ones are valid and I need to know where both arrays have ones in the
same position. I thought logical_and would work but this example proves
otherwise:
>>> a = [0,1,2,5,6,6]
>>> b = [5,4,1,6,4,6]
>>> Numeric.logical_and(a=
12 matches
Mail list logo