Skip to content

Commit

Permalink
Merge pull request #2142 from jschueller/misc1
Browse files Browse the repository at this point in the history
misc 2
  • Loading branch information
jschueller committed Oct 5, 2022
2 parents 6f95e6f + 9ee541b commit dd15205
Show file tree
Hide file tree
Showing 98 changed files with 204 additions and 555 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
* Deprecated Distribution::getCenteredMoment in favor of getCentralMoment
* Deprecated IterativeMoments::getCenteredMoments in favor of getCentralMoments
* Deprecated GeneralLinearModelAlgorithm | KrigingAlgorithm ctors using collection of basis
* Deprecated Drawable.draw|clean & Graph.draw|clean|getRCommand methods for legacy R graphs
* Deprecated GaussianProcess.GIBBS in favor of GaussianProcess.GALLIGAOGIBBS

=== Documentation ===
* Added example galleries at the end of API doc pages
Expand Down
2 changes: 2 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ Remove (Process)Sample::computeCenteredMoment
Remove Distribution::getCenteredMoment
Remove IterativeMoments::getCenteredMoments
Drop deprecated GeneralLinearModelAlgorithm | KrigingAlgorithm ctors for 1.21
Drop deprecated Drawable.draw|clean & Graph.draw|clean|getRCommand|makeR*|GetExtensionMap methods
Drop deprecated GaussianProcess.GIBBS
2 changes: 1 addition & 1 deletion lib/src/Base/Algo/KarhunenLoeveP1Algorithm.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ void KarhunenLoeveP1Algorithm::run()
selectedVariance += eigenValues[K];
++ K;
}
while ((K < nbModesMax) && (selectedVariance < (1.0 - threshold_) * cumulatedVariance));
while ((K < nbModesMax) && (selectedVariance <= (1.0 - threshold_) * cumulatedVariance));
LOGINFO(OSS() << "Selected " << K << " eigenvalues out of " << eigenValues.getSize() << " computed");

// Reduce and rescale the eigenvectors
Expand Down
4 changes: 2 additions & 2 deletions lib/src/Base/Func/MarginalEvaluation.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ MarginalEvaluation::MarginalEvaluation()
/* Default constructor */
MarginalEvaluation::MarginalEvaluation(const EvaluationImplementation & evaluation,
const Indices & indices)
: EvaluationImplementation()
: MarginalEvaluation(evaluation.clone(), indices)
{
*this = MarginalEvaluation(evaluation.clone(), indices);
// Nothing to do
}

/* Default constructor */
Expand Down
4 changes: 2 additions & 2 deletions lib/src/Base/Func/MarginalGradient.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ MarginalGradient::MarginalGradient()
/* Parameter constructor */
MarginalGradient::MarginalGradient(const GradientImplementation & gradient,
const Indices & indices)
: GradientImplementation()
: MarginalGradient(gradient.clone(), indices)
{
*this = MarginalGradient(gradient.clone(), indices);
// Nothing to do
}

/* Parameters constructor */
Expand Down
4 changes: 2 additions & 2 deletions lib/src/Base/Func/MarginalHessian.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ MarginalHessian::MarginalHessian()
/* Parameter constructor */
MarginalHessian::MarginalHessian(const HessianImplementation & hessian,
const Indices & indices)
: HessianImplementation()
: MarginalHessian(hessian.clone(), indices)
{
*this = MarginalHessian(hessian.clone(), indices);
// Nothing to do
}

/* Parameters constructor */
Expand Down
4 changes: 2 additions & 2 deletions lib/src/Base/Func/SymbolicFunction.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ SymbolicFunction::SymbolicFunction ()
/* Parameter constructor */
SymbolicFunction::SymbolicFunction (const String & inputVariablesName,
const String & formula)
: Function()
: SymbolicFunction(Description(1, inputVariablesName), Description(1, formula))
{
*this = SymbolicFunction(Description(1, inputVariablesName), Description(1, formula));
// Nothing to do
}


