当前位置: 首页>>代码示例>>Python>>正文


Python conduit.Node类代码示例

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


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

示例1: test_fetch

 def test_fetch(self):
     vec = array(range(100), uint32)
     n = Node()
     n['a'] = vec
     na = n.fetch('a')
     na_val = na.value()
     self.assertEqual(na_val[99], 99)
开发者ID:fedepad,项目名称:conduit,代码行数:7,代码来源:t_python_conduit_node.py

示例2: test_info

 def test_info(self):
     n = Node()
     n['a'] = 1
     n['b'] = 2
     n['c'] = 3
     ni = n.info();
     #print ni
     self.assertEqual(ni["total_bytes"],n.total_bytes())
开发者ID:fedepad,项目名称:conduit,代码行数:8,代码来源:t_python_conduit_node.py

示例3: test_child

 def test_child(self):
     vec = array(range(100), uint32)
     n = Node()
     n['a'] = vec
     na = n.child(0)
     na_val = na.value()
     self.assertEqual(na_val[99], 99)
     n['b'] = vec
     self.assertEqual(n.number_of_children(),2)
开发者ID:fedepad,项目名称:conduit,代码行数:9,代码来源:t_python_conduit_node.py

示例4: test_total_bytes

 def test_total_bytes(self):
     vec = array(range(100), uint32)
     n = Node()
     n['a'] = vec
     self.assertEqual(n.total_bytes(),4 * 100)
     self.assertEqual(n.total_bytes_compact(),4 * 100)
     # TODO: check if n.is_compact() should pass as well?
     # it doesn't currently
     self.assertTrue(n.fetch('a').is_compact())
开发者ID:fedepad,项目名称:conduit,代码行数:9,代码来源:t_python_conduit_node.py

示例5: test_paths

 def test_paths(self):
     n = Node()
     n['a'] = 1
     n['b'] = 2
     n['c'] = 3
     for v in ['a','b','c']:
         self.assertTrue(n.has_path(v))
     paths = n.paths()
     for v in ['a','b','c']:
         self.assertTrue(v in paths)
开发者ID:fedepad,项目名称:conduit,代码行数:10,代码来源:t_python_conduit_node.py

示例6: test_create_node_using_schema_object

 def test_create_node_using_schema_object(self):
     s = Schema()
     s["a"] = DataType.float64(10)
     s["b"] = DataType.float32(10)
     n = Node()
     n.set(s)
     sr = n.schema()
     self.assertEqual(sr.total_strided_bytes(), 8 * 10 + 4 * 10)
     self.assertEqual(sr["a"].total_strided_bytes(),8 * 10)
     self.assertEqual(sr["b"].total_strided_bytes(),4 * 10)
开发者ID:LLNL,项目名称:conduit,代码行数:10,代码来源:t_python_conduit_schema.py

示例7: test_simple

 def test_simple(self):
     a_val = uint32(10)
     b_val = uint32(20)
     c_val = float64(30.0)
     n = Node()
     n['a'] = a_val
     n['b'] = b_val
     n['c'] = c_val
     s = n.schema();
     self.assertEqual(s.total_strided_bytes(),16)
开发者ID:LLNL,项目名称:conduit,代码行数:10,代码来源:t_python_conduit_schema.py

示例8: test_simple

    def test_simple(self):
        a_val = uint32(10)
        b_val = uint32(20)
        c_val = float64(30.0)

        n = Node()
        n['a'] = a_val
        n['b'] = b_val
        n['c'] = c_val
        print(n)
        d = n.fetch('a').dtype()
        self.assertEqual(d.id(),DataType.name_to_id("uint32"))
        print(d)
开发者ID:fedepad,项目名称:conduit,代码行数:13,代码来源:t_python_conduit_datatype.py

示例9: test_remove

 def test_remove(self):
     n = Node()
     n['a'] = 1
     n['b'] = 2
     n['c'] = 3
     self.assertEqual(n.number_of_children(),3)
     n.remove(path='c')
     self.assertEqual(n.number_of_children(),2)
     paths = n.paths()
     for v in ['a','b']:
         self.assertTrue(v in paths)
     n.remove(index=0)
     paths = n.paths()
     for v in ['b']:
         self.assertTrue(v in paths)
