Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gboml
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
smart_grids
public
gboml
Commits
fb0ceca5
Commit
fb0ceca5
authored
1 year ago
by
Derval Guillaume
Browse files
Options
Downloads
Patches
Plain Diff
Ensure we can modify "intermediate" classes in the tree_modifier
parent
a3dc23cd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/gboml/tools/tree_modifier.py
+6
-4
6 additions, 4 deletions
src/gboml/tools/tree_modifier.py
with
6 additions
and
4 deletions
src/gboml/tools/tree_modifier.py
+
6
−
4
View file @
fb0ceca5
...
...
@@ -80,11 +80,12 @@ def _compute_types_inside():
def
_compute_paths_to
():
"""
path_to[x][y] gives the set of fields in class y that can lead to a subclass x
"""
paths_to
=
{
x
:
{
y
:
set
()
for
y
in
all_gbomlobjects
}
for
x
in
all_gbomlobjects
}
for
cls
in
leaf
_gbomlobjects
:
for
cls
in
all
_gbomlobjects
:
for
field
in
dataclasses
.
fields
(
cls
):
in_types
=
{
a
for
b
in
_effective_types
(
field
.
type
)
for
a
in
types_inside
[
b
]}
|
set
(
_effective_types
(
field
.
type
))
for
cls2
in
in_types
:
paths_to
[
cls2
][
cls
].
add
(
field
.
name
)
for
cls3
in
family_list
[
cls2
]:
paths_to
[
cls3
][
cls
].
add
(
field
.
name
)
return
paths_to
...
...
@@ -94,10 +95,11 @@ all_gbomlobjects: set[typing.Type[GBOMLObject]] = set(_recursive_class_list_chil
leaf_gbomlobjects
:
set
[
typing
.
Type
[
GBOMLObject
]]
=
{
cls
for
cls
in
all_gbomlobjects
if
len
(
cls
.
__subclasses__
())
==
0
}
"""
GBOMLObject-subclasses used by given GBOMLObject-subclasses, recursively
"""
types_inside
=
_compute_types_inside
()
"""
path_to[x][y] gives the set of fields in class y that can lead to a subclass x
"""
paths_to
=
_compute_paths_to
()
"""
all parents of class cls, including itself, from child to parent
"""
family_list
=
{
x
:
_recursive_class_list_parents
(
x
)
for
x
in
all_gbomlobjects
}
"""
path_to[x][y] gives the set of fields in class y that can lead to a subclass x
"""
paths_to
=
_compute_paths_to
()
# note: this whole thing above runs each time GBOML is loaded in memory,
# and it takes ~20ms. We probably shouldn't care.
...
...
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