Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# This file is part of daf_butler. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (http://www.lsst.org). 

6# See the COPYRIGHT file at the top-level directory of this distribution 

7# for details of code ownership. 

8# 

9# This program is free software: you can redistribute it and/or modify 

10# it under the terms of the GNU General Public License as published by 

11# the Free Software Foundation, either version 3 of the License, or 

12# (at your option) any later version. 

13# 

14# This program is distributed in the hope that it will be useful, 

15# but WITHOUT ANY WARRANTY; without even the implied warranty of 

16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

17# GNU General Public License for more details. 

18# 

19# You should have received a copy of the GNU General Public License 

20# along with this program. If not, see <http://www.gnu.org/licenses/>. 

21 

22"""Tests for AstropyTableFormatter. 

23""" 

24 

25import unittest 

26import tempfile 

27import os 

28import shutil 

29import numpy 

30 

31from astropy.table import Table 

32 

33from lsst.daf.butler import Butler, DatasetType 

34 

35TESTDIR = os.path.abspath(os.path.dirname(__file__)) 

36 

37 

38class AstropyTableFormatterTestCase(unittest.TestCase): 

39 """Test for AstropyTableFormatter. 

40 """ 

41 

42 def setUp(self): 

43 self.root = tempfile.mkdtemp(dir=TESTDIR) 

44 Butler.makeRepo(self.root) 

45 ints = [1, 2, 3] 

46 names = ['one', 'two', 'three'] 

47 transcendentals = [3.14, 2.718, 0.643] 

48 self.table = Table([ints, names, transcendentals], 

49 names=['ints', 'names', 'transcendentals']) 

50 

51 def tearDown(self): 

52 if os.path.exists(self.root): 

53 shutil.rmtree(self.root, ignore_errors=True) 

54 del self.table 

55 

56 def testAstropyTableFormatter(self): 

57 butler = Butler(self.root, run="testrun") 

58 datasetType = DatasetType("table", [], "AstropyTable", 

59 universe=butler.registry.dimensions) 

60 butler.registry.registerDatasetType(datasetType) 

61 ref = butler.put(self.table, datasetType) 

62 uri = butler.getURI(ref) 

63 self.assertEqual(uri.getExtension(), '.ecsv') 

64 table = butler.get('table') 

65 self.assertTrue(numpy.all(table == self.table)) 

66 

67 

68if __name__ == "__main__": 68 ↛ 69line 68 didn't jump to line 69, because the condition on line 68 was never true

69 unittest.main()