예제 #1
0
 def test_two_plots_with_incompatible_axis_to_alias_axis(self):
     c1 = Contour(self.cube, self.axes)
     c2 = Contour(self.cube, self.axes)
     c2.alias(time=0)
     emsg = ("cube 'air_potential_temperature' has an incompatible axis "
             "'time' on dimension 0")
     with self.assertRaisesRegexp(ValueError, emsg):
         Browser([c1, c2])
예제 #2
0
 def test_two_plots_with_incompatible_axis_to_alias_axis(self):
     c1 = Contour(self.cube, self.axes)
     c2 = Contour(self.cube, self.axes)
     c2.alias(time=0)
     emsg = ("cube 'air_potential_temperature' has an incompatible axis "
             "'time' on dimension 0")
     with self.assertRaisesRegexp(ValueError, emsg):
         Browser([c1, c2])
예제 #3
0
 def test_two_plots_with_incompatible_alias_axis_to_alias_axis(self):
     c1 = Contour(self.cube, self.axes)
     c1.alias(time=0)
     other = self.cube.copy()
     other.remove_coord('time')
     c2 = Contour(other, self.axes, coords=(0, 'grid_latitude'))
     c2.alias(time=2)
     emsg = ("cube 'air_potential_temperature' has an incompatible axis "
             "'time' on dimension 2")
     with self.assertRaisesRegexp(ValueError, emsg):
         Browser([c1, c2])
예제 #4
0
 def test_two_plots_with_incompatible_alias_axis_to_alias_axis(self):
     c1 = Contour(self.cube, self.axes)
     c1.alias(time=0)
     other = self.cube.copy()
     other.remove_coord('time')
     c2 = Contour(other, self.axes, coords=(0, 'grid_latitude'))
     c2.alias(time=2)
     emsg = ("cube 'air_potential_temperature' has an incompatible axis "
             "'time' on dimension 2")
     with self.assertRaisesRegexp(ValueError, emsg):
         Browser([c1, c2])
예제 #5
0
 def test_single_plot_with_alias_axis(self):
     plot = Contour(self.cube, self.axes)
     plot.alias(wibble=0)
     with mock.patch('cube_browser.Contour.__call__') as func:
         browser = Browser(plot)
         browser.display()
         # Check the initial render.
         func.assert_called_once_with(wibble=self.value)
         # Now simulate a slider change.
         slider = browser._slider_by_name['wibble']
         change = dict(owner=slider)
         browser.on_change(change)
         self.assertEqual(func.call_count, 2)
         expected = [mock.call(wibble=self.value),
                     mock.call(wibble=self.value)]
         func.assert_has_calls(expected)
예제 #6
0
 def test_single_plot_with_alias_axis(self):
     plot = Contour(self.cube, self.axes)
     plot.alias(wibble=0)
     browser = Browser(plot)
     # Check axis_by_name.
     axis = _AxisAlias(dim=0, name='wibble', size=7)
     expected = dict(wibble=axis)
     self.assertEqual(browser._axis_by_name, expected)
     # Check plots_by_name.
     plot_id = id(plot)
     plots_by_name = browser._plots_by_name
     self.assertEqual(plots_by_name.keys(), ['wibble'])
     self.assertEqual([id(v) for v in plots_by_name['wibble']], [plot_id])
     # Check names_by_plot_id.
     names_by_plot_id = browser._names_by_plot_id
     self.assertEqual(names_by_plot_id.keys(), [plot_id])
     self.assertEqual(names_by_plot_id[plot_id], ['wibble'])
예제 #7
0
 def test_single_plot_with_alias_axis(self):
     plot = Contour(self.cube, self.axes)
     plot.alias(wibble=0)
     browser = Browser(plot)
     # Check axis_by_name.
     axis = _AxisAlias(dim=0, name='wibble', size=7)
     expected = dict(wibble=axis)
     self.assertEqual(browser._axis_by_name, expected)
     # Check plots_by_name.
     plot_id = id(plot)
     plots_by_name = browser._plots_by_name
     self.assertEqual(plots_by_name.keys(), ['wibble'])
     self.assertEqual([id(v) for v in plots_by_name['wibble']], [plot_id])
     # Check names_by_plot_id.
     names_by_plot_id = browser._names_by_plot_id
     self.assertEqual(names_by_plot_id.keys(), [plot_id])
     self.assertEqual(names_by_plot_id[plot_id], ['wibble'])
