Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Pydynamo
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
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
Software
Pydynamo
Commits
601d36e5
Commit
601d36e5
authored
3 years ago
by
abaucher
Browse files
Options
Downloads
Patches
Plain Diff
Added comments
parent
a573fccd
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pydynamo/core/plot_system.py
+2
-2
2 additions, 2 deletions
pydynamo/core/plot_system.py
pydynamo/core/system.py
+67
-4
67 additions, 4 deletions
pydynamo/core/system.py
with
69 additions
and
6 deletions
pydynamo/core/plot_system.py
+
2
−
2
View file @
601d36e5
...
...
@@ -5,13 +5,13 @@ import numpy as np
def
plot_system
(
s
,
v_names
=
None
,
rescale
=
False
,
com
=
True
,
filter_no
=
None
,
scales
=
None
,
colors
=
None
,
title
=
''
,
linestyle
=
'
-
'
,
outside_legend_number
=
2
,
legend
=
True
):
assert
'
time
'
in
dir
(
s
),
"
Aucune simulation n
'
a été lancée pour le système !
"
if
not
v_names
:
v_names
=
s
.
get_
var
s
()
v_names
=
s
.
get_
all_variable_name
s
()
if
isinstance
(
v_names
,
str
):
v_names
=
[
v_names
]
if
filter_no
:
v_names
=
[
n
for
n
in
v_names
if
n
not
in
filter_no
]
for
name
in
v_names
:
v
=
s
.
get
_var
(
name
)
v
=
get
attr
(
s
,
name
)
try
:
v
[
0
]
except
:
...
...
This diff is collapsed.
Click to expand it.
pydynamo/core/system.py
+
67
−
4
View file @
601d36e5
...
...
@@ -24,7 +24,7 @@ class System:
"""
def
__init__
(
self
):
"""
Initialise a System with nodes and equations dictionnaries
"""
"""
Initialise a
n empty
System with nodes and equations dictionnaries
"""
self
.
nodes
=
{
'
cst
'
:
set
(),
'
var
'
:
set
(),
...
...
@@ -106,15 +106,58 @@ class System:
return
self
.
nodes
[
node_type
]
def
get_vars
(
self
):
def
get_all_variable_names
(
self
):
"""
Returns
-------
list(str):
List of name of all variables
"""
return
self
.
nodes
[
'
var
'
]
def
get_var
(
self
,
name
):
"""
Parameters
----------
name: str
Name of variable.
Returns
-------
np.array(float):
Array of values of the variable for the last run
"""
assert
name
in
self
.
nodes
[
'
var
'
],
f
"
{
name
}
is not a variable
"
return
getattr
(
self
,
name
)
def
get_time
(
self
):
"""
Returns
-------
np.array(float):
Array of system time.
"""
return
self
.
time
def
get_tabhl_args
(
self
,
name
):
"""
Get indications about a tabhl function.
Parameters
----------
name: str
Name of the variable using a tabhl function.
Returns
-------
np.array, np.array, str, str, str:
x, f(x), x label, y label, title
"""
aa
=
list
(
self
.
eqs
[
'
update
'
][
name
][
'
args
'
][
'
var
'
])
argname
=
aa
[
0
][
0
].
split
(
'
.
'
)[
0
]
assert
'
tabhl_
'
+
name
in
dir
(
self
),
'
Error, no such tabhl function
'
...
...
@@ -652,7 +695,17 @@ class System:
return
s
def
get_out_nodes
(
self
,
node
,
with_definitions
=
False
):
"""
Returns the list of the nodes using the node to be compted
"""
"""
Returns the list of the nodes using the node to be computed.
Parameters
----------
node: str
Name of the node
with_definitions: bool
If yes, returns a dictionnary with each node definition.
"""
out_nodes
=
[
b
for
(
a
,
b
)
in
self
.
get_influence_graph
().
out_edges
(
node
)]
if
with_definitions
:
return
{
a
:
self
.
get_comment
(
a
)
for
a
in
out_nodes
}
...
...
@@ -660,7 +713,17 @@ class System:
return
out_nodes
def
get_in_nodes
(
self
,
node
,
with_definitions
=
False
):
"""
Returns the list of the nodes that this node needs to be compted
"""
"""
Returns the list of the nodes that this node needs to be computed.
Parameters
----------
node: str
Name of the node
with_definitions: bool
If yes, returns a dictionnary with each node definition.
"""
in_nodes
=
[
a
for
(
a
,
b
)
in
self
.
get_influence_graph
().
in_edges
(
node
)]
if
with_definitions
:
return
{
a
:
self
.
get_comment
(
a
)
for
a
in
in_nodes
}
...
...
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