|
33 | 33 | # address = {Riverton, NJ, USA}, |
34 | 34 | #} |
35 | 35 |
|
| 36 | +# handle the new way of integer division |
| 37 | +from __future__ import division |
| 38 | + |
36 | 39 | import sys |
37 | 40 | try: |
38 | 41 | import numpy |
39 | 42 | import numpy.linalg |
40 | 43 | except: |
41 | | - print "numpy is not available with your installation and is not being run" |
| 44 | + print("numpy is not available with your installation and is not being run") |
42 | 45 | sys.exit(0) |
43 | 46 |
|
44 | 47 |
|
@@ -295,44 +298,44 @@ def SetupOutputCompare(device, region, model, variable, output): |
295 | 298 | for i in range(dim): |
296 | 299 | mname = "ElectricField_" + directions[i] |
297 | 300 | output[:,k] = numpy.array(get_element_model_values(device=device, region=region, name=mname)) |
298 | | - print "%d %s" % (k, mname) |
| 301 | + print("%d %s" % (k, mname)) |
299 | 302 | k += 1 |
300 | 303 | for j in range(nen): |
301 | 304 | for i in range(dim): |
302 | 305 | mname = "ElectricField_" + directions[i] |
303 | 306 | dname = mname + ":Potential@en%d" % j |
304 | 307 | output[:,k] = numpy.array(get_element_model_values(device=device, region=region, name=dname)) |
305 | | - print "%d %s" % (k, dname) |
| 308 | + print("%d %s" % (k, dname)) |
306 | 309 | k += 1 |
307 | 310 |
|
308 | 311 | def DoCompare(output, output_compare, number_test): |
309 | 312 | test2 = output[0:nee*number_test] - output_compare[0:nee*number_test] |
310 | | - print numpy.linalg.norm(test2, ord=numpy.inf ) |
| 313 | + print(numpy.linalg.norm(test2, ord=numpy.inf )) |
311 | 314 | for row in range(number_test): |
312 | 315 | for col in range(5): |
313 | 316 | sl1 = slice(nee*row,nee*(row+1)) |
314 | 317 | sl2 = slice(dim*col,dim*(col+1)) |
315 | 318 | norm = numpy.linalg.norm(output[(sl1, sl2)]-output_compare[(sl1,sl2)]) |
316 | 319 | if norm > 1e-4: |
317 | | - print "%d %d %g" % (row, col, norm) |
| 320 | + print("%d %d %g" % (row, col, norm)) |
318 | 321 |
|
319 | 322 | row = 0 |
320 | 323 | if True: |
321 | 324 | #for row in range(10): |
322 | 325 | col = 0 |
323 | 326 | sl1 = slice(nee*row,nee*(row+1)) |
324 | 327 | sl2 = slice(dim*col,dim*(col+1)) |
325 | | - print output[(sl1, sl2)] |
326 | | - print output_compare[(sl1,sl2)] |
327 | | - print output[(sl1, sl2)] - output_compare[(sl1,sl2)] |
| 328 | + print(output[(sl1, sl2)]) |
| 329 | + print(output_compare[(sl1,sl2)]) |
| 330 | + print(output[(sl1, sl2)] - output_compare[(sl1,sl2)]) |
328 | 331 |
|
329 | 332 | def RunTest(device, region, number_test): |
330 | 333 | scalar_efield = GetScalarField(device, region, "scalar_efield", "ElectricField") |
331 | 334 | scalar_efield_derivatives = GetScalarFieldDerivatives(device, region, "scalar_efield_n", "ElectricField", "Potential") |
332 | 335 | node_indexes = GetNodeIndexes(device, region) |
333 | 336 | unit_vectors = GetUnitVectors(device, region) |
334 | 337 |
|
335 | | - number_elements = len(scalar_efield)/nee |
| 338 | + number_elements = len(scalar_efield)//nee |
336 | 339 |
|
337 | 340 | if number_test < 1: |
338 | 341 | number_test = number_elements |
|
0 commit comments