From 4457384d9e726114be3365a146ed4c2d91d3f4a0 Mon Sep 17 00:00:00 2001
From: Le Roux Erwan <erwan.le-roux@irstea.fr>
Date: Fri, 23 Nov 2018 18:47:43 +0100
Subject: [PATCH] [DATASET] add test_dataset

---
 .../max_stable_model/max_stable_models.py     |  1 +
 .../test_dataset.py                           | 29 +++++++++++++++++--
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/extreme_estimator/extreme_models/max_stable_model/max_stable_models.py b/extreme_estimator/extreme_models/max_stable_model/max_stable_models.py
index 1835c6a5..812a7a94 100644
--- a/extreme_estimator/extreme_models/max_stable_model/max_stable_models.py
+++ b/extreme_estimator/extreme_models/max_stable_model/max_stable_models.py
@@ -10,6 +10,7 @@ class Smith(AbstractMaxStableModel):
         super().__init__(params_start_fit=params_start_fit, params_sample=params_sample)
         self.cov_mod = 'gauss'
         self.default_params_start_fit = {
+            'var': 1,
             'cov11': 1,
             'cov12': 0,
             'cov22': 1
diff --git a/test/test_spatio_temporal_dataset/test_dataset.py b/test/test_spatio_temporal_dataset/test_dataset.py
index 320d6877..f19f40b6 100644
--- a/test/test_spatio_temporal_dataset/test_dataset.py
+++ b/test/test_spatio_temporal_dataset/test_dataset.py
@@ -1,10 +1,33 @@
+from rpy2.rinterface import RRuntimeError
 import unittest
+from itertools import product
+
+from extreme_estimator.extreme_models.max_stable_model.utils import load_max_stable_models
+from spatio_temporal_dataset.coordinates.utils import load_coordinates
+from spatio_temporal_dataset.dataset.simulation_dataset import MaxStableDataset
 
 
 class TestDataset(unittest.TestCase):
-    pass
-    # already done by the estimator somehow,
-    # maybe I could add some more precise test that check for 1D, 2D and 3D Datasets
+    nb_obs = 10
+    nb_points = 10
+
+    def test_max_stable_dataset_R1_and_R2(self):
+        max_stable_models = load_max_stable_models()[:]
+        coordinatess = load_coordinates(self.nb_points)[:-1]
+        for coordinates, max_stable_model in product(coordinatess, max_stable_models):
+            MaxStableDataset.from_sampling(nb_obs=self.nb_obs,
+                                           max_stable_model=max_stable_model,
+                                           coordinates=coordinates)
+        self.assertTrue(True)
+
+    def test_max_stable_dataset_crash_R3(self):
+        # test to warn me when spatialExtremes handles R3
+        with self.assertRaises(RRuntimeError):
+            smith_process = load_max_stable_models()[0]
+            coordinates_R3 = load_coordinates(self.nb_points)[-1]
+            MaxStableDataset.from_sampling(nb_obs=self.nb_obs,
+                                           max_stable_model=smith_process,
+                                           coordinates=coordinates_R3)
 
 
 if __name__ == '__main__':
-- 
GitLab