當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。