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
c76faacc
Commit
c76faacc
authored
5 years ago
by
Radek Hušek
Browse files
Options
Downloads
Patches
Plain Diff
simplify project_and_canonize()
parent
5824bb06
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
graph_tools/base.py
+5
-2
5 additions, 2 deletions
graph_tools/base.py
graph_tools/parameters.py
+6
-7
6 additions, 7 deletions
graph_tools/parameters.py
with
11 additions
and
9 deletions
graph_tools/base.py
+
5
−
2
View file @
c76faacc
...
@@ -29,7 +29,10 @@ def _init_():
...
@@ -29,7 +29,10 @@ def _init_():
for
e1
,
e2
in
joins
:
it
=
join
(
it
,
e1
,
e2
)
for
e1
,
e2
in
joins
:
it
=
join
(
it
,
e1
,
e2
)
it
=
(
self
.
project_and_canonize
(
outs
,
b
)
for
b
in
it
)
def
project_and_canonize
(
b
):
return
Boundary
(
self
.
project_and_canonize
(
outs
,
b
.
boundary
),
b
.
value
,
b
.
origins
)
it
=
(
project_and_canonize
(
b
)
for
b
in
it
)
ret
=
dict
()
ret
=
dict
()
for
b
in
it
:
for
b
in
it
:
...
@@ -56,7 +59,7 @@ def _init_():
...
@@ -56,7 +59,7 @@ def _init_():
yield
b
yield
b
def
project_and_canonize
(
self
,
sel
,
b
):
def
project_and_canonize
(
self
,
sel
,
b
):
return
Boundary
(
utils
.
select
(
sel
,
b
.
boundary
),
b
.
value
)
return
utils
.
select
(
sel
,
b
)
def
finalize
(
self
,
b
):
def
finalize
(
self
,
b
):
b
=
list
(
b
)
b
=
list
(
b
)
...
...
This diff is collapsed.
Click to expand it.
graph_tools/parameters.py
+
6
−
7
View file @
c76faacc
...
@@ -120,7 +120,7 @@ def _init_():
...
@@ -120,7 +120,7 @@ def _init_():
yield
Boundary
(
b
.
boundary
,
g
.
copy
(
immutable
=
True
))
yield
Boundary
(
b
.
boundary
,
g
.
copy
(
immutable
=
True
))
def
project_and_canonize
(
self
,
sel
,
b
):
def
project_and_canonize
(
self
,
sel
,
b
):
return
Boundary
(
select
(
sel
,
b
.
boundary
),
b
.
value
)
return
select
(
sel
,
b
)
def
merge_values
(
self
,
a
,
b
):
assert
False
def
merge_values
(
self
,
a
,
b
):
assert
False
...
@@ -191,7 +191,7 @@ def _init_():
...
@@ -191,7 +191,7 @@ def _init_():
yield
b
yield
b
def
project_and_canonize
(
self
,
p
,
b
):
def
project_and_canonize
(
self
,
p
,
b
):
boundary
=
select
(
p
,
b
.
boundary
)
boundary
=
select
(
p
,
b
)
rename
=
{
None
:
None
}
rename
=
{
None
:
None
}
i
=
1
i
=
1
for
x
in
boundary
:
for
x
in
boundary
:
...
@@ -199,7 +199,7 @@ def _init_():
...
@@ -199,7 +199,7 @@ def _init_():
rename
[
x
]
=
i
rename
[
x
]
=
i
i
+=
1
i
+=
1
boundary
=
tuple
(
rename
[
x
]
for
x
in
boundary
)
boundary
=
tuple
(
rename
[
x
]
for
x
in
boundary
)
return
Boundary
(
boundary
,
b
.
value
)
return
boundary
def
finalize
(
self
,
b
):
def
finalize
(
self
,
b
):
assert
len
(
b
)
<=
1
assert
len
(
b
)
<=
1
...
@@ -271,8 +271,7 @@ def _init_():
...
@@ -271,8 +271,7 @@ def _init_():
yield
from
do_join
(
uf
)
yield
from
do_join
(
uf
)
c3
,
c4
=
c4
,
c3
c3
,
c4
=
c4
,
c3
def
project_and_canonize
(
self
,
p
,
bo
):
def
project_and_canonize
(
self
,
p
,
x
):
x
=
bo
.
boundary
l
,
r
=
split_on_none
(
x
)
l
,
r
=
split_on_none
(
x
)
r
=
set
(
r
).
union
(
l
)
r
=
set
(
r
).
union
(
l
)
l
=
select
(
p
,
l
)
l
=
select
(
p
,
l
)
...
@@ -293,7 +292,7 @@ def _init_():
...
@@ -293,7 +292,7 @@ def _init_():
r
.
difference_update
(
set
(
l
))
r
.
difference_update
(
set
(
l
))
return
Boundary
(
tuple
(
l
+
[
None
]
+
sorted
(
r
))
,
bo
.
value
)
return
tuple
(
l
+
[
None
]
+
sorted
(
r
))
def
finalize
(
self
,
b
):
def
finalize
(
self
,
b
):
assert
len
(
b
)
<=
1
assert
len
(
b
)
<=
1
...
@@ -329,7 +328,7 @@ def _init_():
...
@@ -329,7 +328,7 @@ def _init_():
b
=
tuple
(
b
+
[
None
])
b
=
tuple
(
b
+
[
None
])
for
x
in
powerset
(
X
):
for
x
in
powerset
(
X
):
ret
=
b
+
tuple
(
sorted
(
x
))
ret
=
b
+
tuple
(
sorted
(
x
))
if
self
.
project_and_canonize
(
rng
,
Boundary
(
ret
,
0
)).
boundary
==
ret
:
if
self
.
project_and_canonize
(
rng
,
ret
)
==
ret
:
yield
ret
yield
ret
def
add_edge
(
b
,
used
,
fu
):
def
add_edge
(
b
,
used
,
fu
):
...
...
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