Source
xxxxxxxxxx
self.res = testconcat(vis = ['shortpart1.ms', 'shortpart2.ms', 'shortpart3.ms', 'shortpart4.ms', 'shortpart5.ms'],
#########################################################################
# test_task_testconcat.py
#
# Copyright (C) 2018
# Associated Universities, Inc. Washington DC, USA
#
# This script is free software; you can redistribute it and/or modify it
# under the terms of the GNU Library General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This library is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
# License for more details.
#
# [Add the link to the JIRA ticket here once it exists]
#
# Based on the requirements listed in plone found here:
#
#
##########################################################################
import os
import sys
import shutil
import glob
import unittest
from casatools import ctsys
from casatools import table as tbtool
from casatools import ms as mstool
from casatasks import split, testconcat
tb = tbtool( )
ms = mstool( )
datapath = ctsys.resolve('unittest/testconcat/')
myname = 'test_testconcat'
# name of the resulting MS
msname = 'testconcatenated.ms'
def checktable(thename, theexpectation):
global msname, myname
tb.open(msname+"/"+thename)
for mycell in theexpectation:
print(myname, ": comparing ", mycell)
value = tb.getcell(mycell[0], mycell[1])
# see if value is array
try:
isarray = value.__len__
except:
# it's not an array
# zero tolerance?
if mycell[3] == 0:
in_agreement = (value == mycell[2])
else:
in_agreement = ( abs(value - mycell[2]) < mycell[3])
else:
# it's an array
# zero tolerance?
if mycell[3] == 0:
in_agreement = (value == mycell[2]).all()
else:
try:
in_agreement = (abs(value - mycell[2]) < mycell[3]).all()
except:
in_agreement = False
if not in_agreement:
print(myname, ": Error in MS subtable", thename, ":")
print(" column ", mycell[0], " row ", mycell[1], " contains ", value)
print(" expected value is ", mycell[2])
tb.close()
return False
tb.close()
print(myname, ": table ", thename, " as expected.")
return True
###########################
# beginning of actual test
class test_testconcat(unittest.TestCase):
def setUpClass(cls):
cls.myinputlist = []
cpath = os.path.abspath(os.curdir)
filespresent = sorted(glob.glob("*.ms"))
os.chdir(datapath)