Ejemplo n.º 1
0
 def test_single_plot_with_axis_no_metadata(self):
     plot = Contour(self.cube, self.axes)
     with mock.patch('cube_browser.Contour.sliders_axis',
                     new_callable=mock.PropertyMock) as sliders_axis:
         alias = _AxisAlias(dim=0, name=None, size=7)
         sliders_axis.return_value = [alias]
         emsg = ("cube {!r} has no meta-data "
                 "for dimension 0".format(self.cube.name()))
         with self.assertRaisesRegexp(ValueError, emsg):
             Browser(plot)
Ejemplo n.º 2
0
 def test_single_plot_with_axis_no_metadata(self):
     plot = Contour(self.cube, self.axes)
     with mock.patch('cube_browser.Contour.sliders_axis',
                     new_callable=mock.PropertyMock) as sliders_axis:
         alias = _AxisAlias(dim=0, name=None, size=7)
         sliders_axis.return_value = [alias]
         emsg = ("cube {!r} has no meta-data "
                 "for dimension 0".format(self.cube.name()))
         with self.assertRaisesRegexp(ValueError, emsg):
             Browser(plot)
Ejemplo n.º 3
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'])
Ejemplo n.º 4
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'])
Ejemplo n.º 5
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'])
Ejemplo n.º 6
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'])
Ejemplo n.º 7
0
 def test_alias_with_different_size(self):
     a1 = _AxisAlias(dim=0, name=1, size=2)
     a2 = _AxisAlias(dim=0, name=1, size=20)
     self.assertNotEqual(a1, a2)
Ejemplo n.º 8
0
 def test_alias_with_defn(self):
     a1 = _AxisAlias(dim=0, name=1, size=2)
     a2 = _AxisDefn(dim=0, name=1, size=2, coord=3)
     self.assertNotEqual(a1, a2)
Ejemplo n.º 9
0
 def test_alias_same_with_different_dim(self):
     a1 = _AxisAlias(dim=0, name=1, size=2)
     a2 = _AxisAlias(dim=1, name=1, size=2)
     self.assertEqual(a1, a2)
Ejemplo n.º 10
0
 def test_alias_same(self):
     a1 = _AxisAlias(dim=0, name=1, size=2)
     a2 = _AxisAlias(dim=0, name=1, size=2)
     self.assertEqual(a1, a2)
Ejemplo n.º 11
0
 def test_lookup(self):
     dim, name, size = 0, 1, 2
     a = _AxisAlias(dim=dim, name=name, size=size)
     self.assertEqual(a.dim, dim)
     self.assertEqual(a.name, name)
     self.assertEqual(a.size, size)
Ejemplo n.º 12
0
 def test_slider_alias(self):
     plot = Plot2D(self.cube, self.axes)
     plot.alias(time=0)
     expected = _AxisAlias(dim=0, name='time', size=7)
     self.assertEqual(plot.sliders_axis, [expected])
Ejemplo n.º 13
0
 def test_slider_alias(self):
     plot = Plot2D(self.cube, self.axes)
     plot.alias(time=0)
     expected = _AxisAlias(dim=0, name='time', size=7)
     self.assertEqual(plot.sliders_axis, [expected])