예제 #8
0
 def test_single_plot_with_alias_axis(self):
     plot = Contour(self.cube, self.axes)
     plot.alias(wibble=0)
     with mock.patch('cube_browser.Contour.__call__') as func:
         browser = Browser(plot)
         browser.display()
         # Check the initial render.
         func.assert_called_once_with(wibble=self.value)
         # Now simulate a slider change.
         slider = browser._slider_by_name['wibble']
         change = dict(owner=slider)
         browser.on_change(change)
         self.assertEqual(func.call_count, 2)
         expected = [
             mock.call(wibble=self.value),
             mock.call(wibble=self.value)
         ]
         func.assert_has_calls(expected)
예제 #9
0
 def test_two_plots_with_shared_alias_axis(self):
     coords = ('time', 'grid_longitude')
     c1 = Contour(self.cube, self.axes, coords=coords)
     c1.alias(wibble=1)
     c2 = Contour(self.cube, self.axes, coords=coords)
     c2.alias(wibble=1)
     with mock.patch('cube_browser.Contour.__call__') as func:
         browser = Browser([c1, c2])
         browser.display()
         # Check the initial render.
         self.assertEqual(func.call_count, 2)
         expected = [mock.call(wibble=self.value)] * 2
         func.assert_has_calls(expected)
         # Now simulate a slider change.
         slider = browser._slider_by_name['wibble']
         change = dict(owner=slider)
         browser.on_change(change)
         self.assertEqual(func.call_count, 4)
         expected *= 2
         func.assert_has_calls(expected)
예제 #10
0
 def test_two_plots_with_shared_alias_axis(self):
     coords = ('time', 'grid_longitude')
     c1 = Contour(self.cube, self.axes, coords=coords)
     c1.alias(wibble=1)
     c2 = Contour(self.cube, self.axes, coords=coords)
     c2.alias(wibble=1)
     with mock.patch('cube_browser.Contour.__call__') as func:
         browser = Browser([c1, c2])
         browser.display()
         # Check the initial render.
         self.assertEqual(func.call_count, 2)
         expected = [mock.call(wibble=self.value)] * 2
         func.assert_has_calls(expected)
         # Now simulate a slider change.
         slider = browser._slider_by_name['wibble']
         change = dict(owner=slider)
         browser.on_change(change)
         self.assertEqual(func.call_count, 4)
         expected *= 2
         func.assert_has_calls(expected)
예제 #11
0
 def test_two_plots_with_shared_alias_axis(self):
     coords = ('time', 'grid_longitude')
     c1 = Contour(self.cube, self.axes, coords=coords)
     c1.alias(wibble=1)
     c2 = Contour(self.cube, self.axes, coords=coords)
     c2.alias(wibble=1)
     browser = Browser([c1, c2])
     # Check axis_by_name.
     axis = _AxisAlias(dim=1, name='wibble', size=9)
     expected = dict(wibble=axis)
     self.assertEqual(browser._axis_by_name, expected)
     # Check plots_by_name.
     c1_id, c2_id = id(c1), id(c2)
     plots_by_name = browser._plots_by_name
     self.assertEqual(plots_by_name.keys(), ['wibble'])
     self.assertEqual(set([id(v) for v in plots_by_name['wibble']]),
                      set([c1_id, c2_id]))
     # Check names_by_plot_id.
     names_by_plot_id = browser._names_by_plot_id
     self.assertEqual(set(names_by_plot_id.keys()), set([c1_id, c2_id]))
     self.assertEqual(names_by_plot_id[c1_id], ['wibble'])
     self.assertEqual(names_by_plot_id[c2_id], ['wibble'])
예제 #12
0
 def test_two_plots_with_shared_alias_axis(self):
     coords = ('time', 'grid_longitude')
     c1 = Contour(self.cube, self.axes, coords=coords)
     c1.alias(wibble=1)
     c2 = Contour(self.cube, self.axes, coords=coords)
     c2.alias(wibble=1)
     browser = Browser([c1, c2])
     # Check axis_by_name.
     axis = _AxisAlias(dim=1, name='wibble', size=9)
     expected = dict(wibble=axis)
     self.assertEqual(browser._axis_by_name, expected)
     # Check plots_by_name.
     c1_id, c2_id = id(c1), id(c2)
     plots_by_name = browser._plots_by_name
     self.assertEqual(plots_by_name.keys(), ['wibble'])
     self.assertEqual(set([id(v) for v in plots_by_name['wibble']]),
                      set([c1_id, c2_id]))
     # Check names_by_plot_id.
     names_by_plot_id = browser._names_by_plot_id
     self.assertEqual(set(names_by_plot_id.keys()), set([c1_id, c2_id]))
     self.assertEqual(names_by_plot_id[c1_id], ['wibble'])
     self.assertEqual(names_by_plot_id[c2_id], ['wibble'])