def testTableNamespaceHasColumnsInSubtables(self):
     """
 Tests that a name in a subtable is in the namespace
 and can be evaluated.
 
 DUMMY_TABLE
   row
   DUMMY1
   A
   B
   C
   VALID_FORMULA
   Subtable
     row
     SubtableColumn1
     SubtableColumn2
 """
     if IGNORE_TEST:
         return
     column_name1 = "SubtableColumn1"
     column_name2 = "SubtableColumn2"
     colnms = [column_name1, column_name2]
     subtable = createTable("Subtable", column_name=colnms)
     self.table.addChild(subtable)
     column2 = subtable.columnFromName(column_name2)
     formula = "SubtableColumn1*10"
     column2.setFormula(formula)
     errors = self.evaluator.evaluate(user_directory=TEST_DIR)
     self.assertIsNone(errors)
Пример #2
0
 def setUp(self):
   self.api = API()
   self.api._table = ht.createTable("test", column_name=COLUMN1)
   self.column1 = self.api._table.columnFromName(COLUMN1,
       is_relative=False)
   self.column1.addCells(COLUMN1_VALUES, replace=True)
   self.api.setColumnVariables(nodenms=[COLUMN1])
   ht.setupTableInitialization(self)
Пример #3
0
 def testAddColumn(self):
   if IGNORE_TEST:
     return
   table = ht.createTable(ht.TABLE_NAME)
   # Add an empty column
   column = cl.Column(ht.COLUMN)
   column.addCells(ht.COLUMN1_CELLS)
   table.addColumn(column)
   # Add a column with the same name
   self.assertEqual(table.getColumns()[1], column)
   error = table.addColumn(column)
   self.assertIsNotNone(error)
   table = ht.createTable(ht.TABLE_NAME)
   # Add a column with data
   column = cl.Column(ht.COLUMN1)
   column.addCells(ht.LIST)
   table.addColumn(column)
   self.assertEqual(column.numCells(), table.numRows())
Пример #4
0
 def testAddColumn(self):
     if IGNORE_TEST:
         return
     table = ht.createTable(ht.TABLE_NAME)
     # Add an empty column
     column = cl.Column(ht.COLUMN)
     column.addCells(ht.COLUMN1_CELLS)
     table.addColumn(column)
     # Add a column with the same name
     self.assertEqual(table.getColumns()[1], column)
     error = table.addColumn(column)
     self.assertIsNotNone(error)
     table = ht.createTable(ht.TABLE_NAME)
     # Add a column with data
     column = cl.Column(ht.COLUMN1)
     column.addCells(ht.LIST)
     table.addColumn(column)
     self.assertEqual(column.numCells(), table.numRows())
 def setUp(self):
   self.table = createTable(TABLE_NAME)
   self._addColumn(COLUMN1, cells=COLUMN1_CELLS)
   self.column_a = self._addColumn(COLUMN2, cells=COLUMN2_CELLS)
   self.column_b = self._addColumn(COLUMNB, cells=COLUMNB_CELLS)
   self.column_c = self._addColumn(COLUMNC, cells=COLUMNC_CELLS)
   self.column_valid_formula = self._addColumn(COLUMN_VALID_FORMULA,
                                               formula=VALID_FORMULA)
   api_util.writeObjectToFile(self.table)
   self.evaluator = TableEvaluator(self.table)
Пример #6
0
 def _makeThreeLevelTable(self):
     """
 Updtes self.table to add "SUBTABLE" under "DUMMY_SUBTABLE"
 """
     first_subtable = self.table.tableFromName(ht.SUBTABLE_NAME)
     second_subtable = ht.createTable(NEW_SUBTABLE)
     column = cl.Column(ht.COLUMN)
     column.addCells(ht.COLUMN1_CELLS)
     second_subtable.addColumn(column)
     first_subtable.addChild(second_subtable)
Пример #7
0
 def testGetColumnFormula(self):
     if IGNORE_TEST:
         return
     table = ht.createTable("test", column_name=[ht.COLUMN1, ht.COLUMN2])
     column1 = table.columnFromName(ht.COLUMN1, is_relative=True)
     self.assertEqual(len(table.getFormulaColumns()), 0)
     formula1 = "range(5)"
     column1.setFormula(formula1)
     self.assertEqual(len(table.getFormulaColumns()), 1)
     column2 = table.columnFromName(ht.COLUMN2, is_relative=True)
     formula2 = "[2*x for x in %s]" % ht.COLUMN1
     column2.setFormula(formula2)
     self.assertEqual(len(table.getFormulaColumns()), 2)
     column2.setFormula(None)
     self.assertEqual(len(table.getFormulaColumns()), 1)
