Skip to content
Snippets Groups Projects
Commit 4bef8c46 authored by Baptiste Bauvin's avatar Baptiste Bauvin
Browse files

Windows compatible paths

parent 7cd0028e
No related branches found
No related tags found
No related merge requests found
......@@ -21,11 +21,13 @@
import os
import sys
repo_path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath('../../summit'))
sys.path.insert(0, os.path.abspath('../..'))
file_loc = os.path.split(__file__)[0]
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(file_loc), '.')))
sys.path.insert(0, os.path.join(repo_path, "summit'"))
sys.path.insert(0, repo_path)
# sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(file_loc), '.')))
# import summit
# -- General configuration ------------------------------------------------
......@@ -121,7 +123,7 @@ html_theme = 'classic'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static/"]
html_static_path = ["_static"]
# -- Options for HTMLHelp output ------------------------------------------
......
......@@ -2,8 +2,10 @@ import os
import yaml
package_path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
print(package_path)
def get_the_args(path_to_config_file="../config_files/config.yml"):
def get_the_args(path_to_config_file=os.path.join(os.path.dirname(package_path), "config_files", "config.yml")):
"""
The function for extracting the args for a '.yml' file.
......@@ -27,7 +29,7 @@ def pass_default_config(log=True,
label="_",
file_type=".hdf5",
views=None,
pathf="../data/",
pathf=os.path.join(os.path.dirname(package_path), "data", ""),
nice=0,
random_state=42,
nb_cores=1,
......@@ -35,7 +37,7 @@ def pass_default_config(log=True,
debug=False,
add_noise=False,
noise_std=0.0,
res_dir="../results/",
res_dir=os.path.join(os.path.dirname(package_path),"results", ""),
track_tracebacks=True,
split=0.49,
nb_folds=5,
......
......@@ -85,6 +85,7 @@ class Test_Functs(unittest.TestCase):
@classmethod
def setUpClass(cls):
rm_tmp()
os.mkdir(tmp_path)
@classmethod
......
......@@ -31,7 +31,7 @@ class Test_initConstants(unittest.TestCase):
np.array([1, 3, 5, 7, 9])]
cls.labels_names = ["test_true", "test_false"]
cls.name = "test"
cls.directory = os.path.join(tmp_path, "test_dir/")
cls.directory = os.path.join(tmp_path, "test_dir", "")
def test_simple(cls):
kwargs, \
......@@ -60,12 +60,7 @@ class Test_initConstants(unittest.TestCase):
@classmethod
def tearDownClass(cls):
os.remove(tmp_path + "test.hdf5")
os.rmdir(
tmp_path + "test_dir/test_clf/test_dataset")
os.rmdir(tmp_path + "test_dir/test_clf")
os.rmdir(tmp_path + "test_dir")
os.rmdir(tmp_path)
rm_tmp()
class Test_initTrainTest(unittest.TestCase):
......
......@@ -27,6 +27,7 @@ class TestBaseMultiviewClassifier(unittest.TestCase):
@classmethod
def setUpClass(cls):
rm_tmp()
os.mkdir(tmp_path)
@classmethod
......@@ -62,6 +63,7 @@ class TestFunctions(unittest.TestCase):
@classmethod
def setUpClass(cls):
rm_tmp()
os.mkdir(tmp_path)
cls.rs = np.random.RandomState(42)
......
......@@ -113,6 +113,7 @@ class Test_analyze_iterations(unittest.TestCase):
@classmethod
def setUpClass(cls):
rm_tmp()
os.mkdir(tmp_path)
cls.results = [[0, [FakeClassifierResult(), FakeClassifierResult(i=2)], []], [
1, [FakeClassifierResult(), FakeClassifierResult(i=2)], []]]
......
......@@ -31,6 +31,7 @@ class Test_funcs(unittest.TestCase):
@classmethod
def setUpClass(cls):
rm_tmp()
os.mkdir(tmp_path)
cls.res_file = open(os.path.join(tmp_path, "tmp.txt"), "w")
......
......@@ -98,7 +98,7 @@ class Test_get_classic_db_csv(unittest.TestCase):
self.datas = []
for i in range(4):
data = self.random_state.randint(0, 100, (10, 20))
np.savetxt(self.pathF + "Views/test_view_" + str(i) + ".csv",
np.savetxt(os.path.join(self.pathF +"Views","test_view_" + str(i) + ".csv"),
data, delimiter=",")
self.datas.append(data)
......@@ -118,18 +118,7 @@ class Test_get_classic_db_csv(unittest.TestCase):
@classmethod
def tearDown(self):
for i in range(4):
os.remove(
tmp_path + "Views/test_view_" + str(
i) + ".csv")
os.rmdir(tmp_path + "Views")
os.remove(
tmp_path + "test_dataset-labels-names.csv")
os.remove(tmp_path + "test_dataset-labels.csv")
os.remove(tmp_path + "test_dataset.hdf5")
os.remove(
tmp_path + "test_dataset_temp_filter.hdf5")
os.rmdir(tmp_path)
rm_tmp()
class Test_get_plausible_db_hdf5(unittest.TestCase):
......
......@@ -13,9 +13,7 @@ class Test_get_the_args(unittest.TestCase):
def setUpClass(cls):
rm_tmp()
cls.path_to_config_file = tmp_path + "config_temp.yml"
path_file = os.path.dirname(os.path.abspath(__file__))
make_tmp_dir = os.path.join(path_file, "../tmp_tests")
os.mkdir(make_tmp_dir)
os.mkdir(tmp_path)
data = {"log": 10, "name": [12.5, 1e-06], "type": True}
with open(cls.path_to_config_file, "w") as config_file:
yaml.dump(data, config_file)
......
......@@ -21,6 +21,7 @@ class Test_init_log_file(unittest.TestCase):
@classmethod
def setUpClass(cls):
rm_tmp()
os.mkdir(tmp_path)
@classmethod
......@@ -135,6 +136,7 @@ class Test_find_dataset_names(unittest.TestCase):
@classmethod
def setUpClass(cls):
rm_tmp()
os.mkdir(tmp_path)
with open(os.path.join(tmp_path, "test.txt"), "w") as file_stream:
file_stream.write("test")
......@@ -154,7 +156,7 @@ class Test_find_dataset_names(unittest.TestCase):
self.assertEqual(path, tmp_path)
self.assertIn("test1", names)
path, names = execution.find_dataset_names(
"examples/data", ".hdf5", ["all"])
os.path.join("examples","data"), ".hdf5", ["all"])
self.assertIn("doc_summit", names)
self.assertRaises(ValueError, execution.find_dataset_names, tmp_path + "test", ".txt",
["test"])
......
......@@ -8,7 +8,7 @@ from ..multiview_platform.utils.dataset import HDF5Dataset
tmp_path = os.path.join(
os.path.dirname(
os.path.abspath(__file__)),
"tmp_tests/")
"tmp_tests", "")
# TODO Convert to ram dataset
test_dataset = HDF5Dataset(
hdf5_file=h5py.File(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment