From 9a18669a0a42e0ba30b7a03b3b81e783ac7183fc Mon Sep 17 00:00:00 2001
From: Baptiste Bauvin <baptiste.bauvin@lis-lab.fr>
Date: Thu, 10 Oct 2019 10:23:43 -0400
Subject: [PATCH] Test passing

---
 .../utils/get_multiview_db.py                        |  2 +-
 multiview_platform/tests/test_ExecClassif.py         |  5 ++---
 .../tests/test_mono_view/test_ExecClassifMonoView.py | 12 ++++++------
 .../tests/test_utils/test_configuration.py           |  2 +-
 .../tests/test_utils/test_execution.py               |  8 ++++----
 .../tests/test_utils/test_hyper_parameter_search.py  |  7 ++-----
 multiview_platform/tests/utils.py                    |  4 ++--
 setup.py                                             |  2 +-
 8 files changed, 19 insertions(+), 23 deletions(-)

diff --git a/multiview_platform/mono_multi_view_classifiers/utils/get_multiview_db.py b/multiview_platform/mono_multi_view_classifiers/utils/get_multiview_db.py
index c4c5d376..0aec7f32 100644
--- a/multiview_platform/mono_multi_view_classifiers/utils/get_multiview_db.py
+++ b/multiview_platform/mono_multi_view_classifiers/utils/get_multiview_db.py
@@ -285,7 +285,7 @@ def get_classic_db_hdf5(views, path_f, name_DB, nb_class, asked_labels_names,
         dataset_name = dataset.get_name()
     else:
         pass
-    return dataset_file, labels_dictionary, dataset_name
+    return dataset, labels_dictionary, dataset_name
 
 #
 # def add_gaussian_noise(dataset_file, random_state, path_f, dataset_name,
diff --git a/multiview_platform/tests/test_ExecClassif.py b/multiview_platform/tests/test_ExecClassif.py
index 71f53c99..84f4c5f5 100644
--- a/multiview_platform/tests/test_ExecClassif.py
+++ b/multiview_platform/tests/test_ExecClassif.py
@@ -328,8 +328,7 @@ class Test_execOneBenchmark(unittest.TestCase):
     @classmethod
     def setUp(cls):
         rm_tmp()
-        print(os.getcwd())
-        os.mkdir("../tests/tmp_tests")
+        os.mkdir(tmp_path)
         cls.args = {
             "Base": {"name": "chicken_is_heaven", "type": "type",
                      "pathf": "pathF"},
@@ -396,7 +395,7 @@ class Test_execOneBenchmark_multicore(unittest.TestCase):
     @classmethod
     def setUpClass(cls):
         rm_tmp()
-        os.mkdir("./tests/tmp_tests")
+        os.mkdir(tmp_path)
         cls.args = {
             "Base": {"name": "chicken_is_heaven", "type": "type",
                      "pathf": "pathF"},
diff --git a/multiview_platform/tests/test_mono_view/test_ExecClassifMonoView.py b/multiview_platform/tests/test_mono_view/test_ExecClassifMonoView.py
index 469adf7d..1e1625ae 100644
--- a/multiview_platform/tests/test_mono_view/test_ExecClassifMonoView.py
+++ b/multiview_platform/tests/test_mono_view/test_ExecClassifMonoView.py
@@ -16,7 +16,7 @@ class Test_initConstants(unittest.TestCase):
     @classmethod
     def setUpClass(cls):
         rm_tmp()
-        os.mkdir("multiview_platform/tests/tmp_tests")
+        os.mkdir(tmp_path)
         cls.view_name="test_dataset"
         cls.datasetFile = h5py.File(
             tmp_path+"test.hdf5", "w")
@@ -63,7 +63,7 @@ class Test_initConstants(unittest.TestCase):
             tmp_path+"test_dir/test_clf/test_dataset")
         os.rmdir(tmp_path+"test_dir/test_clf")
         os.rmdir(tmp_path+"test_dir")
-        os.rmdir("multiview_platform/tests/tmp_tests")
+        os.rmdir(tmp_path)
 
 
 class Test_initTrainTest(unittest.TestCase):
@@ -103,7 +103,7 @@ class Test_getHPs(unittest.TestCase):
     @classmethod
     def setUpClass(cls):
         rm_tmp()
-        os.mkdir("multiview_platform/tests/tmp_tests")
+        os.mkdir(tmp_path)
         cls.classifierModule = decision_tree
         cls.hyper_param_search = "randomized_search"
         cls.n_iter = 2
@@ -122,10 +122,10 @@ class Test_getHPs(unittest.TestCase):
 
     @classmethod
     def tearDownClass(cls):
-        for file_name in os.listdir("multiview_platform/tests/tmp_tests"):
+        for file_name in os.listdir(tmp_path):
             os.remove(
-                os.path.join("multiview_platform/tests/tmp_tests", file_name))
-        os.rmdir("multiview_platform/tests/tmp_tests")
+                os.path.join(tmp_path, file_name))
+        os.rmdir(tmp_path)
 
     def test_simple(self):
         kwargs, test_folds_predictions = exec_classif_mono_view.getHPs(self.classifierModule,
diff --git a/multiview_platform/tests/test_utils/test_configuration.py b/multiview_platform/tests/test_utils/test_configuration.py
index 9285155c..5e487e76 100644
--- a/multiview_platform/tests/test_utils/test_configuration.py
+++ b/multiview_platform/tests/test_utils/test_configuration.py
@@ -21,7 +21,7 @@ class Test_get_the_args(unittest.TestCase):
     @classmethod
     def tearDownClass(cls):
         os.remove(tmp_path+"config_temp.yml")
-        os.rmdir("multiview_platform/tests/tmp_tests")
+        os.rmdir(tmp_path)
 
     def test_file_loading(self):
         config_dict = configuration.get_the_args(self.path_to_config_file)
diff --git a/multiview_platform/tests/test_utils/test_execution.py b/multiview_platform/tests/test_utils/test_execution.py
index 8848dc56..3a351de1 100644
--- a/multiview_platform/tests/test_utils/test_execution.py
+++ b/multiview_platform/tests/test_utils/test_execution.py
@@ -196,22 +196,22 @@ class Test_genDirecortiesNames(unittest.TestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.directory = "../chicken_is_heaven/"
+        cls.directory = tmp_path
         cls.stats_iter = 5
 
     def test_simple_ovo(cls):
         directories = execution.gen_direcorties_names(cls.directory,
                                                     cls.stats_iter)
         cls.assertEqual(len(directories), 5)
-        cls.assertEqual(directories[0], "../chicken_is_heaven/iter_1/")
-        cls.assertEqual(directories[-1], "../chicken_is_heaven/iter_5/")
+        cls.assertEqual(directories[0], os.path.join(tmp_path, "iter_1/"))
+        cls.assertEqual(directories[-1], os.path.join(tmp_path, "iter_5/"))
 
     def test_ovo_no_iter(cls):
         cls.stats_iter = 1
         directories = execution.gen_direcorties_names(cls.directory,
                                                     cls.stats_iter)
         cls.assertEqual(len(directories), 1)
-        cls.assertEqual(directories[0], "../chicken_is_heaven/")
+        cls.assertEqual(directories[0], tmp_path)
 
 
 class Test_genArgumentDictionaries(unittest.TestCase):
diff --git a/multiview_platform/tests/test_utils/test_hyper_parameter_search.py b/multiview_platform/tests/test_utils/test_hyper_parameter_search.py
index edc164fa..4917c207 100644
--- a/multiview_platform/tests/test_utils/test_hyper_parameter_search.py
+++ b/multiview_platform/tests/test_utils/test_hyper_parameter_search.py
@@ -18,7 +18,7 @@ class Test_randomized_search(unittest.TestCase):
         rm_tmp()
         cls.random_state = np.random.RandomState(42)
         cls.view_weights = [0.5, 0.5]
-        os.mkdir("multiview_platform/tests/tmp_tests")
+        os.mkdir(tmp_path)
         cls.dataset_file = h5py.File(
             tmp_path+"test_file.hdf5", "w")
         cls.labels = cls.dataset_file.create_dataset("Labels",
@@ -49,10 +49,7 @@ class Test_randomized_search(unittest.TestCase):
     @classmethod
     def tearDownClass(cls):
         cls.dataset_file.close()
-        for file_name in os.listdir("multiview_platform/tests/tmp_tests"):
-            os.remove(
-                os.path.join("multiview_platform/tests/tmp_tests", file_name))
-        os.rmdir("multiview_platform/tests/tmp_tests")
+        rm_tmp()
 
 
     def test_simple(self):
diff --git a/multiview_platform/tests/utils.py b/multiview_platform/tests/utils.py
index 5a373cae..1b39abf1 100644
--- a/multiview_platform/tests/utils.py
+++ b/multiview_platform/tests/utils.py
@@ -5,8 +5,8 @@ import h5py
 from ..mono_multi_view_classifiers.utils.dataset import Dataset
 
 
-tmp_path = "multiview_platform/tests/tmp_tests/"
-test_dataset = Dataset(hdf5_file=h5py.File("multiview_platform/tests/test_database.hdf5", "r"))
+tmp_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "tmp_tests/")
+test_dataset = Dataset(hdf5_file=h5py.File(os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_database.hdf5"), "r"))
 
 def rm_tmp():
     try:
diff --git a/setup.py b/setup.py
index fcb010b8..3bc02d0f 100644
--- a/setup.py
+++ b/setup.py
@@ -52,7 +52,7 @@ def setup_package():
     # dependency_links=['https://github.com/aldro61/pyscm.git#egg=pyscm'],
     # Une url qui pointe vers la page officielle de votre lib
     url='http://github.com/babau1/multiview-machine-learning-omis/',
-    install_requires=['numpy>=1.8', 'scipy>=0.16','scikit-learn==0.19',
+    install_requires=['numpy>=1.16', 'scipy>=0.16','scikit-learn==0.19',
                       'matplotlib', 'h5py', 'joblib',
                       'pandas', 'm2r', 'pyyaml', 'pyscm @ git+https://github.com/aldro61/pyscm',
                       'cvxopt'],
-- 
GitLab