Skip to content

Commit 87e21e6

Browse files
committed
Fix Linux build
1 parent d698fe6 commit 87e21e6

File tree

6 files changed

+25
-38
lines changed

6 files changed

+25
-38
lines changed

.ci_support/run_docker_linux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ mkdir build && cd build
77
cmake -DCMAKE_INSTALL_PREFIX=~/.local \
88
-DCMAKE_UNITY_BUILD=ON \
99
-DCMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic -Wshadow -Werror -D_GLIBCXX_ASSERTIONS --coverage" \
10-
-DSWIG_COMPILE_FLAGS="-O1 -Wno-unused-parameter" \
10+
-DSWIG_COMPILE_FLAGS="-O1 -Wno-unused-parameter -Wno-shadow" \
1111
-DUSE_SPHINX=ON -DSPHINX_FLAGS="-W -T -j4" \
1212
/io
1313
make install

lib/src/VineCopula.cxx

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
*/
2121
#include "otvine/VineCopula.hxx"
2222
#include <openturns/PersistentObjectFactory.hxx>
23-
#include <openturns/ClaytonCopula.hxx>
24-
#include <openturns/GumbelCopula.hxx>
25-
#include <openturns/FrankCopula.hxx>
2623

2724
#include <vinecopulib.hpp>
2825

@@ -140,28 +137,6 @@ String VineCopula::__repr__() const
140137
return oss;
141138
}
142139

143-
Distribution VineCopula::asNative() const
144-
{
145-
if (p_vinecop_->get_dim() != 2)
146-
throw NotYetImplementedException(HERE) << "dim is not 2";
147-
std::vector<std::vector<vinecopulib::Bicop> > pairs = p_vinecop_->get_all_pair_copulas();
148-
if (pairs.size() != 1 && pairs[0].size() != 1)
149-
throw NotYetImplementedException(HERE) << "tree contains more than one node";
150-
vinecopulib::Bicop bicop = pairs[0][0];
151-
int rotation = bicop.get_rotation();
152-
if (rotation != 0)
153-
throw NotYetImplementedException(HERE) << "rotation is not 0";
154-
const Scalar theta = bicop.get_parameters()(0, 0);
155-
if (bicop.get_family_name() == "Clayton")
156-
return ClaytonCopula(theta);
157-
else if (bicop.get_family_name() == "Frank")
158-
return FrankCopula(theta);
159-
else if (bicop.get_family_name() == "Gumbel")
160-
return GumbelCopula(theta);
161-
else
162-
throw NotYetImplementedException(HERE) << "unknown family: " << bicop.get_family_name();
163-
}
164-
165140
/* Method save() stores the object through the StorageManager */
166141
void VineCopula::save(Advocate & adv) const
167142
{

lib/src/VineCopulaFactory.cxx

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
*/
2121
#include "otvine/VineCopulaFactory.hxx"
2222
#include <openturns/PersistentObjectFactory.hxx>
23+
#include <openturns/ClaytonCopula.hxx>
24+
#include <openturns/GumbelCopula.hxx>
25+
#include <openturns/FrankCopula.hxx>
2326

2427
#include <vinecopulib.hpp>
2528

@@ -47,7 +50,7 @@ VineCopulaFactory * VineCopulaFactory::clone() const
4750
}
4851

4952
/* example of a func that return a point squared. */
50-
VineCopula VineCopulaFactory::buildAsNative(const Sample & sample) const
53+
Distribution VineCopulaFactory::build(const Sample & sample) const
5154
{
5255
const UnsignedInteger dimension = sample.getDimension();
5356
const UnsignedInteger size = sample.getSize();
@@ -57,21 +60,36 @@ VineCopula VineCopulaFactory::buildAsNative(const Sample & sample) const
5760
data(i, j) = sample(i, j);
5861
Pointer <vinecopulib::Vinecop> p_vinecop = new vinecopulib::Vinecop(dimension);
5962
std::vector<vinecopulib::BicopFamily> family_set;
60-
#if 1
63+
#if 0
6164
family_set = {
6265
vinecopulib::BicopFamily::clayton,
6366
vinecopulib::BicopFamily::gumbel,
6467
vinecopulib::BicopFamily::frank};
6568
#endif
6669
vinecopulib::FitControlsVinecop controls(family_set);
6770
p_vinecop->select(data, controls);
71+
72+
#if 0
73+
std::vector<std::vector<vinecopulib::Bicop> > pairs = p_vinecop->get_all_pair_copulas();
74+
if (p_vinecop->get_dim() == 2 && pairs.size() == 1 && pairs[0].size() == 1)
75+
{
76+
vinecopulib::Bicop bicop = pairs[0][0];
77+
int rotation = bicop.get_rotation();
78+
if (rotation == 0)
79+
{
80+
const Scalar theta = bicop.get_parameters()(0, 0);
81+
if (bicop.get_family_name() == "Clayton")
82+
return ClaytonCopula(theta);
83+
else if (bicop.get_family_name() == "Frank")
84+
return FrankCopula(theta);
85+
else if (bicop.get_family_name() == "Gumbel")
86+
return GumbelCopula(theta);
87+
}
88+
}
89+
#endif
6890
return VineCopula(p_vinecop);
6991
}
7092

71-
Distribution VineCopulaFactory::build(const Sample & sample) const
72-
{
73-
return buildAsNative(sample);
74-
}
7593

7694
/* String converter */
7795
String VineCopulaFactory::__repr__() const

lib/src/otvine/VineCopula.hxx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ protected:
5656
OT::Bool equals(const DistributionImplementation & other) const override;
5757
public:
5858

59-
/** Convert to native OT distribution if possible */
60-
OT::Distribution asNative() const;
61-
6259
/** String converter */
6360
OT::String __repr__() const override;
6461

lib/src/otvine/VineCopulaFactory.hxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public:
4848

4949
/** example of a func that return a point squared. **/
5050
OT::Distribution build(const OT::Sample & sample) const;
51-
VineCopula buildAsNative(const OT::Sample & sample) const;
5251

5352
/** String converter */
5453
OT::String __repr__() const override;

python/test/t_VineCopulaFactory_std.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,3 @@
2424

2525
factory2 = ot.ClaytonCopulaFactory()
2626
print(factory2.build(sample))
27-
28-
print(factory.buildAsNative(sample).asNative())

0 commit comments

Comments
 (0)