Commits

Kazuhiko Shimada authored 9a6fd3b295a
CAS-13520: modified test conditions
No tags

casatasks/tests/tasks/test_imbaseline.py

Modified
1386 1386 bloutput = linefile + ".bloutput"
1387 1387 test_image = "input_image.im"
1388 1388 major = "20arcsec"
1389 1389 minor = "10arcsec"
1390 1390 pa = "0deg"
1391 1391 order = 1
1392 1392 kwidth = 5
1393 1393
1394 1394 test_no = 1
1395 1395
1396 + def __init__(self, *args, **kwargs):
1397 + super(TestImbaselineOutputs, self).__init__(*args, **kwargs)
1398 +
1399 + self.mask = np.full(self.TEST_IMAGE_SHAPE, True)
1400 + for i in [0, 1, 8, 9]:
1401 + self.mask[:, :, :, i] = False
1402 + self.expected_output_chunk = self.expected_output_chunk * self.mask
1403 + self.expected_cont_chunk = self.expected_cont_chunk * self.mask
1404 +
1396 1405 def setUp(self):
1397 1406 self._copy_test_files(self.input_image)
1398 1407 self._copy_test_files(self.blparam)
1399 1408
1400 1409 @staticmethod
1401 1410 def generate_tests():
1402 1411 blfunc = ("poly", "chebyshev", "cspline", "sinusoid")
1403 1412 dirkernel = ("none", "gaussian", "boxcar")
1404 1413 spkernel = ("none", "gaussian", "boxcar")
1405 1414
1418 1427 for _spkernel in spkernel
1419 1428 ]
1420 1429
1421 1430 @staticmethod
1422 1431 def _generate_a_test(blfunc, dirkernel, spkernel, test_name):
1423 1432 def test_method(self):
1424 1433 """TestImbaselineOutputs test."""
1425 1434 self._create_image(
1426 1435 self.test_image, self.TEST_IMAGE_VALUE, self.TEST_IMAGE_SHAPE
1427 1436 )
1437 + kwidth = self.kwidth
1438 + if spkernel == 'gaussian':
1439 + kwidth = 2
1428 1440 params = dict(
1429 1441 imagename=self.test_image,
1430 1442 linefile=self.linefile,
1431 1443 output_cont=self.output_cont,
1432 1444 bloutput=self.bloutput,
1433 1445 blfunc=blfunc,
1434 1446 dirkernel=dirkernel,
1435 1447 spkernel=spkernel,
1436 1448 major=self.major,
1437 1449 minor=self.minor,
1438 1450 pa=self.pa,
1439 1451 order=self.order,
1440 - kwidth=self.kwidth,
1452 + kwidth=kwidth,
1441 1453 )
1442 1454 casalog.post(
1443 1455 f"{test_name} [maskmode=auto, blfunc={blfunc}, "
1444 1456 f"dirkernel={dirkernel}, spkernel={spkernel}]",
1445 1457 "INFO",
1446 1458 )
1447 1459 imbaseline(**params)
1448 1460 if os.path.exists(self.linefile):
1449 1461 with tool_manager(self.linefile, image) as ia:
1450 - chunk = ia.getchunk()
1462 + chunk = ia.getchunk() * self.mask
1451 1463 self._summary(False, test_name, chunk)
1452 1464 self.assertTrue(
1453 1465 np.allclose(chunk, self.expected_output_chunk, atol=2.0)
1454 1466 )
1455 1467 if os.path.exists(self.test_image + ".cont"):
1456 1468 with tool_manager(self.test_image + ".cont", image) as ia:
1457 - chunk = ia.getchunk()
1469 + chunk = ia.getchunk() * self.mask
1458 1470 self._summary(True, test_name, chunk)
1459 1471 self.assertTrue(
1460 1472 np.allclose(chunk, self.expected_cont_chunk, atol=2.0)
1461 1473 )
1462 1474
1463 1475 test_method.__doc__ += (
1464 1476 f" No.{TestImbaselineOutputs.test_no:03} [blfunc={blfunc}, "
1465 1477 f"dirkernel={dirkernel}, spkernel={spkernel}]"
1466 1478 )
1467 1479 TestImbaselineOutputs.test_no += 1

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut