Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions dev-tools/dev_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def main():

_maybe_run_pytest(arguments, test_results_dir_path)

_maybe_run_doctest(arguments)

_maybe_create_documentation(arguments)


Expand Down Expand Up @@ -102,6 +104,16 @@ def _parse_arguments() -> ap.Namespace:
nargs="?",
dest="pytestMarkersExpression",
)
parser.add_argument(
"-dt",
"--doctest",
help="Perform doc tests",
type=str,
default=None,
const="",
nargs="?",
dest="doctestArguments",
)
parser.add_argument(
"-d",
"--diagram",
Expand Down Expand Up @@ -221,15 +233,19 @@ def _maybe_run_pytest(arguments, test_results_dir_path):
and arguments.blackArguments is None
and arguments.diagramsFormat is None
and not arguments.shallCreateDocumentation
and arguments.doctestArguments is None
)
if (
arguments.shallRunAll
or arguments.pytestMarkersExpression is not None
or was_called_without_arguments
):
_run_unit_tests_with_pytest(arguments, test_results_dir_path)
# TODO: re-enable this once the documentation is updated pylint: disable=fixme
# _run_doctests_with_pytest()


def _maybe_run_doctest(arguments):
if arguments.shallRunAll or arguments.doctestArguments is not None:
_run_doctests_with_pytest()


