Skip to content

Commit c5fa318

Browse files
authored
Add tests for DMD (Reference-LAPACK PR 736)
1 parent fa03e54 commit c5fa318

File tree

1 file changed

+43
-42
lines changed

1 file changed

+43
-42
lines changed

lapack-netlib/lapack_testing.py

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
1-
#! /usr/bin/env python
2-
# -*- coding: utf-8 -*-
1+
#!/usr/bin/env python3
32

43

54
###############################################################################
65
# lapack_testing.py
76
###############################################################################
87

9-
from __future__ import print_function
108
from subprocess import Popen, STDOUT, PIPE
119
import os, sys, math
1210
import getopt
1311
# Arguments
1412
try:
1513
opts, args = getopt.getopt(sys.argv[1:], "hd:b:srep:t:n",
16-
["help", "dir", "bin", "short", "run", "error","prec=","test=","number"])
14+
["help", "dir=", "bin=", "short", "run", "error","prec=","test=","number"])
1715

1816
except getopt.error as msg:
1917
print(msg)
2018
print("for help use --help")
2119
sys.exit(2)
2220

23-
short_summary=0
24-
with_file=1
25-
just_errors = 0
21+
short_summary = False
22+
with_file = True
23+
just_errors = False
2624
prec='x'
2725
test='all'
28-
only_numbers=0
26+
only_numbers = False
2927
test_dir='TESTING'
3028
bin_dir='bin/Release'
3129

@@ -34,10 +32,9 @@
3432
print(sys.argv[0]+" [-h|--help] [-d dir |--dir dir] [-s |--short] [-r |--run] [-e |--error] [-p p |--prec p] [-t test |--test test] [-n | --number]")
3533
print(" - h is to print this message")
3634
print(" - r is to use to run the LAPACK tests then analyse the output (.out files). By default, the script will not run all the LAPACK tests")
37-
print(" - d [dir] is to indicate where is the LAPACK testing directory (.out files). By default, the script will use .")
38-
print(" - b [bin] is to indicate where is the LAPACK binary files are located. By default, the script will use .")
35+
print(" - d [dir] indicates the location of the LAPACK testing directory (.out files). By default, the script will use {:s}.".format(test_dir))
36+
print(" - b [bin] indicates the location of the LAPACK binary files. By default, the script will use {:s}.".format(bin_dir))
3937
print(" LEVEL OF OUTPUT")
40-
print(" - x is to print a detailed summary")
4138
print(" - e is to print only the error summary")
4239
print(" - s is to print a short summary")
4340
print(" - n is to print the numbers of failing tests (turn on summary mode)")
@@ -63,15 +60,14 @@
6360
print(" Will return the numbers of failed tests in REAL precision by running the LAPACK Tests then analyzing the output")
6461
print(" ./lapack_testing.py -n -p s -t eig ")
6562
print(" Will return the numbers of failed tests in REAL precision by analyzing only the LAPACK output of EIGEN testings")
66-
print("Written by Julie Langou (June 2011) ")
6763
sys.exit(0)
6864
else:
6965
if o in ("-s", "--short"):
70-
short_summary = 1
66+
short_summary = True
7167
if o in ("-r", "--run"):
72-
with_file = 0
68+
with_file = False
7369
if o in ("-e", "--error"):
74-
just_errors = 1
70+
just_errors = True
7571
if o in ( '-p', '--prec' ):
7672
prec = a
7773
if o in ( '-b', '--bin' ):
@@ -81,12 +77,12 @@
8177
if o in ( '-t', '--test' ):
8278
test = a
8379
if o in ( '-n', '--number' ):
84-
only_numbers = 1
85-
short_summary = 1
80+
only_numbers = True
81+
short_summary = True
8682

8783
# process options
8884

89-
abs_bin_dir=os.path.normpath(os.path.join(os.getcwd(),bin_dir))
85+
abs_bin_dir=os.path.abspath(bin_dir)
9086

9187
os.chdir(test_dir)
9288

@@ -108,7 +104,7 @@ def run_summary_test( f, cmdline, short_summary):
108104
nb_test_illegal=0
109105
nb_test_info=0
110106

