• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python shorts.ov函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中ncobj.shorts.ov函数的典型用法代码示例。如果您正苦于以下问题:Python ov函数的具体用法?Python ov怎么用?Python ov使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ov函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _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


示例2: 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


示例3: 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


示例4: 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


示例5: 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


示例6: test_fail_nomatch

 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'])
开发者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_fail_conflicting_data_shapes

 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'])
开发者ID:pp-mo,项目名称:ncobj,代码行数:9,代码来源:test_grouping.py


示例10: test_multiple

 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)
开发者ID:pp-mo,项目名称:ncobj,代码行数:10,代码来源:test_grouping.py


示例11: test_unlimited

 def test_unlimited(self):
     g = og('', vv=[ov('v1', dd=[od('x', 2, u=True)]),
                    ov('v2', dd=[od('x', 2)])])
     self.assertEqual(all_dimensions(g), [])
     self.assertEqual(g.variables['v2'].dimensions[0], od('x', 2))
     self.do_complete(g)
     self.assertNotEqual(g.variables['v2'].dimensions[0], od('x', 2))
     self.assertEqual(list(g.dimensions), [od('x', 2, u=True)])
     test_dim = g.dimensions['x']
     self.assertIs(g.variables['v1'].dimensions[0], test_dim)
     self.assertIs(g.variables['v2'].dimensions[0], test_dim)
开发者ID:pp-mo,项目名称:ncobj,代码行数:11,代码来源:test_grouping.py


示例12: 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


示例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_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


示例15: 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


示例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_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


示例18: test_fail_error

 def test_fail_error(self):
     g = og('', vv=[ov('v', dd=[od('x')])])
     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 "/v"', 'dimension "x"', 'no definition exists'])
开发者ID:pp-mo,项目名称:ncobj,代码行数:7,代码来源:test_grouping.py


示例19: 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


示例20: 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



注:本文中的ncobj.shorts.ov函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python ncpol2sdpa.SdpRelaxation类代码示例发布时间:2022-05-27
下一篇:
Python shorts.og函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap