Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Markov process representation

Reply
Thread Tools

Re: Markov process representation

 
 
kpp9c
Guest
Posts: n/a
 
      03-15-2006
This is wicked! I am trying to get it to work and am frantically fixing
tabs and spaces... but isn't line 50:

self._all_states |= set(key[i] for key in probabilities)

an error? isn't it supposed to be:

self._all_states != set(key[i] for key in probabilities)

 
Reply With Quote
 
 
 
 
Scott David Daniels
Guest
Posts: n/a
 
      03-15-2006
kpp9c wrote:
> This is wicked! I am trying to get it to work and am frantically fixing
> tabs and spaces...

It was cut and pasted from working code (which I pasted back to test).

> but isn't line 50:
>
> self._all_states |= set(key[i] for key in probabilities)
>
> an error? isn't it supposed to be:
>
> self._all_states != set(key[i] for key in probabilities)
>

Nope. self._all_states is a set. I am collecting all mentioned states
from the key. Another way to do it is:
self._all_states = set()
for key in probabilities:
self._all_states = set(key)
-- key is a order-tuple of states.

--Scott David Daniels
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
kpp9c
Guest
Posts: n/a
 
      03-16-2006
try as i might i still get an error:

File "markov.py", line 50
self._all_states |= set(key[i] for key in probabilities)


I am running:

Python 2.3 (#1, Sep 13 2003, 00:49:11)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin

If that helps any...

Thanks!

 
Reply With Quote
 
Paul Rubin
Guest
Posts: n/a
 
      03-16-2006
"kpp9c" <(E-Mail Removed)> writes:
> self._all_states |= set(key[i] for key in probabilities)
> I am running:
> Python 2.3 (#1, Sep 13 2003, 00:49:11)


generator comprehensions are new in 2.4. Try:

self._all_states |= set([key[i] for key in probabilities])

This does temporarily use more memory.
 
Reply With Quote
 
Jack Diederich
Guest
Posts: n/a
 
      03-16-2006
On Wed, Mar 15, 2006 at 04:50:31PM -0800, Paul Rubin wrote:
> "kpp9c" <(E-Mail Removed)> writes:
> > self._all_states |= set(key[i] for key in probabilities)
> > I am running:
> > Python 2.3 (#1, Sep 13 2003, 00:49:11)

>
> generator comprehensions are new in 2.4. Try:
>
> self._all_states |= set([key[i] for key in probabilities])


And sets aren't a builtin in 2.3

try:
set()
except NameError:
import sets
set = sets.Set

-Jack
 
Reply With Quote
 
kpp9c
Guest
Posts: n/a
 
      03-16-2006
yes looking at this code i see a few things i haven't seem before. I am
on Mac OS X 10.3.x and updating the python seems like a non trivial
task at the moment.. i will try that and see where that gets me. Thanks.

 
Reply With Quote
 
kpp9c
Guest
Posts: n/a
 
      03-16-2006
oh ... uhmm .. i don't follow what you are saying... where should i put
those lines... should the import thing go on top?

 
Reply With Quote
 
kpp9c
Guest
Posts: n/a
 
      03-16-2006
hee hee .... works fine ... but kinda slow on my old machine... really
time for a new laptop haha!

still this code is so beautiful! *^-^*

 
Reply With Quote
 
Max M
Guest
Posts: n/a
 
      03-16-2006
Jack Diederich wrote:
> On Wed, Mar 15, 2006 at 04:50:31PM -0800, Paul Rubin wrote:
>
>>"kpp9c" <(E-Mail Removed)> writes:
>>
>>> self._all_states |= set(key[i] for key in probabilities)
>>>I am running:
>>>Python 2.3 (#1, Sep 13 2003, 00:49:11)

>>
>>generator comprehensions are new in 2.4. Try:
>>
>> self._all_states |= set([key[i] for key in probabilities])

>
>
> And sets aren't a builtin in 2.3
>
> try:
> set()
> except NameError:
> import sets
> set = sets.Set


nitpick:

try:
set
except NameError:
from sets import Set as set

--

hilsen/regards Max M, Denmark

http://www.mxm.dk/
IT's Mad Science

Phone: +45 66 11 84 94
Mobile: +45 29 93 42 96
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Markov Analysis Help bearophileHUGS@lycos.com Python 2 05-17-2008 08:05 PM
markov chains Sigma2 Digital Photography 0 11-30-2007 02:30 PM
[SOLUTION] Markov Chain (#74) semmons99@gmail.com Ruby 0 04-09-2006 01:19 PM
markov query kpp9c Python 5 03-15-2006 01:12 AM
Markov chain with extras? temp@mclift.fsnet.co.uk Python 7 05-19-2005 06:23 PM



Advertisments