111-
if (with_file):
107+
if with_file:
112108
if not os.path.exists(cmdline):
113109
error_message=cmdline+" file not found"
114110
r=1
@@ -145,16 +141,16 @@ def run_summary_test( f, cmdline, short_summary):
145141
whereisrun=words_in_line.index("run)")
146142
nb_test_run+=int(words_in_line[whereisrun-2])
147143
if (line.find("out of")!=-1):
148-
if (short_summary==0): print(line, end=' ')
144+
if not short_summary: print(line, end=' ')
149145
whereisout= words_in_line.index("out")
150146
nb_test_fail+=int(words_in_line[whereisout-1])
151147
if ((line.find("illegal")!=-1) or (line.find("Illegal")!=-1)):
152-
if (short_summary==0):print(line, end=' ')
148+
if not short_summary: print(line, end=' ')
153149
nb_test_illegal+=1
154150
if (line.find(" INFO")!=-1):
155-
if (short_summary==0):print(line, end=' ')
151+
if not short_summary: print(line, end=' ')
156152
nb_test_info+=1
157-
if (with_file==1):
153+
if with_file:
158154
pipe.close()
159155

160156
f.flush();
@@ -169,7 +165,7 @@ def run_summary_test( f, cmdline, short_summary):
169165
except IOError:
170166
f = sys.stdout
171167

172-
if (short_summary==0):
168+
if not short_summary:
173169
print(" ")
174170
print("---------------- Testing LAPACK Routines ----------------")
175171
print(" ")
@@ -203,6 +199,8 @@ def run_summary_test( f, cmdline, short_summary):
203199
range_prec=[1,3]
204200
elif test=='rfp':
205201
range_test=[18]
202+
elif test=='dmd':
203+
range_test=[20]
206204
elif test=='eig':
207205
range_test=list(range(16))
208206
else:
@@ -219,7 +217,7 @@ def run_summary_test( f, cmdline, short_summary):
219217
letter = dtypes[0][dtype]
220218
name = dtypes[1][dtype]
221219

222-
if (short_summary==0):
220+
if not short_summary:
223221
print(" ")
224222
print("------------------------- %s ------------------------" % name)
225223
print(" ")
@@ -231,19 +229,19 @@ def run_summary_test( f, cmdline, short_summary):
231229
letter+"gd",letter+"sb",letter+"sg",
232230
letter+"bb","glm","gqr",
233231
"gsv","csd","lse",
234-
letter+"test", letter+dtypes[0][dtype-1]+"test",letter+"test_rfp"),
232+
letter+"test", letter+dtypes[0][dtype-1]+"test",letter+"test_rfp",letter+"dmd"),
235233
("Nonsymmetric-Eigenvalue-Problem", "Symmetric-Eigenvalue-Problem", "Symmetric-Eigenvalue-Problem-2-stage", "Singular-Value-Decomposition",
236234
"Eigen-Condition","Nonsymmetric-Eigenvalue","Nonsymmetric-Generalized-Eigenvalue-Problem",
237235
"Nonsymmetric-Generalized-Eigenvalue-Problem-driver", "Symmetric-Eigenvalue-Problem", "Symmetric-Eigenvalue-Generalized-Problem",
238236
"Banded-Singular-Value-Decomposition-routines", "Generalized-Linear-Regression-Model-routines", "Generalized-QR-and-RQ-factorization-routines",
239237
"Generalized-Singular-Value-Decomposition-routines", "CS-Decomposition-routines", "Constrained-Linear-Least-Squares-routines",
240-
"Linear-Equation-routines", "Mixed-Precision-linear-equation-routines","RFP-linear-equation-routines"),
238+
"Linear-Equation-routines", "Mixed-Precision-linear-equation-routines","RFP-linear-equation-routines","Dynamic-Mode-Decomposition"),
241239
(letter+"nep", letter+"sep", letter+"se2", letter+"svd",
242240
letter+"ec",letter+"ed",letter+"gg",
243241
letter+"gd",letter+"sb",letter+"sg",
244242
letter+"bb",letter+"glm",letter+"gqr",
245243
letter+"gsv",letter+"csd",letter+"lse",
246-
letter+"test", letter+dtypes[0][dtype-1]+"test",letter+"test_rfp"),
244+
letter+"test", letter+dtypes[0][dtype-1]+"test",letter+"test_rfp",letter+"dmd"),
247245
)
248246

249247