Expand Down
2 changes: 2 additions & 0 deletions lib/src/Base/Graph/GraphImplementation.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,8 @@ void GraphImplementation::draw(const String & file,
const Scalar height,
SignedInteger drawingFormat)
{
LOGWARN(OSS() << "Graph.draw is deprecated");

// Override format base on extension
size_t pos = file.find_last_of(".");
Bool matchedExtension = false;
Expand Down
4 changes: 2 additions & 2 deletions lib/src/Base/Graph/openturns/Drawable.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ public:
/** Accessor for data */
Sample getData() const;

/** Generate R commands for plotting the graphic */
/** @deprecated Generate R commands for plotting the graphic */
String draw() const;

/** Get R point code from key */
UnsignedInteger getPointCode(const String key) const;

/** Clean all the temporary data created by draw() method */
/** @deprecated Clean all the temporary data created by draw() method */
void clean() const;

/** Give the colors name */
Expand Down
4 changes: 2 additions & 2 deletions lib/src/Base/Graph/openturns/DrawableImplementation.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ public:
/** Bounding box accessor */
virtual Interval getBoundingBox() const;

/** R command generating method, for plotting through R */
/** @deprecated R command generating method, for plotting through R */
virtual String draw() const;

/** Clean all the temporary data created by draw() method */
/** @deprecated Clean all the temporary data created by draw() method */
virtual void clean() const;

/** Clone method */
Expand Down
6 changes: 3 additions & 3 deletions lib/src/Base/Graph/openturns/Graph.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,16 @@ public:
String getTitle() const;
void setTitle(const String & title);

/** The method that generates the graphic files */
/** @deprecated The method that generates the graphic files */
void draw(const String & file,
const Scalar width = ResourceMap::GetAsUnsignedInteger("Graph-DefaultWidth"),
const Scalar height = ResourceMap::GetAsUnsignedInteger("Graph-DefaultHeight"),
SignedInteger format = GraphImplementation::ALL);

/** Get the R command corresponding to the graph */
/** @deprecated Get the R command corresponding to the graph */
String getRCommand() const;

/** Clean temporary files */
/** @deprecated Clean temporary files */
void clean();

/** Margin accessor */
Expand Down
6 changes: 3 additions & 3 deletions lib/src/Base/Graph/openturns/GraphImplementation.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,16 @@ public:
virtual String getTitle() const;
void setTitle(const String & title);

/** The method that generates the graphic files */
/** @deprecated The method that generates the graphic files */
void draw(const String & file,
const Scalar width = ResourceMap::GetAsUnsignedInteger("Graph-DefaultWidth"),
const Scalar height = ResourceMap::GetAsUnsignedInteger("Graph-DefaultHeight"),
SignedInteger format = ALL);

/** Get the R command corresponding to the graph */
/** @deprecated Get the R command corresponding to the graph */
String getRCommand() const;

/** Clean temporary files */
/** @deprecated Clean temporary files */
void clean();

/** Margin accessor */
Expand Down
8 changes: 5 additions & 3 deletions lib/src/Base/Stat/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,20 @@ ot_install_header_file (IsotropicCovarianceModel.hxx)
# Build on the fly source files
if (BISON_FOUND AND FLEX_FOUND)
ot_add_build_dir_to_include_dirs (${CMAKE_CURRENT_BINARY_DIR})
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/csv_parser.cc ${CMAKE_CURRENT_BINARY_DIR}/csv_parser.hh
set (BISON_FLAGS "-Wno-deprecated" CACHE STRING "bison flags")
separate_arguments(BISON_FLAGS)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/csv_parser.cc ${CMAKE_CURRENT_BINARY_DIR}/csv_parser.hh
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/csv_parser.yy
COMMAND ${BISON_EXECUTABLE}
ARGS -Wno-deprecated
ARGS ${BISON_FLAGS}
-o ${CMAKE_CURRENT_BINARY_DIR}/csv_parser.cc
${CMAKE_CURRENT_SOURCE_DIR}/csv_parser.yy
COMMENT "CSV parser generation"
)
ot_add_built_source_file (${CMAKE_CURRENT_BINARY_DIR}/csv_parser.cc)
add_custom_target (generate_csv_parser DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/csv_parser.cc)

