Beispiel #1
0
 def test_fail_nomatch(self):
     g = og('', dd=[od('x')],
            vv=[ov('v1', dd=[od('x', 2)]),
                ov('v2', dd=[od('x', 3)])])
     with self.assertRaises(DimensionConflictError) as err_context:
         check_dims(g)
     msg = err_context.exception.message
     self.check_all_in_str(msg, ['/v1', '"x" = 2', '/v2', '"x" = 3'])
Beispiel #2
0
 def test_fail_bad_data_shapes(self):
     d1 = _mockdata((5, 3, 2))
     g = og('', dd=[od('x'), od('y')],
            vv=[ov('v1', dd=[od('x'), od('y')], data=d1)])
     with self.assertRaises(DimensionConflictError) as err_context:
         check_dims(g)
     msg = err_context.exception.message
     self.check_all_in_str(msg, ['/v1', '3 dimensions', '2 dimensions'])
Beispiel #3
0
 def test_okay_override_subgroup(self):
     # NOTE: here *two* 'x' dimensions, which do not conflict.
     g = og('', dd=[od('x')],
            vv=[ov('v1', dd=[od('x', 2)])],
            gg=[og('subgroup',
                   dd=[od('x')],
                   vv=[ov('v2', dd=[od('x', 3)])])])
     check_dims(g)
Beispiel #4
0
 def test_fail_conflicting_data_shapes(self):
     d1 = _mockdata((2, 23))
     v1 = ov('v1', dd=[od('x'), od('y')], data=d1)
     v2 = ov('v2', dd=[od('x', 17), od('y', 23)])
     g = og('', dd=[od('x'), od('y')], vv=[v1, v2])
     with self.assertRaises(DimensionConflictError) as err_context:
         check_dims(g)
     msg = err_context.exception.message
     self.check_all_in_str(msg, ['/v1', '/v2', '"x" = 17', '"x" = 2'])
Beispiel #5
0
 def test_with_varsdata_okay(self):
     g = og('', dd=[od('x')],
            vv=[ov('v1', dd=[od('x', 2)])],
            gg=[og('subgroup', vv=[ov('v2', dd=[od('x', 2)])])])
     subgroup = g.groups['subgroup']
     tag_group(g)
     self.assertTrue(group_is_tagged(g))
     self.assertFalse(group_is_tagged(subgroup))
     check_dims(g)
     self.assertTrue(group_is_tagged(g))
     self.assertFalse(group_is_tagged(subgroup))
Beispiel #6
0
 def test_with_varsdata_fail(self):
     g = og('', dd=[od('x')],
            vv=[ov('v1', dd=[od('x', 2)])],
            gg=[og('subgroup', vv=[ov('v2', dd=[od('x', 3)])])])
     subgroup = g.groups['subgroup']
     tag_group(g)
     self.assertTrue(group_is_tagged(g))
     self.assertFalse(group_is_tagged(subgroup))
     with self.assertRaises(DimensionConflictError):
         check_dims(g)
     self.assertTrue(group_is_tagged(g))
     self.assertFalse(group_is_tagged(subgroup))
Beispiel #7
0
 def test_okay_data_shapes_override(self):
     d1 = _mockdata((2, 3))
     var_xy = ov('v1_xy', dd=[od('x'), od('y')], data=d1)
     g = og('', dd=[od('x', 17), od('y', 23)], vv=[var_xy])
     check_dims(g)
Beispiel #8
0
 def test_with_data_shapes_okay(self):
     d1 = _mockdata((2, 3))
     var_xy = ov('v1_xy', dd=[od('x'), od('y')], data=d1)
     g = og('', dd=[od('x'), od('y')], vv=[var_xy])
     check_dims(g)
Beispiel #9
0
 def test_okay_match_subgroup(self):
     g = og('', dd=[od('x')],
            vv=[ov('v1', dd=[od('x', 2)])],
            gg=[og('subgroup', vv=[ov('v2', dd=[od('x', 2)])])])
     check_dims(g)
Beispiel #10
0
 def test_okay_match_unlimited(self):
     g = og('', dd=[od('x')],
            vv=[ov('v1', dd=[od('x', 3)]),
                ov('v2', dd=[od('x', 3, u=True)])])
     check_dims(g)
Beispiel #11
0
 def test_okay_match(self):
     g = og('', dd=[od('x')],
            vv=[ov('v1', dd=[od('x', 3)]),
                ov('v2', dd=[od('x', 3)])])
     check_dims(g)
Beispiel #12
0
 def test_fail_incomplete(self):
     g = og('', vv=[ov('v1', dd=[od('x')])])
     with self.assertRaises(IncompleteStructureError):
         check_dims(g)
Beispiel #13
0
 def test_fail_nolength(self):
     g = og('', dd=[od('x')], vv=[ov('v1', dd=[od('x')])])
     with self.assertRaises(DimensionConflictError) as err_context:
         check_dims(g)
     msg = err_context.exception.message
     self.check_all_in_str(msg, ['No length', 'dimension "/x"'])
Beispiel #14
0
 def test_single(self):
     g = og('', dd=[od('x')], vv=[ov('v1', dd=[od('x', 5)])])
     check_dims(g)
Beispiel #15
0
 def test_empty(self):
     g = og('')
     check_dims(g)