Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
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
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
9e400584
Commit
9e400584
authored
4 years ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
PyStandardTest: factor out entire domain simulation
parent
60b678af
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tests/Functional/Python/PyStandard/PyStandardTest.cpp
+18
-13
18 additions, 13 deletions
Tests/Functional/Python/PyStandard/PyStandardTest.cpp
with
18 additions
and
13 deletions
Tests/Functional/Python/PyStandard/PyStandardTest.cpp
+
18
−
13
View file @
9e400584
...
@@ -27,24 +27,20 @@
...
@@ -27,24 +27,20 @@
namespace
namespace
{
{
}
// namespace
std
::
unique_ptr
<
OutputData
<
double
>>
domainData
(
const
std
::
string
&
test_name
,
const
Simulation
*
simulation
)
//! Runs simulation via a Python script and directly, and returns true if the results agree.
bool
PyStandardTest
::
runTest
()
{
{
// Set output data filename, and remove old output files
assert
(
m_name
!=
""
);
const
std
::
string
output_name
=
const
std
::
string
output_name
=
FileSystemUtils
::
jointPath
(
BATesting
::
PyStandardOutputDir
(),
m
_name
);
FileSystemUtils
::
jointPath
(
BATesting
::
PyStandardOutputDir
(),
test
_name
);
const
std
::
string
output_path
=
output_name
+
".ref.int.gz"
;
const
std
::
string
output_path
=
output_name
+
".ref.int.gz"
;
std
::
remove
(
output_path
.
c_str
());
std
::
remove
(
output_path
.
c_str
());
std
::
cout
<<
"- removed old output "
<<
output_path
<<
"
\n
"
;
std
::
cout
<<
"- removed old output "
<<
output_path
<<
"
\n
"
;
// Generate Python script
// Generate Python script
const
std
::
string
pyscript_filename
=
const
std
::
string
pyscript_filename
=
FileSystemUtils
::
jointPath
(
BATesting
::
PyStandardOutputDir
(),
m
_name
+
".py"
);
FileSystemUtils
::
jointPath
(
BATesting
::
PyStandardOutputDir
(),
test
_name
+
".py"
);
std
::
ofstream
pythonFile
(
pyscript_filename
);
std
::
ofstream
pythonFile
(
pyscript_filename
);
pythonFile
<<
ExportToPython
::
generatePyExportTest
(
*
m_reference_
simulation
);
pythonFile
<<
ExportToPython
::
generatePyExportTest
(
*
simulation
);
pythonFile
.
close
();
pythonFile
.
close
();
// Run Python script
// Run Python script
...
@@ -66,16 +62,25 @@ bool PyStandardTest::runTest()
...
@@ -66,16 +62,25 @@ bool PyStandardTest::runTest()
throw
std
::
runtime_error
(
msg
.
str
());
throw
std
::
runtime_error
(
msg
.
str
());
}
}
return
std
::
unique_ptr
<
OutputData
<
double
>>
(
IntensityDataIOFactory
::
readOutputData
(
output_path
));
}
}
// namespace
//! Runs simulation via a Python script and directly, and returns true if the results agree.
bool
PyStandardTest
::
runTest
()
{
// Set output data filename, and remove old output files
assert
(
m_name
!=
""
);
const
std
::
unique_ptr
<
OutputData
<
double
>>
domain_data
=
domainData
(
m_name
,
m_reference_simulation
.
get
());
// Run direct simulation
// Run direct simulation
std
::
cout
<<
"- run reference simulation
\n
"
;
std
::
cout
<<
"- run reference simulation
\n
"
;
m_reference_simulation
->
runSimulation
();
m_reference_simulation
->
runSimulation
();
const
std
::
unique_ptr
<
OutputData
<
double
>>
reference_data
=
const
std
::
unique_ptr
<
OutputData
<
double
>>
reference_data
=
m_reference_simulation
->
result
().
data
();
m_reference_simulation
->
result
().
data
();
// Compare results
const
std
::
unique_ptr
<
OutputData
<
double
>>
domain_data
(
IntensityDataIOFactory
::
readOutputData
(
output_path
));
return
IntensityDataFunctions
::
checkRelativeDifference
(
*
domain_data
,
*
reference_data
,
return
IntensityDataFunctions
::
checkRelativeDifference
(
*
domain_data
,
*
reference_data
,
m_threshold
);
m_threshold
);
}
}
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