add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/csv_lexer.cc ${CMAKE_CURRENT_BINARY_DIR}/csv_lexer.h
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/csv_lexer.cc ${CMAKE_CURRENT_BINARY_DIR}/csv_lexer.h
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/csv_lexer.ll
COMMAND ${FLEX_EXECUTABLE}
ARGS -o ${CMAKE_CURRENT_BINARY_DIR}/csv_lexer.cc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,6 @@ public:
/** String converter */
String __repr__() const override;

/** Compute the components alpha_k_p_ by projecting the model on the partial L2 basis */
void computeCoefficients(const Function & function,
const FunctionCollection & basis,
const Indices & indices,
const Indices & addedRanks,
const Indices & conservedRanks,
const Indices & removedRanks,
const UnsignedInteger marginalIndex = 0) override;

/** Method save() stores the object through the StorageManager */
void save(Advocate & adv) const override;

Expand All @@ -86,7 +77,14 @@ public:


protected:

/** Compute the components alpha_k_p_ by projecting the model on the partial L2 basis */
void computeCoefficients(const Function & function,
const FunctionCollection & basis,
const Indices & indices,
const Indices & addedRanks,
const Indices & conservedRanks,
const Indices & removedRanks,
const UnsignedInteger marginalIndex = 0) override;
private:

} ; /* class IntegrationStrategy */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ public:
/** String converter */
String __repr__() const override;

/** Method save() stores the object through the StorageManager */
void save(Advocate & adv) const override;

/** Method load() reloads the object from the StorageManager */
void load(Advocate & adv) override;

protected:
/** Compute the components alpha_k_p_ by projecting the model on the partial L2 basis */
void computeCoefficients(const Function & function,
const FunctionCollection & basis,
Expand All @@ -84,16 +91,6 @@ public:
const Indices & conservedRanks,
const Indices & removedRanks,
const UnsignedInteger marginalIndex = 0) override;

/** Method save() stores the object through the StorageManager */
void save(Advocate & adv) const override;

/** Method load() reloads the object from the StorageManager */
void load(Advocate & adv) override;


protected:

private:
/** Factory to build an ApproximationAlgorithmImplementation */
ApproximationAlgorithmImplementationFactoryImplementation p_approximationAlgorithmImplementationFactory_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ class OT_API ProjectionStrategy
: public TypedInterfaceObject<ProjectionStrategyImplementation>
{
CLASSNAME

// Make the FunctionalChaosAlgorithm class a friend of the ProjectionStrategyImplementation class
// as this last class is in charge of managing data that are part of the FunctionalChaosAlgorithm
// state
friend class FunctionalChaosAlgorithm;
public:

typedef ProjectionStrategyImplementation::FunctionCollection FunctionCollection;
Expand Down Expand Up @@ -79,6 +84,13 @@ public:
virtual void setExperiment(const WeightedExperiment & weightedExperiment);
virtual WeightedExperiment getExperiment() const;

/** String converter */
String __repr__() const override;

/** String converter */
String __str__(const String & offset = "") const override;

protected:
/** Compute the components alpha_k_p_ by projecting the model on the partial L2 basis */
void computeCoefficients(const Function & function,
const FunctionCollection & basis,
Expand All @@ -87,15 +99,6 @@ public:
const Indices & conservedRanks,
const Indices & removedRanks,
const UnsignedInteger marginalIndex = 0);

/** String converter */
String __repr__() const override;

/** String converter */
String __str__(const String & offset = "") const override;

protected:

private:

} ; /* class ProjectionStrategy */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class OT_API ProjectionStrategyImplementation
// as this last class is in charge of managing data that are part of the FunctionalChaosAlgorithm
// state
friend class FunctionalChaosAlgorithm;
friend class ProjectionStrategy;

public:

Expand Down Expand Up @@ -108,6 +109,13 @@ public:
virtual void setExperiment(const WeightedExperiment & weightedExperiment);
virtual WeightedExperiment getExperiment() const;