@@ -252,22 +250,25 @@ def run_summary_test( f, cmdline, short_summary):
252250
# NEED TO SKIP SOME PRECISION (namely s and c) FOR PROTO MIXED PRECISION TESTING
253251
if dtest==17 and (letter=="s" or letter=="c"):
254252
continue
255-
if (with_file==1):
253+
if with_file:
256254
cmdbase=dtests[2][dtest]+".out"
257255
else:
258256
if dtest==16:
259257
# LIN TESTS
260-
cmdbase="LIN/xlintst"+letter+" < "+dtests[0][dtest]+".in > "+dtests[2][dtest]+".out"
258+
cmdbase="xlintst"+letter+" < "+dtests[0][dtest]+".in > "+dtests[2][dtest]+".out"
261259
elif dtest==17:
262260
# PROTO LIN TESTS
263-
cmdbase="LIN/xlintst"+letter+dtypes[0][dtype-1]+" < "+dtests[0][dtest]+".in > "+dtests[2][dtest]+".out"
261+
cmdbase="xlintst"+letter+dtypes[0][dtype-1]+" < "+dtests[0][dtest]+".in > "+dtests[2][dtest]+".out"
264262
elif dtest==18:
265263
# PROTO LIN TESTS
266-
cmdbase="LIN/xlintstrf"+letter+" < "+dtests[0][dtest]+".in > "+dtests[2][dtest]+".out"
264+
cmdbase="xlintstrf"+letter+" < "+dtests[0][dtest]+".in > "+dtests[2][dtest]+".out"
265+
elif dtest==20:
266+
# DMD EIG TESTS
267+
cmdbase="xdmdeigtst"+letter+" < "+dtests[0][dtest]+".in > "+dtests[2][dtest]+".out"
267268
else:
268269
# EIG TESTS
269-
cmdbase="EIG/xeigtst"+letter+" < "+dtests[0][dtest]+".in > "+dtests[2][dtest]+".out"
270-
if (not just_errors and not short_summary):
270+
cmdbase="xeigtst"+letter+" < "+dtests[0][dtest]+".in > "+dtests[2][dtest]+".out"
271+
if not just_errors and not short_summary:
271272
print("Testing "+name+" "+dtests[1][dtest]+"-"+cmdbase, end=' ')
272273
# Run the process: either to read the file or run the LAPACK testing
273274
nb_test = run_summary_test(f, cmdbase, short_summary)
@@ -277,19 +278,19 @@ def run_summary_test( f, cmdline, short_summary):
277278
list_results[3][dtype]+=nb_test[3]
278279
got_error=nb_test[1]+nb_test[2]+nb_test[3]
279280

280-
if (not short_summary):
281-
if (nb_test[0]>0 and just_errors==0):
281+
if not short_summary:
282+
if nb_test[0] > 0 and not just_errors:
282283
print("passed: "+str(nb_test[0]))
283-
if (nb_test[1]>0):
284+
if nb_test[1] > 0:
284285
print("failing to pass the threshold: "+str(nb_test[1]))
285-
if (nb_test[2]>0):
286+
if nb_test[2] > 0:
286287
print("Illegal Error: "+str(nb_test[2]))
287-
if (nb_test[3]>0):
288+
if nb_test[3] > 0:
288289
print("Info Error: "+str(nb_test[3]))
289-
if (got_error>0 and just_errors==1):
290+
if got_error > 0 and just_errors:
290291
print("ERROR IS LOCATED IN "+name+" "+dtests[1][dtest]+" [ "+cmdbase+" ]")
291292
print("")
292-
if (just_errors==0):
293+
if not just_errors:
293294
print("")
294295
# elif (got_error>0):
295296
# print dtests[2][dtest]+".out \t"+str(nb_test[1])+"\t"+str(nb_test[2])+"\t"+str(nb_test[3])
@@ -307,7 +308,7 @@ def run_summary_test( f, cmdline, short_summary):
307308
list_results[2][4]+=list_results[2][dtype]
308309
list_results[3][4]+=list_results[3][dtype]
309310

310-
if only_numbers==1:
311+
if only_numbers:
311312
print(str(list_results[1][4])+"\n"+str(list_results[2][4]+list_results[3][4]))
312313
else:
313314
print(summary)

0 commit comments

Comments
 (0)