Warn that ParameterSpace cannot mix SPDistribution with OTDistribution
We cannot add a random variable defined by an SPDistribution
to a ParameterSpace
containing a random variable defined by an OTDistribution
.
The reason is that the ParameterSpace
creates a ComposedDistribution
but an OTDistribution
can be composed only with OTDistribution
s.
We should warn the user about this requirement: do not mix SPDistribution
with OTDistribution
in ParameterSpace
. Or more precisely: do not mix distributions from different families.
And also raise an exception because the TypeError
raised by OpenTURNS is hard to understand (see below).
Reproducer
from gemseo.algos.parameter_space import ParameterSpace
parameter_space = ParameterSpace()
parameter_space.add_random_variable("x", "OTUniformDistribution")
parameter_space.add_random_variable("y", "SPUniformDistribution")
print(parameter_space.compute_samples(3))
Ugly TypeError
Traceback (most recent call last):
File "C:\Users\matthias.delozzo\workspace\GEMSEO\gemseo\sandbox\_foo.py", line 5, in <module>
parameter_space.add_random_variable("y", "SPUniformDistribution")
File "C:\Users\matthias.delozzo\workspace\GEMSEO\gemseo\src\gemseo\algos\parameter_space.py", line 227, in add_random_variable
self._build_composed_distribution()
File "C:\Users\matthias.delozzo\workspace\GEMSEO\gemseo\src\gemseo\algos\parameter_space.py", line 234, in _build_composed_distribution
self.distribution = tmp_marginal._COMPOSED_DISTRIBUTION(marginals, self._copula)
File "C:\Users\matthias.delozzo\workspace\GEMSEO\gemseo\src\gemseo\uncertainty\distributions\openturns\composed.py", line 79, in __init__
self.distribution = ots.ComposedDistribution(marginals, ot_copula)
File "C:\Users\matthias.delozzo\workspace\GEMSEO\gemseo\.tox\py39\lib\site-packages\openturns\model_copula.py", line 15933, in __init__
_model_copula.ComposedDistribution_swiginit(self, _model_copula.new_ComposedDistribution(*args))
TypeError: Wrong number or type of arguments for overloaded function 'new_ComposedDistribution'.
Possible C/C++ prototypes are:
OT::ComposedDistribution::ComposedDistribution()
OT::ComposedDistribution::ComposedDistribution(OT::ComposedDistribution::DistributionCollection const &)
OT::ComposedDistribution::ComposedDistribution(OT::ComposedDistribution::DistributionCollection const &,OT::Distribution const &)
OT::ComposedDistribution::ComposedDistribution(OT::ComposedDistribution const &)