def test_plot_tree_view_selection_raises_with_mixed_data(self): model = _MockParameterModel() selected_indexes = list() selected_indexes.append(model.index(1, 1)) selected_indexes.append(model.index(2, 1)) support = ParameterTablePlottingHints() with self.assertRaises(PlottingError): plot_selection(model, selected_indexes, support)
def test_plot_tree_view_selection_into_existing_plot_with_mixed_data_raises(self): model = _MockParameterModel() selected_indexes = [model.index(2, 1)] support = ParameterTablePlottingHints() plot_widget = plot_selection(model, selected_indexes, support) self.assertEqual(plot_widget.plot_type, TimeSeries) selected_indexes = [model.index(0, 1), model.index(1, 1)] with self.assertRaises(PlottingError): plot_selection(model, selected_indexes, support, plot_widget)
def test_plot_tree_view_selection_into_existing_plot(self): model = _MockParameterModel() selected_indexes = [model.index(2, 1)] support = ParameterTablePlottingHints() plot_widget = plot_selection(model, selected_indexes, support) self.assertEqual(plot_widget.plot_type, TimeSeries) selected_indexes = [model.index(3, 1)] plot_selection(model, selected_indexes, support, plot_widget) lines = plot_widget.canvas.axes.get_lines() self.assertEqual(len(lines), 2) self.assertEqual(list(lines[0].get_ydata(orig=True)), [0.5, 2.3]) self.assertEqual(list(lines[1].get_ydata(orig=True)), [-5.0, -3.3])
def test_plot_simple_map(self): """Test that a selection containing a single plain number gets plotted.""" model = _make_pivot_proxy_model() support = PivotTablePlottingHints() plot_widget = plot_selection(model, [model.index(3, 4)], support) self.assertEqual(plot_widget.plot_type, Map) lines = plot_widget.canvas.axes.get_lines() self.assertEqual(len(lines), 1) self.assertEqual(list(lines[0].get_ydata(orig=True)), [-1.1, -2.2])
def test_plot_single_plain_number(self): """Test that a selection containing a single plain number gets plotted.""" model = _MockParameterModel() selected_indexes = list() selected_indexes.append(model.index(0, 1)) support = ParameterTablePlottingHints() plot_widget = plot_selection(model, selected_indexes, support) lines = plot_widget.canvas.axes.get_lines() self.assertEqual(len(lines), 1) self.assertEqual(list(lines[0].get_ydata(orig=True)), [-2.3])
def test_plot_tree_view_selection_of_floats(self): model = _MockParameterModel() selected_indexes = list() selected_indexes.append(model.index(0, 1)) selected_indexes.append(model.index(1, 1)) support = ParameterTablePlottingHints() plot_widget = plot_selection(model, selected_indexes, support) lines = plot_widget.canvas.axes.get_lines() self.assertEqual(len(lines), 1) self.assertTrue(all(lines[0].get_ydata(orig=True) == [-2.3, -0.5]))
def test_plot_tree_view_selection_of_time_series(self): model = _MockParameterModel() selected_indexes = list() selected_indexes.append(model.index(2, 1)) selected_indexes.append(model.index(3, 1)) support = ParameterTablePlottingHints() plot_widget = plot_selection(model, selected_indexes, support) lines = plot_widget.canvas.axes.get_lines() self.assertEqual(len(lines), 2) self.assertEqual(list(lines[0].get_ydata(orig=True)), [0.5, 2.3]) self.assertEqual(list(lines[1].get_ydata(orig=True)), [-5.0, -3.3])
def test_plot_nested_map_containing_time_series(self): """Test that a selection containing a single plain number gets plotted.""" model = _make_pivot_proxy_model() support = PivotTablePlottingHints() plot_widget = plot_selection(model, [model.index(5, 4)], support) self.assertEqual(plot_widget.plot_type, TimeSeries) lines = plot_widget.canvas.axes.get_lines() self.assertEqual(len(lines), 4) self.assertEqual(list(lines[0].get_ydata(orig=True)), [-1.1, -2.2]) self.assertEqual(list(lines[1].get_ydata(orig=True)), [-3.3, -4.4]) self.assertEqual(list(lines[2].get_ydata(orig=True)), [-5.5, -6.6]) self.assertEqual(list(lines[3].get_ydata(orig=True)), [-7.7, -8.8])
def test_plot_pivot_selection(self): model = _make_pivot_proxy_model() selected_indexes = list() for row in range(2, 5): for column in range(1, 3): selected_indexes.append(model.index(row, column)) support = PivotTablePlottingHints() plot_widget = plot_selection(model, selected_indexes, support) lines = plot_widget.canvas.axes.get_lines() self.assertEqual(len(lines), 2) self.assertTrue(all(lines[0].get_ydata(orig=True) == [1.1, 1.2, 1.3])) self.assertTrue( all(lines[1].get_ydata(orig=True) == [-3.0, -1.0, 2.0]))