示例#1
0
 def test_09NodeDelete(self):
     import CGNS.PAT.cgnsutils as CGU
     import CGNS.PAT.cgnserrors as CGE
     import CGNS.PAT.cgnskeywords as CGK
     import numpy
     n = CGU.nodeCreate('Base', numpy.array([3, 3]), [], CGK.CGNSBase_ts)
     r = CGU.nodeCreate('ReferenceState', None, [], CGK.ReferenceState_ts, parent=n)
     d = CGU.nodeCreate('Data', numpy.array([3.14]), [], CGK.DataArray_ts, parent=r)
     self.assertIsNotNone(CGU.hasChildName(r, 'Data'))
     CGU.nodeDelete(n, d)
     self.assertIsNone(CGU.hasChildName(r, 'Data'))
     d = CGU.nodeCreate('DataZ', numpy.array([3.14]), [], CGK.DataArray_ts, parent=r)
     self.assertIsNotNone(CGU.hasChildName(r, 'DataZ'))
     CGU.nodeDelete(r, d)
     self.assertIsNone(CGU.hasChildName(r, 'DataZ'))
     CGU.nodeDelete(r, d)
     self.assertIsNone(CGU.hasChildName(r, 'DataZ'))
     n = CGU.nodeCreate('Base', numpy.array([3, 3]), [], CGK.CGNSBase_ts)
     r = CGU.nodeCreate('ReferenceState', None, [], CGK.ReferenceState_ts, parent=n)
     d = CGU.nodeCreate('Data', numpy.array([3.14]), [], CGK.DataArray_ts, parent=r)
     self.assertIsNotNone(CGU.getNodeByPath(n, '/Base/ReferenceState/Data'))
     CGU.nodeDelete(n, d)
     self.assertIsNone(CGU.hasChildName(r, 'Data'))
     n = CGU.nodeCreate('Base', numpy.array([3, 3]), [], CGK.CGNSBase_ts)
     r = CGU.nodeCreate('ReferenceState', None, [], CGK.ReferenceState_ts, parent=n)
     d = CGU.nodeCreate('Data', numpy.array([3.14]), [], CGK.DataArray_ts, parent=r)
     self.assertIsNotNone(CGU.getNodeByPath(n, '/Base/ReferenceState/Data'))
     CGU.removeChildByName(r, 'Data')
     self.assertIsNone(CGU.hasChildName(r, 'Data'))
示例#2
0
 def test_07NodeCompliance(self):
     import CGNS.PAT.cgnsutils as CGU
     import CGNS.PAT.cgnserrors as CGE
     import CGNS.PAT.cgnskeywords as CGK
     import numpy
     n = CGU.nodeCreate('Base', numpy.array([3, 3]), [], CGK.CGNSBase_ts)
     z = CGU.nodeCreate('ReferenceState', None, [], CGK.ReferenceState_ts, parent=n)
     self.assertTrue(CGU.checkNodeCompliant(n, None))
     self.assertTrue(CGU.checkNodeCompliant(z, None))
     self.assertTrue(CGU.checkNodeCompliant(z, n, dienow=True))
     self.assertFalse(CGU.checkNodeCompliant(None, n))
示例#3
0
 def test_04NodeChildren(self):
     import CGNS.PAT.cgnsutils as CGU
     import CGNS.PAT.cgnslib as CGL
     import CGNS.PAT.cgnserrors as CGE
     import CGNS.PAT.cgnskeywords as CGK
     A = ['A', None, [], None]
     B = ['B', None, [], None]
     C = ['C', None, [], None]
     A[2] += [B]
     CGU.setAsChild(A, C)
     self.assertTrue(CGU.hasChildName(A, 'B'))
     self.assertTrue(CGU.hasChildName(A, 'C'))
     self.assertTrue(CGU.checkDuplicatedName(A, 'D'))
     self.assertFalse(CGU.checkHasChildName(A, 'D'))
     D = CGU.nodeCreate('D', None, [], None, parent=A)
     self.assertFalse(CGU.checkDuplicatedName(A, 'D'))
     self.assertTrue(CGU.checkHasChildName(A, 'D'))
     self.assertFalse(CGU.checkNodeType(C))
     d = {
         'None': None,
         'String': 'string value',
         'Integer': 10,
         'Float': 1.4
     }
     for n, v in d.items():
         CGL.newDataArray(A, n, v)
     for name in d.keys():
         self.assertTrue(CGU.hasChildName(A, name))
示例#4
0
 def test_03NodeStructure(self):
     import CGNS.PAT.cgnsutils as CGU
     import CGNS.PAT.cgnserrors as CGE
     import CGNS.PAT.cgnskeywords as CGK
     self.assertEqual(['N1', None, [], 'N_t'], CGU.nodeCreate('N1', None, [], 'N_t'))
     p = CGU.nodeCreate('N1', None, [], 'N_t')
     self.assertEqual(['N1', None, [], 'N_t'], CGU.nodeCreate('N1', None, [], 'N_t', p))
     self.assertEqual(['N1', None, [], 'N_t'], p[2][0])
     n = CGU.nodeCreate('N2', None, [], 'N_t', p)
     self.assertNotEqual(['N1', None, [], 'N_t'], p[2][1])
     self.assertIs(n, p[2][1])
     self.assertEqual(['N2', None, [], 'N_t'], CGU.nodeCopy(n))
     c = CGU.nodeCopy(n)
     self.assertIsNot(n, c)
     cname = 'NCopy'
     c = CGU.nodeCopy(n, cname)
     self.assertEqual(c[0], cname)
     del n
     self.assertEqual(c[0], cname)