本文整理汇总了Python中ncobj.shorts.og函数的典型用法代码示例。如果您正苦于以下问题:Python og函数的具体用法?Python og怎么用?Python og使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了og函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)])
开发者ID:pp-mo,项目名称:ncobj,代码行数:7,代码来源:test_grouping.py
示例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
开发者ID:pp-mo,项目名称:ncobj,代码行数:28,代码来源:test_cdl.py
示例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))
开发者ID:pp-mo,项目名称:ncobj,代码行数:7,代码来源:test_grouping.py
示例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'])
开发者ID:pp-mo,项目名称:ncobj,代码行数:7,代码来源:test_grouping.py
示例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
开发者ID:pp-mo,项目名称:ncobj,代码行数:27,代码来源:simple_semantic_containers.py
示例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'])
开发者ID:pp-mo,项目名称:ncobj,代码行数:8,代码来源:test_grouping.py
示例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)
开发者ID:pp-mo,项目名称:ncobj,代码行数:8,代码来源:test_grouping.py
示例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))
开发者ID:pp-mo,项目名称:ncobj,代码行数:9,代码来源:test_grouping.py
示例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'
'}')
开发者ID:pp-mo,项目名称:ncobj,代码行数:9,代码来源:test_cdl.py
示例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'])
开发者ID:pp-mo,项目名称:ncobj,代码行数:9,代码来源:test_grouping.py
示例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))
开发者ID:pp-mo,项目名称:ncobj,代码行数:11,代码来源:test_grouping.py
示例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'])
开发者ID:pp-mo,项目名称:ncobj,代码行数:12,代码来源:test_grouping.py
示例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)
开发者ID:pp-mo,项目名称:ncobj,代码行数:12,代码来源:test_grouping.py
示例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))
开发者ID:pp-mo,项目名称:ncobj,代码行数:12,代码来源:test_grouping.py
示例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'
'}')
开发者ID:pp-mo,项目名称:ncobj,代码行数:14,代码来源:test_cdl.py
示例16: test_subgroup_mixed
def test_subgroup_mixed(self):
g = og('',
vv=[ov('v1', dd=[od('q')])],
gg=[og('subgroup',
vv=[ov('v1', dd=[od('q', 2)])])])
self.assertEqual(list(g.dimensions), [])
v1 = g.variables['v1']
v2 = g.groups['subgroup'].variables['v1']
self.do_complete(g)
self.assertEqual(len(g.dimensions), 1)
self.assertEqual(list(g.dimensions), [od('q', 2)])
test_dim = g.dimensions['q']
self.assertIs(v1.dimensions[0], test_dim)
self.assertIs(v2.dimensions[0], test_dim)
开发者ID:pp-mo,项目名称:ncobj,代码行数:14,代码来源:test_grouping.py
示例17: test_shared_clash
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'])
开发者ID:pp-mo,项目名称:ncobj,代码行数:7,代码来源:test_grouping.py
示例18: test_unlimited
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)])
开发者ID:pp-mo,项目名称:ncobj,代码行数:7,代码来源:test_grouping.py
示例19: eg_simple_flat
def eg_simple_flat():
"""Produce a flat 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]
collection_vars = [
ov('instrument', data=np.array(0),
aa=[oa('container_type', 'simple'),
oa('members',
('instrument___lat instrument___lon instrument___rh '
'instrument___time')),
oa('measurement_platform', 'aircraft')]),
ov('model', data=np.array(0),
aa=[oa('container_type', 'simple'),
oa('members',
'model___lat model___lon model___rh model___time'),
oa('measurement_platform', 'global circulation model')])]
data_vars = [
ov('instrument___lat', dd=[d_lat], aa=[oa('units', 'degrees_north')]),
ov('instrument___lon', dd=[d_lon], aa=[oa('units', 'degrees_east')]),
ov('instrument___time', dd=[d_time], aa=[oa('units', 'seconds')]),
ov('instrument___rh', dd=dims, aa=[oa('_FillValue', -1)]),
ov('model___lat', dd=[d_lat], aa=[oa('units', 'degrees_north')]),
ov('model___lon', dd=[d_lon], aa=[oa('units', 'degrees_east')]),
ov('model___time', dd=[d_time], aa=[oa('units', 'seconds')]),
ov('model___rh', dd=dims, aa=[oa('_FillValue', -1)])]
g = og('foo', dd=dims, vv=collection_vars + data_vars)
_fake_complete(g)
return g
开发者ID:pp-mo,项目名称:ncobj,代码行数:33,代码来源:simple_semantic_containers.py
示例20: test_mixture
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'])
开发者ID:pp-mo,项目名称:ncobj,代码行数:7,代码来源:test_grouping.py
注:本文中的ncobj.shorts.og函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论