Skip to content

Commit 2dc2cff

Browse files
committed
erase temp files after testing
1 parent 0040807 commit 2dc2cff

4 files changed

Lines changed: 52 additions & 29 deletions

File tree

ABXpy/test/test_analyse.py

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
# -*- coding: utf-8 -*-
44

55
import os
6+
import shutil
67
import sys
8+
79
package_path = os.path.dirname(os.path.dirname(
810
os.path.dirname(os.path.realpath(__file__))))
911
if not(package_path in sys.path):
@@ -50,12 +52,13 @@ def test_analyze():
5052
analyze.analyze(taskfilename, scorefilename, analyzefilename)
5153
finally:
5254
try:
53-
os.remove(item_file)
54-
os.remove(feature_file)
55-
os.remove(taskfilename)
56-
os.remove(distance_file)
57-
os.remove(scorefilename)
58-
os.remove(analyzefilename)
55+
shutil.rmtree('test_items')
56+
# os.remove(item_file)
57+
# os.remove(feature_file)
58+
# os.remove(taskfilename)
59+
# os.remove(distance_file)
60+
# os.remove(scorefilename)
61+
# os.remove(analyzefilename)
5962
except:
6063
pass
6164

@@ -70,26 +73,28 @@ def test_threshold_analyze():
7073
scorefilename = 'test_items/data.score'
7174
taskfilename = 'test_items/data.abx'
7275
analyzefilename = 'test_items/data.csv'
73-
threshold=2
76+
threshold = 2
7477

7578
items.generate_db_and_feat(3, 3, 1, item_file, 2, 3, feature_file)
7679
task = ABXpy.task.Task(item_file, 'c0', 'c1', 'c2')
7780
task.generate_triplets(taskfilename, threshold=threshold)
78-
distances.compute_distances(feature_file, '/features/', taskfilename,
79-
distance_file, dtw_cosine_distance, n_cpu=1)
81+
distances.compute_distances(
82+
feature_file, '/features/', taskfilename,
83+
distance_file, dtw_cosine_distance, n_cpu=1)
8084
score.score(taskfilename, distance_file, scorefilename)
8185
analyze.analyze(taskfilename, scorefilename, analyzefilename)
8286
number_triplets = np.loadtxt(analyzefilename, dtype=int,
8387
delimiter='\t', skiprows=1, usecols=[-1])
8488
assert np.all(number_triplets == threshold)
8589
finally:
8690
try:
87-
os.remove(item_file)
88-
os.remove(feature_file)
89-
os.remove(taskfilename)
90-
os.remove(distance_file)
91-
os.remove(scorefilename)
92-
os.remove(analyzefilename)
91+
shutil.rmtree('test_items')
92+
# os.remove(item_file)
93+
# os.remove(feature_file)
94+
# os.remove(taskfilename)
95+
# os.remove(distance_file)
96+
# os.remove(scorefilename)
97+
# os.remove(analyzefilename)
9398
except:
9499
pass
95100

@@ -122,9 +127,10 @@ def test_frozen_analyze():
122127

123128
finally:
124129
try:
125-
os.remove(taskfilename)
126-
os.remove(distance_file)
127-
os.remove(scorefilename)
128-
os.remove(analyzefilename)
130+
shutil.rmtree('test_items')
131+
# os.remove(taskfilename)
132+
# os.remove(distance_file)
133+
# os.remove(scorefilename)
134+
# os.remove(analyzefilename)
129135
except:
130136
pass

ABXpy/test/test_dtw.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,3 @@ def test_normalized():
3434
dists_mid = np.concatenate([dists[:, :3], dists_mid, dists[:, 3:]], axis=1)
3535
res = dtw._dtw(5, 7, dists_mid, normalized=True)
3636
assert res == 1
37-

ABXpy/test/test_examples.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""This file contains test for the examples of the package"""
22
import os.path as path
3+
import shutil
34
import subprocess
45

56

@@ -13,7 +14,20 @@
1314

1415

1516
def test_complete_run_sh():
16-
subprocess.check_call(['bash', complete_run_sh])
17+
try:
18+
subprocess.check_call(['bash', complete_run_sh])
19+
finally:
20+
try:
21+
shutil.rmtree('./example_items')
22+
except:
23+
pass
24+
1725

1826
def test_complete_run_py():
19-
subprocess.check_call(['python', complete_run_py])
27+
try:
28+
subprocess.check_call(['python', complete_run_py])
29+
finally:
30+
try:
31+
shutil.rmtree('./example_items')
32+
except:
33+
pass

ABXpy/test/test_score.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
# -*- coding: utf-8 -*-
44

55
import os
6+
import shutil
67
import sys
8+
79
package_path = os.path.dirname(os.path.dirname(
810
os.path.dirname(os.path.realpath(__file__))))
911
if not(package_path in sys.path):
@@ -32,15 +34,17 @@ def test_score():
3234
items.generate_db_and_feat(3, 3, 1, item_file, 2, 3, feature_file)
3335
task = ABXpy.task.Task(item_file, 'c0', 'c1', 'c2')
3436
task.generate_triplets()
35-
distances.compute_distances(feature_file, '/features/', taskfilename,
36-
distance_file, dtw_cosine_distance, n_cpu=3)
37+
distances.compute_distances(
38+
feature_file, '/features/', taskfilename,
39+
distance_file, dtw_cosine_distance, n_cpu=3)
3740
score.score(taskfilename, distance_file, scorefilename)
3841
finally:
3942
try:
40-
os.remove(item_file)
41-
os.remove(feature_file)
42-
os.remove(taskfilename)
43-
os.remove(distance_file)
44-
os.remove(scorefilename)
43+
shutil.rmtree('test_items')
44+
# os.remove(item_file)
45+
# os.remove(feature_file)
46+
# os.remove(taskfilename)
47+
# os.remove(distance_file)
48+
# os.remove(scorefilename)
4549
except:
4650
pass

0 commit comments

Comments
 (0)