Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Franck Pommereau
/
snakes
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Franck Pommereau
2012-04-05 12:47:36 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
53cf5cf2607c244ae7602dea331340ea3be6194b
53cf5cf2
1 parent
d287e063
fixed bug in environments
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
14 deletions
TODO
snakes/nets.py
TODO
View file @
53cf5cf
* add name to transitions, eg, [buff-(x) as name]
make it consistent with instance names?
* zero test/inhibitor arc
! parameter and global buffer with same names => parameter ignored
! accept net instances with too much parameters
...
...
snakes/nets.py
View file @
53cf5cf
...
...
@@ -24,7 +24,7 @@ class Evaluator (object) :
"""Initialize like a dict
"""
self
.
_env
=
dict
(
*
larg
,
**
karg
)
self
.
attached
=
set
()
self
.
attached
=
[]
def
__call__
(
self
,
expr
,
locals
=
{})
:
"""Evaluate an expression
"""
...
...
@@ -40,14 +40,15 @@ class Evaluator (object) :
namespace.
"""
self
.
_env
=
other
.
_env
other
.
attached
.
add
(
self
)
other
.
attached
.
append
(
self
)
# FIXME: should not need to use list() to remove infinite recursion
for
e
in
list
(
self
.
attached
)
:
e
.
attach
(
self
)
def
detach
(
self
,
other
)
:
"""Make this instance namespace independent
"""
self
.
_env
=
self
.
_env
.
copy
()
other
.
attached
.
discard
(
self
)
other
.
attached
.
remove
(
self
)
def
update
(
self
,
other
)
:
"""Update namespace from another evaluator
"""
...
...
@@ -80,17 +81,6 @@ class Evaluator (object) :
"""Test for inequality of namespaces
"""
return
not
self
.
__eq__
(
other
)
def
__hashone__
(
self
,
pair
)
:
try
:
return
hash
(
pair
)
except
:
return
hash
(
pair
[
0
])
def
__hash__
(
self
)
:
"""Return hash value
"""
return
reduce
(
operator
.
xor
,
(
self
.
__hashone__
(
i
)
for
i
in
self
),
113110355
)
##
## net element
...
...
Please
register
or
login
to post a comment