示例#1
0
 def test_group_contained(self):
     g = og('',
            gg=[og('subgroup', dd=[od('x', 4)],
                   vv=[ov('sv1', dd=[od('x'), od('y')])])])
     add_missing_dims(g)
     self.assertEqual(list(g.dimensions), [od('y')])
     self.assertEqual(list(g.groups['subgroup'].dimensions), [od('x', 4)])
示例#2
0
 def test_shared_clash(self):
     # NOTE: "complete" won't allow this, but this method doesn't care.
     g = og('', vv=[ov('v1', dd=[od('x', 2)]),
                    ov('v2', dd=[od('x', 3)])])
     add_missing_dims(g)
     self.assertEqual(len(g.dimensions), 1)
     self.assertEqual(g.dimensions.names(), ['x'])
示例#3
0
 def test_unlimited(self):
     g = og('', vv=[ov('v', dd=[od('x', 2, u=True)])])
     self.assertEqual(all_dimensions(g), [])
     add_missing_dims(g)
     self.assertEqual(len(g.dimensions), 1)
     self.assertNotEqual(all_dimensions(g), [od('x', 2)])
     self.assertEqual(all_dimensions(g), [od('x', 2, u=True)])
示例#4
0
 def test_mixture(self):
     g = og('', dd=[od('x')], vv=[ov('v', dd=[od('y')])])
     self.assertEqual(all_dimensions(g), [od('x')])
     r = add_missing_dims(g)
     self.assertEqual(r, [od('y')])
     self.assertEqual(len(g.dimensions), 2)
     self.assertIs(r[0], g.dimensions['y'])
示例#5
0
 def test_missing(self):
     g = og('', vv=[ov('v', dd=[od('x')])])
     self.assertEqual(all_dimensions(g), [])
     r = add_missing_dims(g)
     self.assertEqual(r, [od('x')])
     self.assertEqual(all_dimensions(g), [od('x')])
     self.assertIs(g.dimensions['x'], r[0])
示例#6
0
 def test_length(self):
     g = og('', vv=[ov('v', dd=[od('x', 2)])])
     self.assertEqual(all_dimensions(g), [])
     r = add_missing_dims(g)
     self.assertEqual(r, [od('x', 2)])
     self.assertEqual(len(g.dimensions), 1)
     self.assertNotEqual(all_dimensions(g), [od('x')])
     self.assertEqual(all_dimensions(g), [od('x', 2)])
示例#7
0
 def test_nomissing(self):
     g = og('', dd=[od('x')], vv=[ov('v', dd=[od('x')])])
     test_dim = g.dimensions['x']
     str_before = str(g)
     r = add_missing_dims(g)
     self.assertEqual(r, [])
     self.assertIs(g.dimensions['x'], test_dim)
     self.assertEqual(str(g), str_before)
示例#8
0
 def test_multiple(self):
     g = og('', vv=[ov('v1', dd=[od('x'), od('y')]),
                    ov('v2', dd=[od('y'), od('z')])])
     self.assertEqual(all_dimensions(g), [])
     r = add_missing_dims(g)
     self.assertEqual(len(r), 3)
     self.assertEqual(len(g.dimensions), 3)
     self.assertIn(od('x'), g.dimensions)
     self.assertIn(od('y'), g.dimensions)
     self.assertIn(od('z'), g.dimensions)
示例#9
0
 def test_subgroup_mixed(self):
     g = og('', vv=[ov('v1', dd=[od('q')])],
            gg=[og('subgroup', vv=[ov('v1', dd=[od('q', 2)])])])
     add_missing_dims(g)
     self.assertEqual(len(g.dimensions), 1)
     self.assertEqual(g.dimensions.names(), ['q'])
示例#10
0
 def test_empty(self):
     g = og('')
     add_missing_dims(g)