本文整理汇总了Python中ncobj.shorts.og函数的典型用法代码示例。如果您正苦于以下问题:Python og函数的具体用法?Python og怎么用?Python og使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了og函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_group_contained
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: _make_complex_group
def _make_complex_group():
g = og(
'temp',
aa=[oa('a_root_attr_num', _long(1)),
oa('c_root_attr_str', 'xyz'),
oa('b_root_attr_vec', np.array([1.2, 3, 4]))],
dd=[od('root_dim_x', 2)],
vv=[ov('root_var_1',
dd=[od('root_dim_x')],
aa=[oa('root_var_attr_1', _long(11))],
data=np.zeros((2))),
ov('root_var_2_scalar',
data=np.array(3.15, dtype=np.float32))],
gg=[og('subgroup',
aa=[oa('subgroup_attr', 'qq')],
dd=[od('subgroup_dim_y', 3)],
vv=[ov('subgroup_var',
dd=[od('root_dim_x'), od('subgroup_dim_y')],
aa=[oa('subgroup_var_attr', 57.5)],
data=np.zeros((2, 3)))],
gg=[og('sub_sub_group',
aa=[oa('sub_sub_group_attr', 'this')],
vv=[ov('sub_sub_group_var',
dd=[od('subgroup_dim_y')],
data=np.zeros((3)))])]),
og('sg_2_empty')])
ncg.complete(g)
return g
示例3: test_grouped_okay
def test_grouped_okay(self):
g = og('', dd=[od('x'), od('y')],
vv=[ov('v1', dd=[od('x')]), ov('v2', dd=[od('x'), od('y')])],
gg=[og('subgroup', dd=[od('z')],
vv=[ov('sv1', dd=[od('x')]),
ov('sv2', dd=[od('y'), od('z')])])])
self.assertTrue(has_no_missing_dims(g))
示例4: test_var_vs_grp
def test_var_vs_grp(self):
g = og('root', vv=[ov('tst1')], gg=[og('tst1')])
with self.assertRaises(NameConflictError) as err_context:
check_names(g)
msg = err_context.exception.message
self.check_all_in_str(msg, ['group "root"', 'both',
'variable', 'group', 'tst1'])
示例5: eg_simple_grouped
def eg_simple_grouped():
"""Produce a grouped version of the simple containers example."""
d_lat = od('lat', 10)
d_lon = od('lon', 5)
d_time = od('time', u=True)
dims = [d_lat, d_lon, d_time]
c_lat = ov('lat', dd=[d_lat], aa=[oa('units', 'degrees_north')])
c_lon = ov('lon', dd=[d_lon], aa=[oa('units', 'degrees_east')])
c_time = ov('time', dd=[d_time], aa=[oa('units', 'seconds')])
coords = [c_lat, c_lon, c_time]
g = og('foo',
dd=dims,
gg=[og('instrument',
vv=(coords +
[ov('rh', dd=dims, aa=[oa('_FillValue', -1)])]),
aa=[oa('container_type', 'simple'),
oa('measurement_platform', 'aircraft')]),
og('model',
vv=(coords +
[ov('rh', dd=dims, aa=[oa('_FillValue', -1)])]),
aa=[oa('container_type', 'simple'),
oa('measurement_platform',
'global circulation model')])])
_fake_complete(g)
return g
示例6: test_subgroup
def test_subgroup(self):
g = og('',
gg=[og('subgroup', vv=[ov('v1', dd=[od('y', 2)])])])
self.do_complete(g)
self.assertEqual(len(g.dimensions), 1)
self.assertEqual(list(g.dimensions), [od('y', 2)])
self.assertIs(g.groups['subgroup'].variables['v1'].dimensions[0],
g.dimensions['y'])
示例7: test_okay_override_subgroup
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)
示例8: test_subgroup_okay
def test_subgroup_okay(self):
g = og('root', vv=[ov('test_var')],
gg=[og('tst1', vv=[ov('test_var')])])
subgroup = g.groups['tst1']
self.assertFalse(group_is_tagged(g))
self.assertFalse(group_is_tagged(subgroup))
check_names(g)
self.assertFalse(group_is_tagged(g))
self.assertFalse(group_is_tagged(subgroup))
示例9: test_inner_groups
def test_inner_groups(self):
g = og('group_name', gg=[og('sub_group')])
result = cdl(g)
self.assertEqual(result,
'netcdf group_name {\n'
'\n'
'group: sub_group {\n'
'} // group sub_group\n'
'}')
示例10: test_fail_nomatch_subgroup
def test_fail_nomatch_subgroup(self):
g = og('', dd=[od('x')],
vv=[ov('v1', dd=[od('x', 2)])],
gg=[og('subgroup', vv=[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',
'/subgroup/v2', '"x" = 3'])
示例11: test_with_varsdata_okay
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))
示例12: test_grouped_fail
def test_grouped_fail(self):
g = og('', dd=[od('x'), od('y')],
vv=[ov('v1', dd=[od('x')]), ov('v2', dd=[od('x'), od('y')])],
gg=[og('subgroup', dd=[od('zz')],
vv=[ov('sv1', dd=[od('x')]),
ov('sv2', dd=[od('y'), od('z')])])])
with self.assertRaises(IncompleteStructureError) as err_context:
has_no_missing_dims(g, fail_if_not=True)
msg = err_context.exception.message
self.check_all_in_str(msg, [
'Variable "/subgroup/sv2"', 'dimension "z"',
'no definition exists'])
示例13: test_partial_grouped
def test_partial_grouped(self):
# Build a group with one dimension to be found in the subgroup.
g = og('',
gg=[og('subgroup',
dd=[od('x', 4)],
vv=[ov('subvar_1', dd=[od('x')]),
ov('subvar_2', dd=[od('z', 3), od('x')])])])
dim_x_def = g.groups['subgroup'].dimensions['x']
self.do_complete(g)
self.assertEqual(list(g.dimensions), [od('z', 3)])
self.assertEqual(list(g.groups['subgroup'].dimensions), [dim_x_def])
self.assertIs(g.groups['subgroup'].dimensions['x'], dim_x_def)
示例14: test_with_varsdata_fail
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))
示例15: test_inner_group_attr
def test_inner_group_attr(self):
g = og('group_name',
gg=[og('sub_group',
aa=[oa('x', _long(2))])])
result = cdl(g)
self.assertEqual(result,
'netcdf group_name {\n'
'\n'
'group: sub_group {\n'
'\n'
'// group attributes:\n'
' :x = 2L ;\n'
'} // group sub_group\n'
'}')