Пример #8
0
 def testGetColumnFormula(self):
   if IGNORE_TEST:
     return
   table = ht.createTable("test", column_name=[ht.COLUMN1, ht.COLUMN2])
   column1 = table.columnFromName(ht.COLUMN1)
   self.assertEqual(len(table.getFormulaColumns()), 0)
   formula1 = "range(5)"
   column1.setFormula(formula1)
   self.assertEqual(len(table.getFormulaColumns()), 1)
   column2 = table.columnFromName(ht.COLUMN2)
   formula2 = "[2*x for x in %s]" % ht.COLUMN1
   column2.setFormula(formula2)
   self.assertEqual(len(table.getFormulaColumns()), 2)
   column2.setFormula(None)
   self.assertEqual(len(table.getFormulaColumns()), 1)
 def setUp(self):
   self.table = createTable(TABLE_NAME)
   column1 = cl.Column(COLUMN1)
   column1.addCells(COLUMN1_CELLS)
   self.table.addColumn(column1)
   column2 = cl.Column(COLUMN2)
   column2.addCells(COLUMN2_CELLS)
   error = self.table.addColumn(column2)
   if error is not None:
     import pdb; pdb.set_trace()
   self.column5 = cl.Column(COLUMN5)
   self.column5.addCells(COLUMN5_CELLS)
   self.table.addColumn(self.column5)
   self.columns = self.table.getColumns()
   self.subtable = Table(SUBTABLE)
   self.table.addChild(self.subtable)
   self.subtable_column = self.subtable.getChildAtPosition(0)
   self.subtable_column_name = 'row'
Пример #10
0
 def setUp(self):
     self.table = createTable(TABLE_NAME)
     column1 = cl.Column(COLUMN1)
     column1.addCells(COLUMN1_CELLS)
     self.table.addColumn(column1)
     self.column2 = cl.Column(COLUMN2)
     self.column2.addCells(COLUMN2_CELLS)
     error = self.table.addColumn(self.column2)
     if error is not None:
         import pdb
         pdb.set_trace()
     self.column5 = cl.Column(COLUMN5)
     self.column5.addCells(COLUMN5_CELLS)
     self.table.addColumn(self.column5)
     self.columns = self.table.getColumns()
     self.subtable = Table(SUBTABLE)
     self.table.addChild(self.subtable)
     self.subtable_column = self.subtable.getChildAtPosition(0)
     self.subtable_column_name = 'row'
 def setUp(self):
     """
 Creates the following structure:
 DUMMY_TABLE
   row:
     DUMMY1:
     A:
     B:
     C:
     VALID_FORMULA:
 """
     self.table = createTable(TABLE_NAME)
     self._addColumn(COLUMN1, cells=COLUMN1_CELLS)
     self.column_a = self._addColumn(COLUMN2, cells=COLUMN2_CELLS)
     self.column_b = self._addColumn(COLUMNB, cells=COLUMNB_CELLS)
     self.column_c = self._addColumn(COLUMNC, cells=COLUMNC_CELLS)
     self.column_valid_formula = self._addColumn(COLUMN_VALID_FORMULA,
                                                 formula=VALID_FORMULA)
     api_util.writeObjectToFile(self.table)
     self.evaluator = TableEvaluator(self.table)
Пример #12
0
 def testAdjustColumnLength(self):
     if IGNORE_TEST:
         return
     table = ht.createTable(ht.TABLE_NAME)
     column = cl.Column(ht.COLUMN)
     column.addCells(ht.COLUMN1_CELLS)
     table.addColumn(column)
     column = cl.Column(ht.COLUMN1)
     column.addCells(['aa'])
     table.addColumn(column)
     table.adjustColumnLength()
     self.assertEqual(column.numCells(), table.numRows())
     self.assertIsNone(column.getCells()[1])
     column = cl.Column("YetAnotherColumn")
     column.addCells([1])
     table.addColumn(column)
     table.adjustColumnLength()
     self.assertEqual(column.numCells(), table.numRows())
     if column.isFloats():
         self.assertTrue(np.isnan(column.getCells()[1]))  # pylint: disable=E1101
     else:
         self.assertIsNone(column.getCells()[1])
