Skip to content

Commit f479d4d

Browse files
author
Sofiane HADDAD
committed
In CovarianceModel, made public {g,s}etFullParameter and getFullParameterDescription methods
Fix also missing sign checking
1 parent 7ad8ab9 commit f479d4d

File tree

6 files changed

+95
-3
lines changed

6 files changed

+95
-3
lines changed

lib/src/Base/Stat/CovarianceModel.cxx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,23 @@ Indices CovarianceModel::getActiveParameter() const
302302
return getImplementation()->getActiveParameter();
303303
}
304304

305+
306+
/* setter for the full parameter */
307+
void CovarianceModel::setFullParameter(const Point & parameter)
308+
{
309+
getImplementation()->setFullParameter(parameter);
310+
}
311+
312+
Point CovarianceModel::getFullParameter() const
313+
{
314+
return getImplementation()->getFullParameter();
315+
}
316+
317+
Description CovarianceModel::getFullParameterDescription() const
318+
{
319+
return getImplementation()->getFullParameterDescription();
320+
}
321+
305322
/* Is it a stationary covariance model ? */
306323
Bool CovarianceModel::isStationary() const
307324
{

lib/src/Base/Stat/CovarianceModelImplementation.cxx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,14 +574,24 @@ void CovarianceModelImplementation::setFullParameter(const Point & parameter)
574574
// Here we manage only the generic parameters
575575
// First the scale parameter
576576
UnsignedInteger index = 0;
577+
// Check the size
578+
const UnsignedInteger totalSize = spatialDimension_ + dimension_ * (dimension_ + 1) / 2;
579+
if (parameter.getSize() < totalSize)
580+
throw InvalidArgumentException(HERE) << "In CovarianceModelImplementation::setFullParameter, points have incompatible size. Point size = " << parameter.getSize()
581+
<< " whereas expected size = " << totalSize ;
582+
577583
for (UnsignedInteger i = 0; i < spatialDimension_; ++ i)
578584
{
585+
if (!(parameter[index] > 0.0))
586+
throw InvalidArgumentException(HERE) << "In CovarianceModelImplementation::setParameter, the component " << index << " of scale is non positive" ;
579587
scale_[i] = parameter[index];
580588
++ index;
581589
}
582590
// Second the amplitude parameter
583591
for (UnsignedInteger i = 0; i < dimension_; ++ i)
584592
{
593+
if (!(parameter[index] > 0.0))
594+
throw InvalidArgumentException(HERE) << "In CovarianceModelImplementation::setParameter, the component " << index << " of amplitude is non positive" ;
585595
amplitude_[i] = parameter[index];
586596
++ index;
587597
}

lib/src/Base/Stat/openturns/CovarianceModel.hxx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ public:
153153
void setActiveParameter(const Indices & active);
154154
Indices getActiveParameter() const;
155155

156+
157+
/* setter for the full parameter */
158+
virtual void setFullParameter(const Point & parameter);
159+
virtual Point getFullParameter() const;
160+
virtual Description getFullParameterDescription() const;
161+
156162
/** Is it a stationary model ? */
157163
virtual Bool isStationary() const;
158164

lib/src/Base/Stat/openturns/CovarianceModelImplementation.hxx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,11 @@ public:
177177
virtual void setActiveParameter(const Indices & active);
178178
virtual Indices getActiveParameter() const;
179179

180+
/* setter for the full parameter */
181+
virtual void setFullParameter(const Point & parameter);
182+
virtual Point getFullParameter() const;
183+
virtual Description getFullParameterDescription() const;
184+
180185
/** String converter */
181186
virtual String __repr__() const;
182187

@@ -202,9 +207,6 @@ public:
202207
virtual void load(Advocate & adv);
203208

204209
protected:
205-
virtual void setFullParameter(const Point & parameter);
206-
virtual Point getFullParameter() const;
207-
virtual Description getFullParameterDescription() const;
208210

209211
// set the covariance structure
210212
void updateSpatialCovariance();

python/src/CovarianceModelImplementation_doc.i.in

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,3 +661,54 @@ graph : :class:`~openturns.Graph`
661661
%feature("docstring") OT::CovarianceModelImplementation::draw
662662
OT_CovarianceModel_draw_doc
663663

664+
// ---------------------------------------------------------------------
665+
666+
%define OT_CovarianceModel_setFullParameter_doc
667+
"Set the full parameters of the covariance function.
668+
669+
Parameters
670+
----------
671+
parameter : :class:`~openturns.Point`
672+
List the full parameter of the covariance function i.e.
673+
scale parameter :math:`\vect{\theta} \in \Rset^n`, the
674+
the amplitude parameter :math:`\vect{\sigma} \in \Rset^d`,
675+
the Spatial correlation parameter :math:`\mat{R} \in \cS_d^+([-1,1])`;
676+
and potential other parameter depending on the model;
677+
678+
Must be at least of dimension :math:`n+\frac{d(d+1)}{2}`."
679+
%enddef
680+
%feature("docstring") OT::CovarianceModelImplementation::setFullParameter
681+
OT_CovarianceModel_setFullParameter_doc
682+
683+
// ---------------------------------------------------------------------
684+
685+
%define OT_CovarianceModel_getFullParameter_doc
686+
"Get the full parameters of the covariance function.
687+
688+
Returns
689+
-------
690+
parameter : :class:`~openturns.Point`
691+
List the full parameter of the covariance function i.e.
692+
scale parameter :math:`\vect{\theta} \in \Rset^n`, the
693+
the amplitude parameter :math:`\vect{\sigma} \in \Rset^d`,
694+
the Spatial correlation parameter :math:`\mat{R} \in \cS_d^+([-1,1])`;
695+
and potential other parameter depending on the model;
696+
"
697+
%enddef
698+
%feature("docstring") OT::CovarianceModelImplementation::getFullParameter
699+
OT_CovarianceModel_getFullParameter_doc
700+
701+
// ---------------------------------------------------------------------
702+
703+
%define OT_CovarianceModel_getFullParameterDescription_doc
704+
"Get the description full parameters of the covariance function.
705+
706+
Returns
707+
-------
708+
description : :class:`~openturns.Description`
709+
Description of the full parameter of the covariance function.
710+
"
711+
%enddef
712+
%feature("docstring") OT::CovarianceModelImplementation::getFullParameterDescription
713+
OT_CovarianceModel_getFullParameterDescription_doc
714+

python/src/CovarianceModel_doc.i.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,9 @@ OT_CovarianceModel_operator_doc
6060
OT_CovarianceModel_setActiveParameter_doc
6161
%feature("docstring") OT::CovarianceModel::getActiveParameter
6262
OT_CovarianceModel_getActiveParameter_doc
63+
%feature("docstring") OT::CovarianceModel::setFullParameter
64+
OT_CovarianceModel_setFullParameter_doc
65+
%feature("docstring") OT::CovarianceModel::getFullParameter
66+
OT_CovarianceModel_getFullParameter_doc
67+
%feature("docstring") OT::CovarianceModel::getFullParameterDescription
68+
OT_CovarianceModel_getFullParameterDescription_doc

0 commit comments

Comments
 (0)