mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Refactor: Make a copy of histogram data.
This commit is contained in:
@@ -106,9 +106,8 @@ RigHistogramData RigEnsembleFractureStatisticsCalculator::createStatisticsData(
|
||||
double mean;
|
||||
RigStatisticsMath::calculateStatisticsCurves( samples, &histogramData.p10, &p50, &histogramData.p90, &mean );
|
||||
|
||||
// TODO: this leaks memory: api assume the the histogram is owned by someone else (which is kind-of-strange)
|
||||
std::vector<size_t>* histogram = new std::vector<size_t>();
|
||||
RigHistogramCalculator histogramCalculator( histogramData.min, histogramData.max, 20, histogram );
|
||||
std::vector<size_t> histogram;
|
||||
RigHistogramCalculator histogramCalculator( histogramData.min, histogramData.max, 20, &histogram );
|
||||
for ( auto s : samples )
|
||||
histogramCalculator.addValue( s );
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ RigHistogramData::RigHistogramData()
|
||||
, mean( std::numeric_limits<double>::infinity() )
|
||||
, weightedMean( std::numeric_limits<double>::infinity() )
|
||||
, sum( 0.0 )
|
||||
, histogram( nullptr )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -56,5 +55,5 @@ bool RigHistogramData::isValid( double parameter ) const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigHistogramData::isHistogramVectorValid() const
|
||||
{
|
||||
return histogram && histogram->size() > 0 && isMinMaxValid();
|
||||
return histogram.size() > 0 && isMinMaxValid();
|
||||
}
|
||||
|
||||
@@ -29,14 +29,14 @@ class RigHistogramData
|
||||
public:
|
||||
RigHistogramData();
|
||||
|
||||
double min;
|
||||
double max;
|
||||
double p10;
|
||||
double p90;
|
||||
double mean;
|
||||
double sum;
|
||||
double weightedMean;
|
||||
const std::vector<size_t>* histogram;
|
||||
double min;
|
||||
double max;
|
||||
double p10;
|
||||
double p90;
|
||||
double mean;
|
||||
double sum;
|
||||
double weightedMean;
|
||||
std::vector<size_t> histogram;
|
||||
|
||||
bool isMinMaxValid() const;
|
||||
bool isHistogramVectorValid() const;
|
||||
|
||||
Reference in New Issue
Block a user