Пример #13
0
 def testAdjustColumnLength(self):
   if IGNORE_TEST:
     return
   table = ht.createTable(ht.TABLE_NAME)
   column = cl.Column(ht.COLUMN)
   column.addCells(ht.COLUMN1_CELLS)
   table.addColumn(column)
   column = cl.Column(ht.COLUMN1)
   column.addCells(['aa'])
   table.addColumn(column)
   table.adjustColumnLength()
   self.assertEqual(column.numCells(), table.numRows())
   self.assertIsNone(column.getCells()[1])
   column = cl.Column("YetAnotherColumn")
   column.addCells([1])
   table.addColumn(column)
   table.adjustColumnLength()
   self.assertEqual(column.numCells(), table.numRows())
   if column.isFloats():
     self.assertTrue(np.isnan(column.getCells()[1]))  # pylint: disable=E1101
   else:
     self.assertIsNone(column.getCells()[1])
Пример #14
0
 def testRefactorColumn(self):
   if IGNORE_TEST:
     return
   table = ht.createTable("test", 
       column_name=[ht.COLUMN1, ht.COLUMN2, ht.COLUMN3])
   column1 = table.columnFromName(ht.COLUMN1)
   formula1 = "range(5)"
   column1.setFormula(formula1)
   column2 = table.columnFromName(ht.COLUMN2)
   formula2 = "%s = [5*x for x in %s]" % (ht.COLUMN2, ht.COLUMN1)
   column2.setFormula(formula2)
   table.evaluate(user_directory=ht.TEST_DIR)
   expected_values = [5*x for x in range(5)]
   actual_values = [x for x in column2.getCells()]
   self.assertTrue(expected_values == actual_values)
   new_name = "%s_new" % ht.COLUMN1
   table.refactorColumn(ht.COLUMN1, new_name)
   table.evaluate(user_directory=ht.TEST_DIR)
   column = table.columnFromName(new_name)
   self.assertIsNotNone(column)
   expected_values = range(5)
   actual_values = [x for x in column.getCells()]
   self.assertTrue(expected_values == actual_values)
Пример #15
0
 def testRefactorColumn(self):
     if IGNORE_TEST:
         return
     table = ht.createTable(
         "test", column_name=[ht.COLUMN1, ht.COLUMN2, ht.COLUMN3])
     column1 = table.columnFromName(ht.COLUMN1, is_relative=True)
     formula1 = "range(5)"
     column1.setFormula(formula1)
     column2 = table.columnFromName(ht.COLUMN2, is_relative=True)
     formula2 = "%s = [5*x for x in %s]" % (ht.COLUMN2, ht.COLUMN1)
     column2.setFormula(formula2)
     table.evaluate(user_directory=ht.TEST_DIR)
     expected_values = [5 * x for x in range(5)]
     actual_values = [x for x in column2.getCells()]
     self.assertTrue(expected_values == actual_values)
     new_name = "%s_new" % ht.COLUMN1
     table.refactorColumn(ht.COLUMN1, new_name)
     table.evaluate(user_directory=ht.TEST_DIR)
     column = table.columnFromName(new_name, is_relative=True)
     self.assertIsNotNone(column)
     expected_values = range(5)
     actual_values = [x for x in column.getCells()]
     self.assertTrue(expected_values == actual_values)
Пример #16
0
 def setUp(self):
   table = ht.createTable("test", column_name=[COLUMN1, COLUMN2])
   self.api = APIAdmin(table.getFilepath())
   self.api.initialize()
   ht.setupTableInitialization(self)
Пример #17
0
 def setUp(self):
   table = ht.createTable("test", column_name=COLUMN1)
   self.api = APIFormulas(table)
   ht.setupTableInitialization(self)
Пример #18
0
 def setUp(self):
     table = ht.createTable("test", column_name=COLUMN1)
     self.api = APIFormulas(table)
     ht.setupTableInitialization(self)
Пример #19
0
 def setUp(self):
     self.api = API()
     self.api._table = ht.createTable("test", column_name=COLUMN1)
     self.column1 = self.api._table.columnFromName(COLUMN1)
     self.column1.addCells(COLUMN1_VALUES, replace=True)
     ht.setupTableInitialization(self)
Пример #20
0
 def setUp(self):
     table = ht.createTable("test", column_name=[COLUMN1, COLUMN2])
     self.api = APIAdmin(table.getFilepath())
     self.api.initialize()
     ht.setupTableInitialization(self)