def _run_unit_tests_with_pytest(arguments, test_results_dir_path):
Expand Down
43 changes: 39 additions & 4 deletions pytrnsys_process/process/process_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,24 @@ def process_single_simulation(
>>> def processing_step_1(sim: api.Simulation):
... # Process simulation data
... pass
>>> results = api.process_single_simulation(
... _pl.Path("path/to/simulation"),
...
>>> api.global_settings.reader.read_step_files = True
...
>>> api.global_settings.reader.force_reread_prt = True
...
>>> simulation = api.process_single_simulation( # doctest: +ELLIPSIS
... _pl.Path("tests/pytrnsys_process/data/doctest/results/sim-1"),
... processing_step_1
... )
INFO ...
>>> simulation.step.shape
(5, 142)
>>> simulation.hourly.shape
(3, 18)
>>> simulation.monthly.shape
(14, 11)
>>> simulation.scalar.shape
(1, 10)
"""
main_logger = log.get_main_logger(sim_folder)
log.initialize_logs(sim_folder)
Expand Down Expand Up @@ -267,16 +281,37 @@ def process_whole_result_set(
>>> import pathlib as _pl
>>> from pytrnsys_process import api
...
>>> api.global_settings.reader.force_reread_prt = True
...
>>> api.global_settings.reader.read_step_files = False
...
>>> def processing_step_1(sim):
... # Process simulation data
... pass
...
>>> def processing_step_2(sim):
... # Process simulation data
... pass
>>> results = api.process_whole_result_set(
... _pl.Path("path/to/results"),
...
>>> simulations_data = api.process_whole_result_set( # doctest: +ELLIPSIS
... _pl.Path("tests/pytrnsys_process/data/doctest/results"),
... [processing_step_1, processing_step_2]
... )
INFO ...
>>> simulations_data.simulations["sim-1"].hourly.shape
(3, 18)
>>> simulations_data.simulations["sim-1"].monthly.shape
(14, 11)
>>> simulations_data.simulations["sim-1"].step.shape
(0, 0)
>>> simulations_data.simulations["sim-1"].step.shape
(0, 0)
>>> simulations_data.simulations["sim-2"].monthly.shape
(14, 11)
>>> simulations_data.simulations["sim-2"].step.shape
(0, 0)
>>> simulations_data.scalar.shape
(2, 10)
"""
_validate_folder(results_folder)
main_logger = log.get_main_logger(results_folder)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
TIME xFracVBoil MBoil_TeeBoil MHXSnk_VBoil MVBoil_TeeBoil MVBoil_Boil xFracVSrcPS2 xFracVSrcPS1 xFracVSnkPreHeat MQSrcRZ_TeeRZHP MTeeRZHP_HPRZ MHPRZ_PPitReg MPPitReg_TeeHPRZ MTeeHPRZ_QSrcRZ MHPRZ_TeeHPHX MTeeHPHX_PHXSnk MPHXSnk_HXSnk MHXSnk_TeeHXHP MTeeHXHP_PHPRZ MVSnkPreHeat_TeeHPHX MVSrcH_TeeRZHP MTeePitL1H_VSrcH xFracVSnkPS2 xFracVSnkPS3 MVSrcPS2_VSrcPS1 MTeePS2_VSrcPS2 MTeePS2_VSnkPS2 MVSnkPS2_TeeHXHP MTeePS3_VSnkPS3 MTeePS3_VSrcPS2 MVSnkPS3_VSnkPS2 xFracVPSDiv1b xFracVPSDiv1a xFracVPSDiv2b xFracVPSDiv2a xFracVPSDiv3b xFracVPSDiv3a xFracVPSDiv4b xFracVPSDiv4a MVPSDiv1a_TeePSCon1 MVPSDiv1b_VPSDiv1a MPS_VPSDiv1a MPS_VPSDiv1b MPS_VPSDiv1b2 MVPSDiv2a_TeePS2 MVPSDiv2b_VPSDiv2a MPS_VPSDiv2a MPS_VPSDiv2b MPS_VPSDiv2b2 MVPSDiv3a_TeePS3 MVPSDiv3b_VPSDiv3a MPS_VPSDiv3a MPS_VPSDiv3b MPS_VPSDiv3b2 MPS_VPSDiv4a MPS_VPSDiv4b MPS_VPSDiv4b2 MVPSDiv4b_VPSDiv4a MTeePSCon1_VSnkPreHeat xFracVPS4 MVPS4_VSnkPS3 MVPS4_TeeHPRZ MVPSDiv4a_VPS4 MVSnkPreHeat_PPreHeat MPPreHeat_TeePreHeat MPHPRZ_TeePreHeat MTeePreHeat_HPRZ MTeeBoil_SCnr MSCnr_SCnr2Cold MSCnr_SCnr2Hot MSCnr2_QSnk1 MQSnk1_SCnr2 MSCnr_HXSnk
+0.0000000000000000E+00 +1.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +1.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00
+1.6666666666666666E-01 +1.0000000000000000E+00 +3.4034278971338371E+05 +3.4034278971338371E+05 +0.0000000000000000E+00 +3.4034278971338371E+05 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +8.6097625140506541E+05 +8.6097625140506541E+05 +8.6097625140506541E+05 +8.6097625140506541E+05 +8.6097625140506541E+05 +3.2209990500000014E+05 +3.4034278971338371E+05 +3.4034278971338371E+05 +3.4034278971338371E+05 +3.2209990500000014E+05 +1.8242884713383566E+04 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 -1.8242884713383566E+04 +0.0000000000000000E+00 +0.0000000000000000E+00 -1.8242884713383566E+04 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +1.8242884713383566E+04 +1.8242884713383566E+04 +0.0000000000000000E+00 +0.0000000000000000E+00 +1.8242884713383566E+04 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 -1.8242884713383566E+04 -1.8242884713383566E+04 +1.8242884713383566E+04 +1.0000000000000000E+00 -1.8242884713383566E+04 +0.0000000000000000E+00 -1.8242884713383566E+04 +0.0000000000000000E+00 +0.0000000000000000E+00 +3.2209990500000014E+05 +3.2209990500000014E+05 +3.4034278971338371E+05 +3.4034278971338371E+05 +3.4034278971338371E+05 +3.4034278971338371E+05 +3.4034278971338371E+05 +3.4034278971338371E+05
+3.3333333333333331E-01 +1.0000000000000000E+00 +3.4034278971338371E+05 +3.4034278971338371E+05 +0.0000000000000000E+00 +3.4034278971338371E+05 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +8.6097625140506541E+05 +8.6097625140506541E+05 +8.6097625140506541E+05 +8.6097625140506541E+05 +8.6097625140506541E+05 +2.9645650638254941E+05 +3.4034278971338371E+05 +3.4034278971338371E+05 +3.4034278971338371E+05 +2.9645650638254941E+05 +4.3886283330834296E+04 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 -4.3886283330834296E+04 +0.0000000000000000E+00 +0.0000000000000000E+00 -4.3886283330834296E+04 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +4.3886283330834296E+04 +4.3886283330834296E+04 +0.0000000000000000E+00 +0.0000000000000000E+00 +4.3886283330834296E+04 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 -4.3886283330834296E+04 -4.3886283330834296E+04 +4.3886283330834296E+04 +1.0000000000000000E+00 -4.3886283330834296E+04 +0.0000000000000000E+00 -4.3886283330834296E+04 +0.0000000000000000E+00 +0.0000000000000000E+00 +2.9645650638254941E+05 +2.9645650638254941E+05 +3.4034278971338371E+05 +3.4034278971338371E+05 +3.4034278971338371E+05 +3.4034278971338371E+05 +3.4034278971338371E+05 +3.4034278971338371E+05
+5.0000000000000000E-01 +1.0000000000000000E+00 +3.4034278971338371E+05 +3.4034278971338371E+05 +0.0000000000000000E+00 +3.4034278971338371E+05 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +8.6097625140506541E+05 +8.6097625140506541E+05 +8.6097625140506541E+05 +8.6097625140506541E+05 +8.6097625140506541E+05 +2.9831240206806629E+05 +3.4034278971338371E+05 +3.4034278971338371E+05 +3.4034278971338371E+05 +2.9831240206806629E+05 +4.2030387645317416E+04 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 -4.2030387645317416E+04 +0.0000000000000000E+00 +0.0000000000000000E+00 -4.2030387645317416E+04 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +4.2030387645317416E+04 +4.2030387645317416E+04 +0.0000000000000000E+00 +0.0000000000000000E+00 +4.2030387645317416E+04 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 -4.2030387645317416E+04 -4.2030387645317416E+04 +4.2030387645317416E+04 +1.0000000000000000E+00 -4.2030387645317416E+04 +0.0000000000000000E+00 -4.2030387645317416E+04 +0.0000000000000000E+00 +0.0000000000000000E+00 +2.9831240206806629E+05 +2.9831240206806629E+05 +3.4034278971338371E+05 +3.4034278971338371E+05 +3.4034278971338371E+05 +3.4034278971338371E+05 +3.4034278971338371E+05 +3.4034278971338371E+05
+6.6666666666666663E-01 +1.0000000000000000E+00 +3.4034278971338371E+05 +3.4034278971338371E+05 +0.0000000000000000E+00 +3.4034278971338371E+05 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +8.6097625140506541E+05 +8.6097625140506541E+05 +8.6097625140506541E+05 +8.6097625140506541E+05 +8.6097625140506541E+05 +2.9169765459545422E+05 +3.4034278971338371E+05 +3.4034278971338371E+05 +3.4034278971338371E+05 +2.9169765459545422E+05 +4.8645135117929487E+04 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 -4.8645135117929487E+04 +0.0000000000000000E+00 +0.0000000000000000E+00 -4.8645135117929487E+04 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +4.8645135117929487E+04 +4.8645135117929487E+04 +0.0000000000000000E+00 +0.0000000000000000E+00 +4.8645135117929487E+04 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 -4.8645135117929487E+04 -4.8645135117929487E+04 +4.8645135117929487E+04 +1.0000000000000000E+00 -4.8645135117929487E+04 +0.0000000000000000E+00 -4.8645135117929487E+04 +0.0000000000000000E+00 +0.0000000000000000E+00 +2.9169765459545422E+05 +2.9169765459545422E+05 +3.4034278971338371E+05 +3.4034278971338371E+05 +3.4034278971338371E+05 +3.4034278971338371E+05 +3.4034278971338371E+05 +3.4034278971338371E+05
Loading
Loading