Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PPP-libmodule-Python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Moritz Aurel Pascal Schubotz
PPP-libmodule-Python
Commits
90c20998
Commit
90c20998
authored
10 years ago
by
Valentin Lorentz
Browse files
Options
Downloads
Patches
Plain Diff
Comments.
parent
6a136034
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ppp_libmodule/simplification.py
+8
-2
8 additions, 2 deletions
ppp_libmodule/simplification.py
with
8 additions
and
2 deletions
ppp_libmodule/simplification.py
+
8
−
2
View file @
90c20998
...
...
@@ -6,19 +6,25 @@ from ppp_datamodel.nodes.list_operators import *
__all__
=
[
'
simplify
'
]
def
simplify_union
(
tree
):
# Trivial cases
if
len
(
tree
.
list
)
==
0
:
return
List
([])
elif
len
(
tree
.
list
)
==
1
:
return
tree
.
list
[
0
]
# Partition the items in lists / non-lists
list_
=
[
x
for
x
in
tree
.
list
if
x
]
lists
=
(
x
.
list
for
x
in
list_
if
isinstance
(
x
,
List
))
not_lists
=
[
x
for
x
in
list_
if
not
isinstance
(
x
,
List
)]
# Make union of lists
lists
=
list
(
set
(
itertools
.
chain
(
*
lists
)))
if
not_lists
:
if
not_lists
:
# If there are non-lists (eg. triples)
all_
=
not_lists
all_
.
append
(
List
(
lists
))
return
Union
(
all_
)
else
:
else
:
# If there are only lists
return
List
(
lists
)
...
...
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