Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regression test problem #469 #682

Merged
merged 3 commits into from
Nov 22, 2024
Merged
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
14 changes: 14 additions & 0 deletions PythonScriptStore/RegressionTest/regression_test_base_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ def read_dat_file(self):
file.close()
return ifconverged

def clean_input_folder(folder_path, keep_file="regression_test_tool.py"):
for filename in os.listdir(folder_path):
file_path = os.path.join(folder_path, filename)
if filename != keep_file and os.path.isfile(file_path):
os.remove(file_path)
print(f"Deleted: {file_path}")


class SphinxsysRegressionTest:

Expand Down Expand Up @@ -117,6 +124,13 @@ def run_case_with_reload(self) -> None:
os.system(command)
print('Simulating case is finished...')

def clean_input_folder(folder_path, keep_file="regression_test_tool.py"):
for filename in os.listdir(folder_path):
file_path = os.path.join(folder_path, filename)
if filename != keep_file and os.path.isfile(file_path):
os.remove(file_path)
print(f"Deleted: {file_path}")

def read_dat_file(self):
file = open(self.condition_file_path)
ifconverged = file.readline(4)
Expand Down
4 changes: 2 additions & 2 deletions src/shared/regression_test/dynamic_time_warping_method.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @file dynamic_time_warping_method.h
* @brief Classes for the comparison between validated and tested results
with dynamic time warping method.
* @author Bo Zhang , Chi Zhang and Xiangyu Hu
* @author Bo Zhang, Chi Zhang and Xiangyu Hu
*/

#ifndef DYNAMIC_TIME_WARPING_H
Expand Down Expand Up @@ -103,7 +103,7 @@ class RegressionTestDynamicTimeWarping : public RegressionTestTimeAverage<Observ
}
this->writeResultToXml(this->number_of_run_ - 1);
writeDTWDistanceToXml();
compareDTWDistance(threshold_value);
compareDTWDistance(threshold_value); //wether the distance is convergence.
}
else
std::cout << "The results have been converged." << std::endl;
Expand Down
14 changes: 7 additions & 7 deletions src/shared/regression_test/regression_test_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/**
* @file regression_test_base.h
* @brief Base classes for comparisons between validated and tested results.
* @author Bo Zhang , Chi Zhang and Xiangyu Hu
* @author Bo Zhang, Chi Zhang and Xiangyu Hu
*/

#ifndef REGRESSION_TEST_BASE_H
Expand Down Expand Up @@ -56,8 +56,8 @@ class RegressionTestBase : public ObserveMethodType
std::string converged; /*< the tag for result converged, default false. */

XmlMemoryIO xmlmemory_io_; /*< xml memory in_output operator, which has defined several
methods to read and write data from and into xml memory,
including one by one, or all result in the same time. */
methods to read and write data from and into xml memory,
including one by one, or all result in the same time. */

XmlEngine observe_xml_engine_; /*< xml engine for current result io_environment. */
XmlEngine result_xml_engine_in_; /*< xml engine for input result. */
Expand All @@ -67,15 +67,15 @@ class RegressionTestBase : public ObserveMethodType
StdVec<std::string> element_tag_; /*< the container of the tag of current result. */
BiVector<VariableType> current_result_; /*< the container of current run result stored as snapshot * observation. */
BiVector<VariableType> current_result_trans_; /*< the container of current run result with snapshot & observations transposed,
because this data structure is required in TA and DTW method. */
because this data structure is required in TA and DTW method. */
BiVector<VariableType> result_in_; /*< the temporary container of each result when reading from .xml memory, and
it may be snapshot * observations (reading all result for averaged methods),
or observations * snapshot (reading specified result for TA and DTW method.) */
it may be snapshot * observations (reading all result for averaged methods),
or observations * snapshot (reading specified result for TA and DTW method.) */
TriVector<VariableType> result_; /*< the container of results in all runs (run * snapshot * observation) */

int snapshot_, observation_; /*< the size of each layer of current result vector. */
int difference_; /*< the length difference of snapshot between old and new result,
which is used to trim each new run result to be a unified length. */
which is used to trim each new run result to be a unified length. */
int number_of_run_; /*< the times of run. */
int label_for_repeat_; /*< the label used stable convergence (several convergence). */
int number_of_snapshot_old_; /*< the snapshot size of last trimmed result. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ template <typename DataType, typename NormType, class DynamicsIdentifier>
template <class ExecutionPolicy, class EncloserType>
VariableNormCK<DataType, NormType, DynamicsIdentifier>::ReduceKernel::
ReduceKernel(const ExecutionPolicy &ex_policy, EncloserType &encloser)
: variable_(encloser.dv_variable_->template DelegatedDataField(ex_policy)) {}
: variable_(encloser.dv_variable_->DelegatedDataField(ex_policy)) {}
//=================================================================================================//
template <class ExecutionPolicy, class EncloserType>
TotalKineticEnergyCK::ReduceKernel::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)

while True:
print("Now start a new run......")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)

while True:
print("Now start a new run......")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)

while True:
print("Now start a new run......")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)

clean_input_folder(sphinxsys.input_file_path)

while True:
print("Now start a new run......")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
sphinxsys_1 = SphinxsysRegressionTest(case_name, body_name_1, parameter_name_1)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
sphinxsys_1 = SphinxsysRegressionTest(case_name, body_name_1, parameter_name_1)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
sphinxsys_1 = SphinxsysRegressionTest(case_name, body_name_1, parameter_name_1)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)

while True:
print("Now start a new run......")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)

while True:
print("Now start a new run......")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
sphinxsys_1 = SphinxsysRegressionTest(case_name, body_name_1, parameter_name_1)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
sphinxsys_1 = SphinxsysRegressionTest(case_name, body_name_1, parameter_name_1)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)

while True:
print("Now start a new run......")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)

while True:
print("Now start a new run......")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
sphinxsys_1 = SphinxsysRegressionTest(case_name, body_name_1, parameter_name_1)
clean_input_folder(sphinxsys.input_file_path)

while True:
print("Now start a new run......")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
sphinxsys_1 = SphinxsysRegressionTest(case_name, body_name_1, parameter_name_1)
clean_input_folder(sphinxsys.input_file_path)

while True:
print("Now start a new run......")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
sphinxsys_1 = SphinxsysRegressionTest(case_name, body_name_1, parameter_name_1)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
number_of_run_times = 0
converged = 0
sphinxsys = SphinxsysRegressionTest(case_name, body_name, parameter_name)
clean_input_folder(sphinxsys.input_file_path)


while True:
Expand Down
Loading
Loading