Skip to content

Commit af365e4

Browse files
paskinocasperdcl
authored andcommitted
fix PD unittest
1 parent d91a43e commit af365e4

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

test/test_run_test.py

+25-21
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@
99

1010
@unittest.skipUnless(gpu_modules_available, 'Skipping as GPU modules not available')
1111
class TestRegularisers(unittest.TestCase):
12+
def setUp(self):
13+
self.filename = os.path.join(os.path.dirname(__file__), "test_imageLena.bin")
14+
1215
def test_ROF_TV_CPU_vs_GPU(self):
1316
#print ("tomas debug test function")
14-
print(__name__)
1517
#filename = os.path.join("test","lena_gray_512.tif")
1618
#plt = TiffReader()
17-
filename = os.path.join("test","test_imageLena.bin")
19+
filename = os.path.join(os.path.dirname(__file__), "test_imageLena.bin")
1820
plt = BinReader()
1921
# read image
20-
Im = plt.imread(filename)
22+
Im = plt.imread(self.filename)
2123
Im = np.asarray(Im, dtype='float32')
2224

2325
Im = Im/255
@@ -83,10 +85,10 @@ def test_FGP_TV_CPU_vs_GPU(self):
8385
print(__name__)
8486
#filename = os.path.join("test","lena_gray_512.tif")
8587
#plt = TiffReader()
86-
filename = os.path.join("test","test_imageLena.bin")
88+
# self.filename = os.path.join("test","test_imageLena.bin")
8789
plt = BinReader()
8890
# read image
89-
Im = plt.imread(filename)
91+
Im = plt.imread(self.filename)
9092
Im = np.asarray(Im, dtype='float32')
9193

9294
Im = Im/255
@@ -161,10 +163,10 @@ def test_PD_TV_CPU_vs_GPU(self):
161163
print(__name__)
162164
#filename = os.path.join("test","lena_gray_512.tif")
163165
#plt = TiffReader()
164-
filename = os.path.join("test","test_imageLena.bin")
166+
# self.filename = os.path.join("test","test_imageLena.bin")
165167
plt = BinReader()
166168
# read image
167-
Im = plt.imread(filename)
169+
Im = plt.imread(self.filename)
168170
Im = np.asarray(Im, dtype='float32')
169171

170172
Im = Im/255
@@ -201,9 +203,10 @@ def test_PD_TV_CPU_vs_GPU(self):
201203
pars['regularisation_parameter'],
202204
pars['number_of_iterations'],
203205
pars['tolerance_constant'],
206+
pars['lipschitz_const'],
204207
pars['methodTV'],
205208
pars['nonneg'],
206-
pars['lipschitz_const'], device='cpu')
209+
device='cpu')
207210

208211
rms = rmse(Im, pd_cpu)
209212
pars['rmse'] = rms
@@ -218,9 +221,10 @@ def test_PD_TV_CPU_vs_GPU(self):
218221
pars['regularisation_parameter'],
219222
pars['number_of_iterations'],
220223
pars['tolerance_constant'],
224+
pars['lipschitz_const'],
221225
pars['methodTV'],
222226
pars['nonneg'],
223-
pars['lipschitz_const'], device='gpu')
227+
device='gpu')
224228

225229
rms = rmse(Im, pd_gpu)
226230
pars['rmse'] = rms
@@ -242,9 +246,9 @@ def test_SB_TV_CPU_vs_GPU(self):
242246
#filename = os.path.join("test","lena_gray_512.tif")
243247
#plt = TiffReader()
244248
# read image
245-
filename = os.path.join("test","test_imageLena.bin")
249+
# filename = os.path.join("test","test_imageLena.bin")
246250
plt = BinReader()
247-
Im = plt.imread(filename)
251+
Im = plt.imread(self.filename)
248252
Im = np.asarray(Im, dtype='float32')
249253

250254
Im = Im/255
@@ -314,10 +318,10 @@ def test_TGV_CPU_vs_GPU(self):
314318
print(__name__)
315319
#filename = os.path.join("test","lena_gray_512.tif")
316320
#plt = TiffReader()
317-
filename = os.path.join("test","test_imageLena.bin")
321+
# filename = os.path.join("test","test_imageLena.bin")
318322
plt = BinReader()
319323
# read image
320-
Im = plt.imread(filename)
324+
Im = plt.imread(self.filename)
321325
Im = np.asarray(Im, dtype='float32')
322326

323327
Im = Im/255
@@ -395,9 +399,9 @@ def test_LLT_ROF_CPU_vs_GPU(self):
395399
#filename = os.path.join("test","lena_gray_512.tif")
396400
#plt = TiffReader()
397401
# read image
398-
filename = os.path.join("test","test_imageLena.bin")
402+
# filename = os.path.join("test","test_imageLena.bin")
399403
plt = BinReader()
400-
Im = plt.imread(filename)
404+
Im = plt.imread(self.filename)
401405
Im = np.asarray(Im, dtype='float32')
402406

403407
Im = Im/255
@@ -471,9 +475,9 @@ def test_NDF_CPU_vs_GPU(self):
471475
#filename = os.path.join("test","lena_gray_512.tif")
472476
#plt = TiffReader()
473477
# read image
474-
filename = os.path.join("test","test_imageLena.bin")
478+
# filename = os.path.join("test","test_imageLena.bin")
475479
plt = BinReader()
476-
Im = plt.imread(filename)
480+
Im = plt.imread(self.filename)
477481
Im = np.asarray(Im, dtype='float32')
478482

479483
Im = Im/255
@@ -549,9 +553,9 @@ def test_Diff4th_CPU_vs_GPU(self):
549553
#filename = os.path.join("test","lena_gray_512.tif")
550554
#plt = TiffReader()
551555
# read image
552-
filename = os.path.join("test","test_imageLena.bin")
556+
# filename = os.path.join(os.path.dirname(__file__), "test_imageLena.bin")
553557
plt = BinReader()
554-
Im = plt.imread(filename)
558+
Im = plt.imread(self.filename)
555559
Im = np.asarray(Im, dtype='float32')
556560

557561
Im = Im/255
@@ -622,9 +626,9 @@ def test_FDGdTV_CPU_vs_GPU(self):
622626
#filename = os.path.join("test","lena_gray_512.tif")
623627
#plt = TiffReader()
624628
# read image
625-
filename = os.path.join("test","test_imageLena.bin")
629+
# filename = os.path.join("test","test_imageLena.bin")
626630
plt = BinReader()
627-
Im = plt.imread(filename)
631+
Im = plt.imread(self.filename)
628632
Im = np.asarray(Im, dtype='float32')
629633

630634
Im = Im/255

0 commit comments

Comments
 (0)