def testTooFewColumnNames(self):
     """Test that too few names in config.colnames causes an error"""
     config = ReadTextCatalogTask.ConfigClass()
     for badColNames in (
         ["name", "ra", "dec", "counts", "flux"],
         ["name"],
     ):
         config.colnames = badColNames
         config.header_lines = 1
         task = ReadTextCatalogTask(config=config)
         with self.assertRaises(ValueError):
             task.run(TextPath)
 def testTooFewColumnNames(self):
     """Test that too few names in config.colnames causes an error"""
     config = ReadTextCatalogTask.ConfigClass()
     for badColNames in (
         ["name", "ra", "dec", "counts", "flux"],
         ["name"],
     ):
         config.colnames = badColNames
         config.header_lines = 1
         task = ReadTextCatalogTask(config=config)
         with self.assertRaises(ValueError):
             task.run(TextPath)
 def testDefaultNames(self):
     """Test reading without renaming
     """
     task = ReadTextCatalogTask()
     arr = task.run(TextPath)
     self.assertTrue(np.array_equal(arr, self.arr))
     self.assertEqual(len(arr), 2)
 def testDefaultNames(self):
     """Test reading without renaming
     """
     task = ReadTextCatalogTask()
     arr = task.run(TextPath)
     self.assertTrue(np.array_equal(arr, self.arr))
     self.assertEqual(len(arr), 2)
 def testGivenNames(self):
     """Test reading with column names in the config
     """
     colnames = ("id", "ra_deg", "dec_deg", "total_counts", "total_flux", "is_resolved")
     config = ReadTextCatalogTask.ConfigClass()
     config.colnames = colnames
     config.header_lines = 1
     task = ReadTextCatalogTask(config=config)
     arr = task.run(TextPath)
     self.assertEqual(arr.dtype.names, colnames)
     self.assertEqual(len(arr), 2)
     for inname, outname in zip(self.arr.dtype.names, colnames):
         self.assertTrue(np.array_equal(self.arr[inname], arr[outname]))
 def testGivenNames(self):
     """Test reading with column names in the config
     """
     colnames = ("id", "ra_deg", "dec_deg", "total_counts", "total_flux",
                 "is_resolved")
     config = ReadTextCatalogTask.ConfigClass()
     config.colnames = colnames
     config.header_lines = 1
     task = ReadTextCatalogTask(config=config)
     arr = task.run(TextPath)
     self.assertEqual(arr.dtype.names, colnames)
     self.assertEqual(len(arr), 2)
     for inname, outname in zip(self.arr.dtype.names, colnames):
         self.assertTrue(np.array_equal(self.arr[inname], arr[outname]))
 def testBadPath(self):
     """Test that an invalid path causes an error"""
     task = ReadTextCatalogTask()
     badPath = "does/not/exists.garbage"
     with self.assertRaises(IOError):
         task.run(badPath)
Esempio n. 8
0
from lsst.meas.algorithms.readTextCatalogTask import ReadTextCatalogTask
task = ReadTextCatalogTask()
catalogArray = task.run("exxtable.csv")



 def testBadPath(self):
     """Test that an invalid path causes an error"""
     task = ReadTextCatalogTask()
     badPath = "does/not/exists.garbage"
     with self.assertRaises(IOError):
         task.run(badPath)