开发者ID:fedepad,项目名称:conduit,代码行数:15,代码来源:t_python_conduit_node.py

示例10: test_base64

 def test_base64(self):
     n = default_node()
     print(n)
     n_schema = n.to_json("base64_json");
     print("result base64 json", n_schema)
     g = Generator(n_schema,"base64_json");
     ng = Node();
     g.walk(node=ng);
     print("Generator result")
     print(ng)
     for p in ["a","b","c"]:
         orig = n.fetch(p).value()
         curr = ng.fetch(p).value()
         print(ng)
         print(p, orig, curr)
         orig = n[p]
         curr = ng[p]
         print(ng)
         print(p, orig, curr)
         self.assertEqual(orig,curr)
开发者ID:gzagaris,项目名称:conduit,代码行数:20,代码来源:t_python_conduit_generator.py

示例11: test_set_external

 def test_set_external(self):
     types = ['uint8', 'uint16', 'uint32', 'uint64', 'float32', 'float64']
     for type in types:
         ext_data = array(range(10), dtype=type)
         n = Node()
         n.set_external(ext_data)
         for i in range(len(ext_data)):
             self.assertEqual(n.value()[i], ext_data[i])
         ext_data[5] = 11
         n.value()[8] = 77
         n.value()[2] = 8
         for i in range(len(ext_data)):
             self.assertEqual(n.value()[i], ext_data[i])
开发者ID:fedepad,项目名称:conduit,代码行数:13,代码来源:t_python_conduit_node.py

示例12: test_simple

 def test_simple(self):
     n = default_node()
     n_schema = n.to_json("conduit");
     print("result detailed json", n_schema)
     g = Generator(json_schema=n_schema);
     ng = Node();
     sg = Schema()
     g.walk(node=ng);
     g.walk(schema=sg);
     print(ng)
     print(sg)
     for p in ["a","b","c"]:
         orig = n.fetch(p).value()
         curr = ng.fetch(p).value()
         print(ng)
         print(p, orig, curr)
         orig = n[p]
         curr = ng[p]
         print(ng)
         print(p, orig, curr)
         self.assertEqual(orig,curr)
开发者ID:gzagaris,项目名称:conduit,代码行数:21,代码来源:t_python_conduit_generator.py

示例13: test_list

 def test_list(self):
     n = Node()
     n.append().set(1)
     self.assertTrue(n.child(0).value(),1)
     # TODO: this needs to work but doesn't
     #self.assertTrue(n[0],1)
     n2 = Node()
     n2_c = n2.append()
     n2_c.set(2)
     self.assertEqual(n2.child(0).value(),2)
开发者ID:fedepad,项目名称:conduit,代码行数:10,代码来源:t_python_conduit_node.py

示例14: test_set_external_basic_slice

 def test_set_external_basic_slice(self):
     types = ['uint8', 'uint16', 'uint32', 'uint64', 'float32', 'float64']
     for type in types:
         base_data = array(range(20), dtype=type)
         ext_data  = base_data[1:16]
         n = Node()
         n.set_external(ext_data)
         for i in range(len(ext_data)):
             self.assertEqual(n.value()[i], ext_data[i])
         ext_data[5] = 11
         n.value()[6] = 77
         n.value()[2] = 8
         for i in range(len(ext_data)):
             self.assertEqual(n.value()[i], ext_data[i])
开发者ID:fedepad,项目名称:conduit,代码行数:14,代码来源:t_python_conduit_node.py

示例15: test_simple

    def test_simple(self):
        a_val = uint32(10)
        b_val = uint32(20)
        c_val = float64(30.0)

        n = Node()
        n["a"] = a_val
        n["b"] = b_val
        n["c"] = c_val

        itr = NodeIterator()
        self.assertFalse(itr.has_next())
        itr = n.children()
        self.assertTrue(itr.has_next())
        print(itr.has_next())
        for v in itr:
            print(v.name(), v.node())
            idx = v.index()
            if idx == 0:
                self.assertEqual(v.node().value(), a_val)
            elif idx == 1:
                self.assertEqual(v.node().value(), b_val)
            elif idx == 2:
                self.assertEqual(v.node().value(), c_val)
开发者ID:LLNL,项目名称:conduit,代码行数:24,代码来源:t_python_conduit_node_iterator.py


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