/** Method save() stores the object through the StorageManager */
void save(Advocate & adv) const override;

/** Method load() reloads the object from the StorageManager */
void load(Advocate & adv) override;

protected:
/** Compute the components alpha_k_p_ by projecting the model on the partial L2 basis */
virtual void computeCoefficients(const Function & function,
const FunctionCollection & basis,
Expand All @@ -117,13 +125,6 @@ public:
const Indices & removedRanks,
const UnsignedInteger marginalIndex = 0);

/** Method save() stores the object through the StorageManager */
void save(Advocate & adv) const override;

/** Method load() reloads the object from the StorageManager */
void load(Advocate & adv) override;

protected:
/** The collection of Alpha_k coefficients */
Point alpha_k_p_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ SimulationSensitivityAnalysis::SimulationSensitivityAnalysis(const RandomVector

/* Standard constructor */
SimulationSensitivityAnalysis::SimulationSensitivityAnalysis(const ProbabilitySimulationResult & result)
: PersistentObject()
: SimulationSensitivityAnalysis(result.getEvent())
{
*this = SimulationSensitivityAnalysis(result.getEvent());
// Nothing to do
}

/* Standard constructor */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ CalibrationAlgorithmImplementation::CalibrationAlgorithmImplementation(const Fun
, parameterPrior_(parameterPrior)
, result_()
{
// Nothing to do
// Allow for a dim-0 sample but it should have the right size internally
if (!inputObservations_.getDimension())
inputObservations_ = Sample(outputObservations.getSize(), 0);
}

/* Performs the actual computation. Must be overloaded by the actual calibration algorithm */
Expand Down
4 changes: 2 additions & 2 deletions lib/src/Uncertainty/Bayesian/GaussianLinearCalibration.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ GaussianLinearCalibration::GaussianLinearCalibration(const Function & model,
const UnsignedInteger parameterDimension = candidate.getDimension();
if (model.getParameterDimension() != parameterDimension) throw InvalidArgumentException(HERE) << "Error: expected a model of parameter dimension=" << parameterDimension << ", got parameter dimension=" << model.getParameterDimension();
if (parameterCovariance.getDimension() != parameterDimension) throw InvalidArgumentException(HERE) << "Error: expected a parameter covariance of dimension=" << parameterDimension << ", got dimension=" << parameterCovariance.getDimension();
const UnsignedInteger inputDimension = inputObservations.getDimension();
const UnsignedInteger inputDimension = inputObservations_.getDimension();
if (model.getInputDimension() != inputDimension) throw InvalidArgumentException(HERE) << "Error: expected a model of input dimension=" << inputDimension << ", got input dimension=" << model.getInputDimension();
const UnsignedInteger outputDimension = outputObservations.getDimension();
if (model.getOutputDimension() != outputDimension) throw InvalidArgumentException(HERE) << "Error: expected a model of output dimension=" << outputDimension << ", got output dimension=" << model.getOutputDimension();
const UnsignedInteger size = inputObservations.getSize();
const UnsignedInteger size = outputObservations.getSize();
if (outputObservations.getSize() != size) throw InvalidArgumentException(HERE) << "Error: expected an output sample of size=" << size << ", got size=" << outputObservations.getSize();
globalErrorCovariance_ = errorCovariance.getDimension() != outputDimension;
if (globalErrorCovariance_ && !(errorCovariance.getDimension() == outputDimension * size)) throw InvalidArgumentException(HERE) << "Error: expected an error covariance either of dimension=" << outputDimension << " or dimension=" << outputDimension * size << ", got dimension=" << errorCovariance.getDimension();
Expand Down
4 changes: 2 additions & 2 deletions lib/src/Uncertainty/Bayesian/GaussianNonLinearCalibration.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ GaussianNonLinearCalibration::GaussianNonLinearCalibration(const Function & mode
const UnsignedInteger parameterDimension = candidate.getDimension();
if (model.getParameterDimension() != parameterDimension) throw InvalidArgumentException(HERE) << "Error: expected a model of parameter dimension=" << parameterDimension << ", got parameter dimension=" << model.getParameterDimension();
if (parameterCovariance.getDimension() != parameterDimension) throw InvalidArgumentException(HERE) << "Error: expected a parameter covariance of dimension=" << parameterDimension << ", got dimension=" << parameterCovariance.getDimension();
const UnsignedInteger inputDimension = inputObservations.getDimension();
const UnsignedInteger inputDimension = inputObservations_.getDimension();
if (model.getInputDimension() != inputDimension) throw InvalidArgumentException(HERE) << "Error: expected a model of input dimension=" << inputDimension << ", got input dimension=" << model.getInputDimension();
const UnsignedInteger outputDimension = outputObservations.getDimension();
if (model.getOutputDimension() != outputDimension) throw InvalidArgumentException(HERE) << "Error: expected a model of output dimension=" << outputDimension << ", got output dimension=" << model.getOutputDimension();
const UnsignedInteger size = inputObservations.getSize();
const UnsignedInteger size = outputObservations.getSize();
if (outputObservations.getSize() != size) throw InvalidArgumentException(HERE) << "Error: expected an output sample of size=" << size << ", got size=" << outputObservations.getSize();
globalErrorCovariance_ = errorCovariance.getDimension() != outputDimension;
if (globalErrorCovariance_ && !(errorCovariance.getDimension() == outputDimension * size)) throw InvalidArgumentException(HERE) << "Error: expected an error covariance either of dimension=" << outputDimension << " or dimension=" << outputDimension * size << ", got dimension=" << errorCovariance.getDimension();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ LinearLeastSquaresCalibration::LinearLeastSquaresCalibration(const Function & mo
// Check the input
const UnsignedInteger parameterDimension = candidate.getDimension();
if (model.getParameterDimension() != parameterDimension) throw InvalidArgumentException(HERE) << "Error: expected a model of parameter dimension=" << parameterDimension << ", got parameter dimension=" << model.getParameterDimension();
const UnsignedInteger inputDimension = inputObservations.getDimension();
const UnsignedInteger inputDimension = inputObservations_.getDimension();
if (model.getInputDimension() != inputDimension) throw InvalidArgumentException(HERE) << "Error: expected a model of input dimension=" << inputDimension << ", got input dimension=" << model.getInputDimension();
const UnsignedInteger outputDimension = outputObservations.getDimension();
if (model.getOutputDimension() != outputDimension) throw InvalidArgumentException(HERE) << "Error: expected a model of output dimension=" << outputDimension << ", got output dimension=" << model.getOutputDimension();
const UnsignedInteger size = inputObservations.getSize();
const UnsignedInteger size = outputObservations.getSize();
if (outputObservations.getSize() != size) throw InvalidArgumentException(HERE) << "Error: expected an output sample of size=" << size << ", got size=" << outputObservations.getSize();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ NonLinearLeastSquaresCalibration::NonLinearLeastSquaresCalibration(const Functio
, bootstrapSize_(ResourceMap::GetAsUnsignedInteger("NonLinearLeastSquaresCalibration-BootstrapSize"))
{
// Check the input
const UnsignedInteger inputDimension = inputObservations.getDimension();
const UnsignedInteger inputDimension = inputObservations_.getDimension();
if (model.getInputDimension() != inputDimension) throw InvalidArgumentException(HERE) << "Error: expected a model of input dimension=" << inputDimension << ", got input dimension=" << model.getInputDimension();
const UnsignedInteger outputDimension = outputObservations.getDimension();
if (model.getOutputDimension() != outputDimension) throw InvalidArgumentException(HERE) << "Error: expected a model of output dimension=" << outputDimension << ", got output dimension=" << model.getOutputDimension();
const UnsignedInteger size = inputObservations.getSize();
const UnsignedInteger size = outputObservations.getSize();
if (outputObservations.getSize() != size) throw InvalidArgumentException(HERE) << "Error: expected an output sample of size=" << size << ", got size=" << outputObservations.getSize();

// Now the automatic selection of the algorithm
Expand Down
Loading

0 comments on commit dd15205

Please sign in to comment.