Skip to content

Commit b574e0f

Browse files
authored
Merge pull request openturns#477 from sofianehaddad/sh/fix-ns-su
Various fixes and enhancements
2 parents 0d09c26 + d953a3a commit b574e0f

12 files changed

+119
-14
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
=== Bug fixes ===
2626
* #890 (Cannot build triangular distribution)
27+
* #891 (Viewer issue with Pairs drawables)
2728

2829

2930
== 1.9 release (2017-04-18) == #release-1.9

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: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ void CovarianceModelImplementation::setAmplitude(const Point & amplitude)
508508
{
509509
if (amplitude.getDimension() != dimension_) throw InvalidArgumentException(HERE) << "In CovarianceModelImplementation::setAmplitude: the given amplitude has a dimension=" << amplitude.getDimension() << " different from the dimension=" << dimension_;
510510
for (UnsignedInteger index = 0; index < dimension_; ++index)
511-
if (amplitude[index] <= 0)
511+
if (!(amplitude[index] > 0.0))
512512
throw InvalidArgumentException(HERE) << "In CovarianceModelImplementation::setAmplitude, the component " << index << " of amplitude is non positive" ;
513513
amplitude_ = amplitude;
514514
updateSpatialCovariance();
@@ -524,7 +524,7 @@ void CovarianceModelImplementation::setScale(const Point & scale)
524524
{
525525
if (scale.getDimension() != spatialDimension_) throw InvalidArgumentException(HERE) << "In CovarianceModelImplementation::setScale: the given scale has a dimension=" << scale.getDimension() << " different from the input dimension=" << spatialDimension_;
526526
for (UnsignedInteger index = 0; index < spatialDimension_; ++index)
527-
if (scale[index] <= 0)
527+
if (!(scale[index] > 0.0))
528528
throw InvalidArgumentException(HERE) << "In CovarianceModelImplementation::setScale: the component " << index << " of scale is non positive" ;
529529
scale_ = scale;
530530
}
@@ -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/SampleImplementation.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,7 @@ SampleImplementation SampleImplementation::sortUnique() const
13271327
}
13281328
}
13291329
if (last + 1 < size_) sampleUnique.erase(last + 1, size_);
1330+
if (!p_description_.isNull()) sampleUnique.setDescription(getDescription());
13301331
return sampleUnique;
13311332
}
13321333

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();

lib/src/Uncertainty/StatTests/VisualTest.cxx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,21 @@ VisualTest::VisualTest()
4040
{
4141
}
4242

43+
/* Draw the empirical CDF of the Sample when its dimension is 1 */
44+
Graph VisualTest::DrawEmpiricalCDF(const Sample & sample)
45+
{
46+
if (sample.getDimension() != 1)
47+
throw InvalidDimensionException(HERE) << "In VisualTest::DrawEmpiricalCDF: sample should be of dimension 1, here dimension=" << sample.getDimension();
48+
return UserDefined(sample).drawCDF();
49+
}
50+
4351
/* Draw the empirical CDF of the Sample when its dimension is 1 */
4452
Graph VisualTest::DrawEmpiricalCDF(const Sample & sample,
4553
const Scalar xMin,
4654
const Scalar xMax)
4755
{
56+
if (sample.getDimension() != 1)
57+
throw InvalidDimensionException(HERE) << "In VisualTest::DrawEmpiricalCDF: sample should be of dimension 1, here dimension=" << sample.getDimension();
4858
return UserDefined(sample).drawCDF(xMin, xMax);
4959
}
5060

lib/src/Uncertainty/StatTests/openturns/VisualTest.hxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public:
4040

4141

4242
/** Draw the empirical CDF of the Sample when its dimension is 1 */
43+
static Graph DrawEmpiricalCDF(const Sample & sample);
44+
4345
static Graph DrawEmpiricalCDF(const Sample & sample,
4446
const Scalar xMin,
4547
const Scalar xMax);

python/src/CovarianceModelImplementation_doc.i.in

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,9 +553,9 @@ OT_CovarianceModel_set_nugget_factor_doc
553553
%define OT_CovarianceModel_setParameter_doc
554554
"Set the parameters of the covariance function.
555555

556-
Returns
557-
-------
558-
parameters : :class:`~openturns.PointWithDescription`
556+
Parameters
557+
----------
558+
parameters : :class:`~openturns.Point`
559559
List of the scale parameter :math:`\vect{\theta} \in \Rset^n` and the
560560
amplitude parameter :math:`\vect{\sigma} \in \Rset^d` of the covariance
561561
function.
@@ -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)