From 1f191ed69e81dc99fbf618ecde2b90b94918d03c Mon Sep 17 00:00:00 2001 From: Russell Taylor Date: Mon, 3 Dec 2012 18:05:49 -0500 Subject: [PATCH] Re #6267. Change makeFilterByValue args from template type to double. Required to avoid truncation for integer-typed TSPs because the FilterByLogValue argument takes in the limits as doubles. --- .../Kernel/inc/MantidKernel/TimeSeriesProperty.h | 2 +- .../Framework/Kernel/src/TimeSeriesProperty.cpp | 13 +++++++++++-- .../Framework/Kernel/test/TimeSeriesPropertyTest.h | 6 ++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Code/Mantid/Framework/Kernel/inc/MantidKernel/TimeSeriesProperty.h b/Code/Mantid/Framework/Kernel/inc/MantidKernel/TimeSeriesProperty.h index 3d729b5a45e6..2be89b48050a 100644 --- a/Code/Mantid/Framework/Kernel/inc/MantidKernel/TimeSeriesProperty.h +++ b/Code/Mantid/Framework/Kernel/inc/MantidKernel/TimeSeriesProperty.h @@ -166,7 +166,7 @@ namespace Mantid /// Split out a time series property by time intervals. void splitByTime(TimeSplitterType& splitter, std::vector< Property * > outputs) const; /// Fill a TimeSplitterType that will filter the events by matching - void makeFilterByValue(TimeSplitterType& split, TYPE min, TYPE max, double TimeTolerance, bool centre) const; + void makeFilterByValue(TimeSplitterType& split, double min, double max, double TimeTolerance, bool centre) const; /// Return the time series as a correct C++ map. All values std::map valueAsCorrectMap() const; diff --git a/Code/Mantid/Framework/Kernel/src/TimeSeriesProperty.cpp b/Code/Mantid/Framework/Kernel/src/TimeSeriesProperty.cpp index 96c0bbfb9f00..3057b9b1e171 100644 --- a/Code/Mantid/Framework/Kernel/src/TimeSeriesProperty.cpp +++ b/Code/Mantid/Framework/Kernel/src/TimeSeriesProperty.cpp @@ -438,7 +438,7 @@ namespace Mantid /** * Fill a TimeSplitterType that will filter the events by matching - * log values >= min and < max. Creates SplittingInterval's where + * log values >= min and <= max. Creates SplittingInterval's where * times match the log values, and going to index==0. * * @param split :: Splitter that will be filled. @@ -448,7 +448,7 @@ namespace Mantid * @param centre :: Whether the log value time is considered centred or at the beginning. */ template - void TimeSeriesProperty::makeFilterByValue(TimeSplitterType& split, TYPE min, TYPE max, double TimeTolerance, bool centre) const + void TimeSeriesProperty::makeFilterByValue(TimeSplitterType& split, double min, double max, double TimeTolerance, bool centre) const { // Make sure the splitter starts out empty split.clear(); @@ -510,6 +510,15 @@ namespace Mantid return; } + /** Function specialization for TimeSeriesProperty + * @throws Kernel::Exception::NotImplementedError always + */ + template<> + void TimeSeriesProperty::makeFilterByValue(TimeSplitterType&, double, double, double, bool) const + { + throw Exception::NotImplementedError("TimeSeriesProperty::makeFilterByValue is not implemented for string properties"); + } + /** * Return the time series as a correct C++ map. All values * are included. diff --git a/Code/Mantid/Framework/Kernel/test/TimeSeriesPropertyTest.h b/Code/Mantid/Framework/Kernel/test/TimeSeriesPropertyTest.h index 34ac32077e11..fd53a4f70139 100644 --- a/Code/Mantid/Framework/Kernel/test/TimeSeriesPropertyTest.h +++ b/Code/Mantid/Framework/Kernel/test/TimeSeriesPropertyTest.h @@ -385,6 +385,12 @@ class TimeSeriesPropertyTest : public CxxTest::TestSuite delete log; } + void test_makeFilterByValue_throws_for_string_property() + { + TimeSeriesProperty log("StringTSP"); + TimeSplitterType splitter; + TS_ASSERT_THROWS(log.makeFilterByValue(splitter,0.0,0.0,0.0,true), Exception::NotImplementedError); + } //---------------------------------------------------------------------------- void test_splitByTime_and_getTotalValue()