Source
xxxxxxxxxx
ok = abs(val1['quantity']['*3']['value']-val2['quantity']['*1']['value'])<1e-6 and val1['quantity']['*3']['unit']==val2['quantity']['*1']['unit']
##############################################################################
# #
# Test Name: #
# coordsystest_regression.py #
# Rationale for Inclusion: #
# This is a Python translation of the Glish assay test coordsystest.g #
# It tests many coordsys tool methods #
# Features Tested: #
# coordsys, type, done, id, ncoordinates #
# coordinatetype, axiscoordinatetypes, summary #
# is_coordsys, coordsystools #
# referencecode, setreferencecode #
# restfrequency, setrestfrequency #
# projection, setprojection #
# torecord, fromrecord, copy #
# setepoch, epoch, setobserver, observer #
# settelescope, telescope, setparentname, parentname #
# setnames, names, setunits, units #
# setreferencepixel, referencepixel #
# setreferencevalue, referencevalue #
# setincrement, increment #
# setlineartransform, lineartransform #
# setstokes, stokes #
# findcoordinate, findaxis #
# toworld, toworldmany, topixel, topixelmany #
# naxes, axesmap #
# reorder #
# frequencytovelocity, velocitytofrequency #
# setreferencelocation #
# toabs, torel, toabsmany, torelmany #
# convert, convertmany #
# setspectral #
# settabular #
# addcoordinate #
# toworld, topixel with reference conversion #
# setdirection #
# replace #
# Success/failure criteria: #
# Internally tests each method for pass/fail. Throws an uncaught #
# exception ending test when an unexpected failure occurs. #
# All tests pass if script runs to completion. #
# #
##############################################################################
# #
# Converted by RRusk 2007-11-08 from coordsystest.py #
# #
##############################################################################
import time
import re
#
# coordsystest.py: test casapy coordsys tool
#
#
# Utils
#
def note(message, priority="INFO", origin="coordsystest", ntime=None, postcli='F'):
#if not ntime: #if (ntime==None):
# ntime=time.asctime()
#print ntime, priority, origin, message
if postcli: print message
casalog.postLocally(message, priority, origin)
###
def info(message):
#note(message,origin='coordsystest')
print message
casalog.postLocally(message, priority="INFO", origin="coordsystest")
def fail(message=""):
casalog.postLocally(message, priority="SEVERE", origin='coordsystest')
raise RuntimeError, message
###
def stop(message=""):
note(message ,priority='SEVERE', origin='coordsystest')
raise RuntimeError, message
###
def cleanup(dir):
if (os.path.isdir(dir)):
info("Cleaning up directory "+dir)
def errFunc(raiser, problemPath, excInfo):
#print raiser.__name__,'failed on',problemPath
note(raiser.__name__+'failed on'+problemPath,"SEVERE")
raise RuntimeError, "Cleanup of " + dir + " fails!"
shutil.rmtree(dir,0,errFunc)
return True
def all(x,y,tolerance=0):
if len(x) != len(y):