Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
KADMOS
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
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
LR-FPP-MDO
KADMOS
Commits
53705fca
Commit
53705fca
authored
7 years ago
by
Anne-Liza
Browse files
Options
Downloads
Patches
Plain Diff
Added option to choose labeling method for equation labels
Former-commit-id: 6a3dc36c845b6a0c7801959f87c053368305872d
parent
99da533c
No related branches found
Branches containing commit
Tags
v0.7.3
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
kadmos/graph/mixin_equation.py
+17
-9
17 additions, 9 deletions
kadmos/graph/mixin_equation.py
with
17 additions
and
9 deletions
kadmos/graph/mixin_equation.py
+
17
−
9
View file @
53705fca
...
...
@@ -75,14 +75,14 @@ class EquationMixin(object):
return
chars
def
add_equation_label
(
self
,
edge
,
label
=
None
,
language
=
'
Python
'
):
def
add_equation_label
(
self
,
edge
,
label
ing_method
=
'
node_label
'
,
language
=
'
Python
'
):
"""
Method to add an equation label to a edge that can (safely) be used as reference in an equation.
:type self: KadmosGraph
:param edge: graph edge under consideration
:type edge: str
:param label
: label to be added (if not given it will be determined based on the
node
label
or key
)
:type label: str
:param label
ing_method: select method for automatic label string determination (node_id or
node
_
label)
:type label
ing_method
: str
:param language: equation language used for the equation label
:type language: str
...
...
@@ -94,9 +94,16 @@ class EquationMixin(object):
assert
self
.
has_edge
(
edge
[
0
],
edge
[
1
]),
'
Edge %s does not exist.
'
%
edge
# If the label is not provided retrieve it automatically from the variable node
if
label
is
None
:
variable
=
edge
[
0
]
if
self
.
node
[
edge
[
0
]].
get
(
'
category
'
)
==
'
variable
'
else
edge
[
1
]
label
=
self
.
node
[
variable
].
get
(
'
label
'
,
variable
)
node_id
=
edge
[
0
]
if
self
.
node
[
edge
[
0
]].
get
(
'
category
'
)
==
'
variable
'
else
edge
[
1
]
if
labeling_method
==
'
node_label
'
:
label
=
self
.
node
[
node_id
].
get
(
'
label
'
,
node_id
)
elif
labeling_method
==
'
node_id
'
:
label
=
node_id
.
split
(
'
/
'
)[
-
1
]
else
:
raise
IOError
(
'
Invalid setting label_method.
'
)
# Make the label valid
for
char
in
self
.
_get_equation_chars
(
language
=
language
):
...
...
@@ -112,7 +119,7 @@ class EquationMixin(object):
return
label
def
add_equation_labels
(
self
,
nodes
,
language
=
'
Python
'
):
def
add_equation_labels
(
self
,
nodes
,
language
=
'
Python
'
,
labeling_method
=
'
node_id
'
):
"""
Method to add equation labels automatically to all input edges connected to the specified list of nodes
:type self: KadmosGraph
...
...
@@ -120,6 +127,8 @@ class EquationMixin(object):
:type nodes: list
:param language: equation language used for the equation label
:type language: str
:param labeling_method: select method for automatic label string determination (node_id or node_label)
:type labeling_method: str
"""
# Find all input edges
...
...
@@ -127,7 +136,7 @@ class EquationMixin(object):
# Loop
for
edge
in
in_edges
:
self
.
add_equation_label
(
edge
,
language
=
language
)
self
.
add_equation_label
(
edge
,
labeling_method
=
labeling_method
,
language
=
language
)
return
...
...
@@ -181,7 +190,6 @@ class EquationMixin(object):
cmdows_added_equations
=
dict
()
for
graph_math_func
in
graph_math_funcs
:
# Create mathematicalFunctions/mathematicalFunction
cmdows_math_func
=
cmdows_math_funcs
.
add
(
'
mathematicalFunction
'
,
uID
=
graph_math_func
)
cmdows_math_func
.
add
(
'
label
'
,
self
.
node
[
graph_math_func
].
get
(
'
label
'
,
graph_math_func
))
...
...
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