-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs #4650. Add the missing TimeSeriesProperty export.
- Loading branch information
1 parent
9957b56
commit ac75800
Showing
7 changed files
with
78 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
26 changes: 26 additions & 0 deletions
26
Code/Mantid/Framework/PythonInterface/mantid/kernel/src/DateAndTime.cpp
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,26 @@ | ||
#include "MantidKernel/DateAndTime.h" | ||
#include <boost/python/class.hpp> | ||
#include <boost/python/operators.hpp> // Also provides self | ||
|
||
using Mantid::Kernel::DateAndTime; | ||
using namespace boost::python; | ||
|
||
void export_DateAndTime() | ||
{ | ||
|
||
class_<DateAndTime>("DateAndTime", no_init) | ||
.def("total_nanoseconds", &DateAndTime::total_nanoseconds) | ||
.def("__str__", &Mantid::Kernel::DateAndTime::to_ISO8601_string) | ||
// cppcheck-suppress duplicateExpression | ||
.def(self == self) | ||
// cppcheck-suppress duplicateExpression | ||
.def(self != self) | ||
// cppcheck-suppress duplicateExpression | ||
.def(self < self) | ||
.def(self + int64_t()) | ||
.def(self += int64_t()) | ||
.def(self - int64_t()) | ||
.def(self -= int64_t()); | ||
|
||
} | ||
|
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
27 changes: 27 additions & 0 deletions
27
Code/Mantid/Framework/PythonInterface/mantid/kernel/src/TimeSeriesProperty.cpp
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,27 @@ | ||
#include "MantidKernel/TimeSeriesProperty.h" | ||
#include <boost/python/class.hpp> | ||
|
||
using Mantid::Kernel::TimeSeriesProperty; | ||
using Mantid::Kernel::Property; | ||
using namespace boost::python; | ||
|
||
void export_TimeSeriesProperty_Double() | ||
{ | ||
class_<TimeSeriesProperty<double>, bases<Property>, boost::noncopyable>("TimeSeriesProperty_dbl", no_init) | ||
.def("getStatistics", &Mantid::Kernel::TimeSeriesProperty<double>::getStatistics) | ||
.add_property("value", &Mantid::Kernel::TimeSeriesProperty<double>::valuesAsVector) | ||
.add_property("times", &Mantid::Kernel::TimeSeriesProperty<double>::timesAsVector) | ||
; | ||
} | ||
|
||
void export_TimeSeriesPropertyStatistics() | ||
{ | ||
class_<Mantid::Kernel::TimeSeriesPropertyStatistics>("TimeSeriesPropertyStatistics", no_init) | ||
.add_property("minimum", &Mantid::Kernel::TimeSeriesPropertyStatistics::minimum) | ||
.add_property("maximum", &Mantid::Kernel::TimeSeriesPropertyStatistics::maximum) | ||
.add_property("mean", &Mantid::Kernel::TimeSeriesPropertyStatistics::mean) | ||
.add_property("median", &Mantid::Kernel::TimeSeriesPropertyStatistics::median) | ||
.add_property("standard_deviation", &Mantid::Kernel::TimeSeriesPropertyStatistics::standard_deviation) | ||
.add_property("duration", &Mantid::Kernel::TimeSeriesPropertyStatistics::duration) | ||
; | ||
} |
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
15 changes: 15 additions & 0 deletions
15
Code/Mantid/Framework/PythonInterface/test/python/TimeSeriesPropertyTest.py
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,15 @@ | ||
import unittest | ||
from testhelpers import run_algorithm | ||
|
||
class TimeSeriesPropertyTest(unittest.TestCase): | ||
|
||
def test_time_series_can_be_extracted(self): | ||
alg = run_algorithm("Load", Filename="CNCS_7860_event.nxs", child=True) | ||
ws = alg.getProperty("OutputWorkspace").value | ||
log_series = ws.getRun()["Phase1"] | ||
self.assertTrue(hasattr(log_series, "value")) | ||
self.assertTrue(hasattr(log_series, "times")) | ||
self.assertTrue(hasattr(log_series, "getStatistics")) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |