Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cdc-counting
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Radek Hušek
cdc-counting
Commits
a4709bc2
Commit
a4709bc2
authored
3 years ago
by
Radek Hušek
Browse files
Options
Downloads
Patches
Plain Diff
drop unused track_origins parameter
parent
da706975
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
graph_tools/base.py
+12
-33
12 additions, 33 deletions
graph_tools/base.py
with
12 additions
and
33 deletions
graph_tools/base.py
+
12
−
33
View file @
a4709bc2
...
@@ -11,45 +11,27 @@ def _init_():
...
@@ -11,45 +11,27 @@ def _init_():
from
itertools
import
combinations
,
chain
,
product
from
itertools
import
combinations
,
chain
,
product
from
functools
import
reduce
from
functools
import
reduce
BoundaryValue
=
namedtuple
(
"
BoundaryValue
"
,
[
'
boundary
'
,
'
value
'
,
'
origins
'
])
BoundaryValue
=
namedtuple
(
"
BoundaryValue
"
,
[
'
boundary
'
,
'
value
'
])
BoundaryValue
.
with_origins
=
lambda
s
,
o
:
BoundaryValue
(
s
.
boundary
,
s
.
value
,
o
)
OriginJoinEdge
=
namedtuple
(
"
OriginJoinEdge
"
,
[
'
boundary
'
,
'
e1
'
,
'
e2
'
,
'
info
'
])
OriginJoinBoundaries
=
namedtuple
(
"
OriginJoinBoundaries
"
,
[
'
boundaries
'
,
'
info
'
])
# hack compatible with Python < 3.7
BoundaryValue
.
__new__
.
__defaults__
=
(
None
,
None
,
None
)
class
GraphParameterBase
:
class
GraphParameterBase
:
def
__hash__
(
self
):
return
id
(
self
)
def
__hash__
(
self
):
return
id
(
self
)
def
__eq__
(
self
,
b
):
return
self
is
b
def
__eq__
(
self
,
b
):
return
self
is
b
def
eval_join
(
self
,
multiplicity_vectors
,
joins
,
outs
,
offsets
,
track_origins
):
def
eval_join
(
self
,
multiplicity_vectors
,
joins
,
outs
,
offsets
):
def
join_boundaries
(
x
):
def
join_boundaries
(
x
):
return
self
.
join_boundaries
(
x
,
offsets
)
return
self
.
join_boundaries
(
x
,
offsets
)
#for info in self.join_boundaries_info(x, offsets):
# ret = self.join_boundaries(x, offsets, info)
# if ret is None: continue
# if track_origins: ret = ret.with_origins(OriginJoinBoundaries(x, info))
# yield ret
it
=
chain
.
from_iterable
(
join_boundaries
(
x
)
for
x
in
product
(
*
multiplicity_vectors
)
)
it
=
chain
.
from_iterable
(
join_boundaries
(
x
)
for
x
in
product
(
*
multiplicity_vectors
)
)
def
join
(
gen
,
e1
,
e2
):
def
join
(
gen
,
e1
,
e2
):
for
b
in
gen
:
for
b
in
gen
:
yield
from
self
.
join_edges
(
b
,
e1
,
e2
)
yield
from
self
.
join_edges
(
b
,
e1
,
e2
)
#for info in self.join_edges_info(b, e1, e2):
# ret = self.join_edges(b, e1, e2, info)
# if ret is None: continue
# if track_origins: ret = ret.with_origins([ OriginJoinEdge(b, e1, e2, info) ])
# yield ret
for
e1
,
e2
in
joins
:
it
=
join
(
it
,
e1
,
e2
)
for
e1
,
e2
in
joins
:
it
=
join
(
it
,
e1
,
e2
)
def
project_and_canonize
(
b
):
def
project_and_canonize
(
b
):
return
BoundaryValue
(
self
.
project_and_canonize
(
outs
,
b
.
boundary
),
b
.
value
,
b
.
origins
)
return
BoundaryValue
(
self
.
project_and_canonize
(
outs
,
b
.
boundary
),
b
.
value
)
it
=
(
project_and_canonize
(
b
)
for
b
in
it
)
it
=
(
project_and_canonize
(
b
)
for
b
in
it
)
...
@@ -57,9 +39,7 @@ def _init_():
...
@@ -57,9 +39,7 @@ def _init_():
for
b
in
it
:
for
b
in
it
:
if
b
.
boundary
in
ret
:
if
b
.
boundary
in
ret
:
ret
[
b
.
boundary
]
=
BoundaryValue
(
b
.
boundary
,
ret
[
b
.
boundary
]
=
BoundaryValue
(
b
.
boundary
,
self
.
merge_values
(
ret
[
b
.
boundary
].
value
,
b
.
value
),
self
.
merge_values
(
ret
[
b
.
boundary
].
value
,
b
.
value
))
ret
[
b
.
boundary
].
origins
+
b
.
origins
if
track_origins
else
None
)
else
:
else
:
ret
[
b
.
boundary
]
=
b
ret
[
b
.
boundary
]
=
b
...
@@ -129,11 +109,10 @@ def _init_():
...
@@ -129,11 +109,10 @@ def _init_():
_gadget_cache
=
utils
.
DynamicLRU
()
_gadget_cache
=
utils
.
DynamicLRU
()
def
eval
(
self
,
p
,
track_origins
=
False
,
**
kwargs
):
def
eval
(
self
,
p
,
**
kwargs
):
assert
self
.
is_graph
()
assert
self
.
is_graph
()
ret
=
self
.
eval_gadget
(
p
,
track_origins
=
track_origins
,
**
kwargs
)
ret
=
self
.
eval_gadget
(
p
,
**
kwargs
)
if
not
track_origins
:
return
p
.
finalize
(
ret
)
return
p
.
finalize
(
ret
)
return
(
p
.
finalize
(
ret
),
self
.
enumerate
(
ret
))
@staticmethod
@staticmethod
def
join
(
gadgets
,
joins
,
outs
,
*
,
no_cache
=
False
):
def
join
(
gadgets
,
joins
,
outs
,
*
,
no_cache
=
False
):
...
@@ -151,12 +130,12 @@ def _init_():
...
@@ -151,12 +130,12 @@ def _init_():
super
().
__init__
(
size
)
super
().
__init__
(
size
)
self
.
value
=
value
self
.
value
=
value
def
eval_gadget
(
self
,
_
,
track_origins
=
None
,
no_cache
=
False
):
def
eval_gadget
(
self
,
_
,
no_cache
=
False
):
return
self
.
value
return
self
.
value
class
BaseGadget
(
Gadget
):
class
BaseGadget
(
Gadget
):
def
eval_gadget
(
self
,
parameter
,
track_origins
=
None
,
no_cache
=
False
):
def
eval_gadget
(
self
,
parameter
,
no_cache
=
False
):
try
:
try
:
if
self
is
CUBIC_VERTEX
:
if
self
is
CUBIC_VERTEX
:
return
parameter
.
CUBIC_VERTEX
return
parameter
.
CUBIC_VERTEX
...
@@ -187,13 +166,13 @@ def _init_():
...
@@ -187,13 +166,13 @@ def _init_():
self
.
_info
=
(
tuple
(
gadgets
),
joins
,
outs
)
self
.
_info
=
(
tuple
(
gadgets
),
joins
,
outs
)
def
eval_gadget
(
self
,
parameter
,
track_origins
=
False
,
no_cache
=
False
):
def
eval_gadget
(
self
,
parameter
,
no_cache
=
False
):
gadgets
,
joins
,
outs
=
self
.
_info
gadgets
,
joins
,
outs
=
self
.
_info
def
do_eval
():
def
do_eval
():
ret
=
parameter
.
eval_join
(
ret
=
parameter
.
eval_join
(
[
g
.
eval_gadget
(
parameter
,
track_origins
=
track_origins
,
no_cache
=
no_cache
)
for
g
in
gadgets
],
[
g
.
eval_gadget
(
parameter
,
no_cache
=
no_cache
)
for
g
in
gadgets
],
joins
,
outs
,
self
.
offsets
,
track_origins
joins
,
outs
,
self
.
offsets
)
)
return
ret
return
ret
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment