-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,6 +130,7 @@ Contents | |
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
pages/defaults | ||
pages/data | ||
pages/case_setup | ||
pages/models | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
Defaults | ||
=================================== | ||
|
||
|
||
|
||
.. exec_code:: | ||
:hide_code: | ||
:linenos_output: | ||
:language_output: python | ||
:caption: LagrangeBench default values | ||
|
||
|
||
with open("lagrangebench/defaults.py", "r") as file: | ||
defaults_full = file.read() | ||
|
||
# parse defaults: remove imports, only keep the set_defaults function | ||
|
||
defaults_full = defaults_full.split("\n") | ||
|
||
# remove imports | ||
defaults_full = [line for line in defaults_full if not line.startswith("import")] | ||
defaults_full = [line for line in defaults_full if len(line.replace(" ", "")) > 0] | ||
|
||
# remove other functions | ||
keep = False | ||
defaults = [] | ||
for i, line in enumerate(defaults_full): | ||
if line.startswith("def"): | ||
if "set_defaults" in line: | ||
keep = True | ||
else: | ||
keep = False | ||
|
||
if keep: | ||
defaults.append(line) | ||
|
||
# remove function declaration and return | ||
defaults = defaults[2:-2] | ||
|
||
# remove indent | ||
defaults = [line[4:] for line in defaults] | ||
|
||
|
||
print("\n".join(defaults)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters