def test_remove_rows_from_the_middle(self):
     model = TimePatternModel(TimePattern(['a', 'b', 'c'],
                                          [-5.0, 3.0, 7.0]))
     self.assertTrue(model.removeRows(1, 1))
     self.assertEqual(len(model.value), 2)
     self.assertEqual(model.value.indexes, ['a', 'c'])
     numpy.testing.assert_equal(model.value.values, np.array([-5.0, 7.0]))
 def test_insert_rows_in_the_end(self):
     model = TimePatternModel(TimePattern(['a', 'b'], [-5.0, 7.0]))
     self.assertTrue(model.insertRows(2, 1))
     self.assertEqual(len(model.value), 3)
     self.assertEqual(model.value.indexes, ['a', 'b', '3'])
     numpy.testing.assert_equal(model.value.values,
                                np.array([-5.0, 7.0, 0.0]))
 def test_insert_multiple_rows_in_the_middle(self):
     model = TimePatternModel(TimePattern(['a', 'b'], [-5.0, 7.0]))
     self.assertTrue(model.insertRows(1, 3))
     self.assertEqual(len(model.value), 5)
     self.assertEqual(model.value.indexes, ['a', '2', '3', '4', 'b'])
     numpy.testing.assert_equal(model.value.values,
                                np.array([-5.0, 0.0, 0.0, 0.0, 7.0]))
 def test_flags(self):
     model = TimePatternModel(TimePattern(["", ""], [0.0, 0.0]))
     for row in range(len(model.value)):
         for column in range(2):
             model_index = model.index(row, column)
             self.assertEqual(
                 model.flags(model_index),
                 Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)
 def test_batch_set_data(self):
     model = TimePatternModel(TimePattern(['a', 'b', 'c'],
                                          [-5.0, 3.0, 7.0]))
     indexes = [model.index(0, 0), model.index(1, 1), model.index(2, 1)]
     values = ['A', 55.5, -55.5]
     model.batch_set_data(indexes, values)
     expected = TimePattern(['A', 'b', 'c'], [-5.0, 55.5, -55.5])
     self.assertEqual(model.value, expected)
 def test_cannot_remove_all_rows(self):
     model = TimePatternModel(TimePattern(['a', 'b'], [-5.0, 7.0]))
     self.assertTrue(model.removeRows(0, 2))
     self.assertEqual(len(model.value), 1)
     self.assertEqual(model.value.indexes, ['a'])
     numpy.testing.assert_equal(model.value.values, [-5.0])
 def test_remove_rows_from_the_beginning(self):
     model = TimePatternModel(TimePattern(['a', 'b'], [-5.0, 7.0]))
     self.assertTrue(model.removeRows(0, 1))
     self.assertEqual(len(model.value), 1)
     self.assertEqual(model.value.indexes, ['b'])
     numpy.testing.assert_equal(model.value.values, np.array([7.0]))
 def test_setData(self):
     model = TimePatternModel(TimePattern(['a', 'b'], [-5.0, 7.0]))
     model_index = model.index(1, 1)
     model.setData(model_index, 2.3)
     self.assertEqual(model.value.indexes, ['a', 'b'])
     numpy.testing.assert_equal(model.value.values, [-5.0, 2.3])
 def test_removing_last_row_fails(self):
     model = TimePatternModel(TimePattern(['a'], [-5.0]))
     self.assertFalse(model.removeRows(0, 1))