Skip to content

Commit

Permalink
Re #6267. Change makeFilterByValue args from template type to double.
Browse files Browse the repository at this point in the history
Required to avoid truncation for integer-typed TSPs because the
FilterByLogValue argument takes in the limits as doubles.
  • Loading branch information
RussellTaylor committed Dec 4, 2012
1 parent 1093d0d commit 1f191ed
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
Expand Up @@ -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<DateAndTime, TYPE>. All values
std::map<DateAndTime, TYPE> valueAsCorrectMap() const;
Expand Down
13 changes: 11 additions & 2 deletions Code/Mantid/Framework/Kernel/src/TimeSeriesProperty.cpp
Expand Up @@ -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.
Expand All @@ -448,7 +448,7 @@ namespace Mantid
* @param centre :: Whether the log value time is considered centred or at the beginning.
*/
template<typename TYPE>
void TimeSeriesProperty<TYPE>::makeFilterByValue(TimeSplitterType& split, TYPE min, TYPE max, double TimeTolerance, bool centre) const
void TimeSeriesProperty<TYPE>::makeFilterByValue(TimeSplitterType& split, double min, double max, double TimeTolerance, bool centre) const
{
// Make sure the splitter starts out empty
split.clear();
Expand Down Expand Up @@ -510,6 +510,15 @@ namespace Mantid
return;
}

/** Function specialization for TimeSeriesProperty<std::string>
* @throws Kernel::Exception::NotImplementedError always
*/
template<>
void TimeSeriesProperty<std::string>::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<DateAndTime, TYPE>. All values
* are included.
Expand Down
6 changes: 6 additions & 0 deletions Code/Mantid/Framework/Kernel/test/TimeSeriesPropertyTest.h
Expand Up @@ -385,6 +385,12 @@ class TimeSeriesPropertyTest : public CxxTest::TestSuite
delete log;
}

void test_makeFilterByValue_throws_for_string_property()
{
TimeSeriesProperty<std::string> log("StringTSP");
TimeSplitterType splitter;
TS_ASSERT_THROWS(log.makeFilterByValue(splitter,0.0,0.0,0.0,true), Exception::NotImplementedError);
}

//----------------------------------------------------------------------------
void test_splitByTime_and_getTotalValue()
Expand Down

0 comments on commit 1f191ed

Please sign in to comment.