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


Python common.areArraysEqual函数代码示例

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


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

示例1: testGetNestedField

    def testGetNestedField(self):
        """Check the NestedRecArray.field method.
        """

        nra0 = nra.array(descr=self.descr, buffer=self.buffer)

        # Test top level nested fields
        # The info field
        buffer = [
            [('Paco', 'Perez'), (10, 20, 30)],
            [('Maria', 'Luisa'), (0, 2.0, 10)],
            [('C3Peanut', 'Tofu'), (10, 30, 20)]
        ]
        my_descr = [('name', [('first','a9'), ('second','a9')]),
            ('coord', [('x','Float32'), ('y', 'f4'), ('z', 'f4')])]
        model = nra.array(buffer, descr=my_descr)
        modelFirst = model.field('name/first')

        nra1 = nra0.field('info')
        nra1First = nra1.field('name/first')
        nra2 = nra1.field('name')
        nra3=nra2.field('first')

        self.assert_(common.areArraysEqual(model, nra1))
        self.assert_(common.areArraysEqual(modelFirst, nra1First))
        self.assert_(common.areArraysEqual(modelFirst, nra3))
开发者ID:87,项目名称:PyTables,代码行数:26,代码来源:test_nestedrecords.py

示例2: test02_NestedRecArrayCompat

    def test02_NestedRecArrayCompat(self):
        """Creating a compatible nested record array``."""

        tbl = self.h5file.create_table("/", "test", self._TestTDescr, title=self._getMethodName())

        nrarr = numpy.array(testABuffer, dtype=tbl.description._v_nested_descr)
        self.assertTrue(common.areArraysEqual(nrarr, self._testAData), "Can not create a compatible structured array.")
开发者ID:B-Rich,项目名称:PyTables,代码行数:7,代码来源:test_nestedtypes.py

示例3: test06_modifyRows

    def test06_modifyRows(self):
        "Checking modifying several rows at once (using nestedrecarray)"

        tbl = self.h5file.createTable(
            '/', 'test', self._TestTDescr, title=self._getMethodName())
        tbl.append(self._testAData)
        tbl.flush()

        # Get the nested record and swap the first and last rows.
        raTable = self._testAData.copy()
        (raTable[0], raTable[-1]) = (raTable[-1].copy(), raTable[0].copy())

        # Write the resulting nested record and re-read the whole table.
        tbl.modifyRows(start=0, stop=2, rows=raTable)
        tbl.flush()

        if self.reopen:
            self._reopen()
            tbl = self.h5file.root.test

        raReadTable = tbl.read()
        if common.verbose:
            print "Table read:", raReadTable
            print "Should look like:", raTable

        # Compare it to the written one.
        self.assert_(common.areArraysEqual(raTable, raReadTable),
                     "Written and read values differ.")
开发者ID:ilustreous,项目名称:PyTables,代码行数:28,代码来源:test_nestedtypes.py

示例4: _test

    def _test(self):
        self.assert_("/ExtendibleArray" in self.h5file)

        arr = self.h5file.getNode("/ExtendibleArray")
        self.assert_(isinstance(arr, tables.EArray))

        self.assertEqual(arr.byteorder, "big")
        self.assertEqual(arr.atom.type, "int32")
        self.assertEqual(arr.shape, (10, 5))
        self.assertEqual(arr.extdim, 0)
        self.assertEqual(len(arr), 10)

        data = arr.read()
        expectedData = numpy.array(
            [
                [1, 1, 1, 3, 3],
                [1, 1, 1, 3, 3],
                [1, 1, 1, 0, 0],
                [2, 0, 0, 0, 0],
                [2, 0, 0, 0, 0],
                [2, 0, 0, 0, 0],
                [2, 0, 0, 0, 0],
                [2, 0, 0, 0, 0],
                [2, 0, 0, 0, 0],
                [2, 0, 0, 0, 0],
            ],
            dtype=arr.atom.type,
        )

        self.assert_(common.areArraysEqual(data, expectedData))
开发者ID:vkarthi46,项目名称:PyTables,代码行数:30,代码来源:test_hdf5compat.py

示例5: test_ref_utf_str

    def test_ref_utf_str(self):
        array = self.h5file.get_node('/ANN/my_arr')

        self.assertTrue(common.areArraysEqual(
                        array[0][0][0],
                        numpy.array([0, 0],
                                    dtype=numpy.uint64)))
开发者ID:FrancescAlted,项目名称:PyTables,代码行数:7,代码来源:test_hdf5compat.py

示例6: testNRAFromRA

    def testNRAFromRA(self):
        """Check the array function with a RecArray instance.
        """

        buffer_ = [('Cuke', 123, (45, 67)), ('Tader', 321, (76, 54))]
        names = ['name', 'value', 'pair']
        formats = ['a6', 'Int8', '(2,)Int16']
        ra = numarray.records.array(
            buffer_, names=names, formats=formats)
##            buffer_, names=names, formats=formats, aligned=True)

        names1 = ['newName', 'newValue', 'newPair']
        nra0 = nra.array(buffer=ra, descr=zip(names1, formats))
        nra1 = nra.array(buffer=buffer_, descr=zip(names1, formats))
        self.assert_(common.areArraysEqual(nra0, nra1))

        # Bad number of fields
        badFormats = ['Int8', '(2,)Int16']
        self.assertRaises(ValueError, nra.array, buffer=ra,
            formats=badFormats)

        # Bad format in the first field
        badFormats = ['a9', 'Int8', '(2,)Int16']
        self.assertRaises(ValueError, nra.array, buffer=ra,
            formats=badFormats)
开发者ID:87,项目名称:PyTables,代码行数:25,代码来源:test_nestedrecords.py

示例7: test_ref_str

    def test_ref_str(self):
        array = self.h5file.get_node('/var')

        self.assertTrue(common.areArraysEqual(
                        array[1][0][0],
                        numpy.array([[116], [101], [115], [116]],
                                    dtype=numpy.uint16)))
开发者ID:FrancescAlted,项目名称:PyTables,代码行数:7,代码来源:test_hdf5compat.py

示例8: testNRAFromNRA

    def testNRAFromNRA(self):
        """Check the array function with a NestedRecArray instance.
        """

        nra0 = nra.array(buffer=self.buffer, descr=self.descr)
        my_Descr = [('ID', 'Int64'),
            ('data', [('name', [('first','a9'), ('second','a9')]),
            ('coord', [('x','Float32'), ('y', 'f4'), ('z', 'f4')])])]
        nra1 = nra.array(buffer=self.buffer, descr=my_Descr)
        nra2 = nra.array(buffer=nra0, descr=my_Descr)
        self.assert_(common.areArraysEqual(nra2, nra1))

        # Bad number of fields
        badDescr = [
            ('data', [('name', [('first','a9'), ('second','a9')]),
            ('coord', [('x','Float32'), ('y', 'f4'), ('z', 'f4')])])]
        self.assertRaises(ValueError, nra.array, buffer=nra0,
            descr=badDescr)

        # Bad format in the first field
        badDescr = [('ID', 'b1'),
            ('data', [('name', [('first','a9'), ('second','a9')]),
            ('coord', [('x','Float32'), ('y', 'f4'), ('z', 'f4')])])]
        self.assertRaises(ValueError, nra.array, buffer=nra0,
            descr=badDescr)
开发者ID:87,项目名称:PyTables,代码行数:25,代码来源:test_nestedrecords.py

示例9: test04_modifyColumn

    def test04_modifyColumn(self):
        """Modifying one single nested column (modifyColumn)."""

        tbl = self.h5file.createTable(
            '/', 'test', self._TestTDescr, title=self._getMethodName())
        tbl.append(self._testAData)
        tbl.flush()

        nColumn = self._testNestedCol
        # Get the nested column data and swap the first and last rows.
        raTable = self._testAData.copy()
        raColumn = raTable[nColumn]
        # The next will not work until NestedRecords supports copies
        (raColumn[0], raColumn[-1]) = (raColumn[-1], raColumn[0])

        # Write the resulting column and re-read the whole table.
        tbl.modifyColumn(colname=nColumn, column=raColumn)
        tbl.flush()

        if self.reopen:
            self._reopen()
            tbl = self.h5file.root.test

        raReadTable = tbl.read()
        if common.verbose:
            print "Table read:", raReadTable
            print "Should look like:", raTable

        # Compare it to the written one.
        self.assert_(common.areArraysEqual(raTable, raReadTable),
                     "Written and read values differ.")
开发者ID:ilustreous,项目名称:PyTables,代码行数:31,代码来源:test_nestedtypes.py

示例10: _test

    def _test(self):
        self.assertTrue('/ExtendibleArray' in self.h5file)

        arr = self.h5file.get_node('/ExtendibleArray')
        self.assertTrue(isinstance(arr, tables.EArray))

        self.assertEqual(arr.byteorder, 'big')
        self.assertEqual(arr.atom.type, 'int32')
        self.assertEqual(arr.shape, (10, 5))
        self.assertEqual(arr.extdim, 0)
        self.assertEqual(len(arr), 10)

        data = arr.read()
        expectedData = numpy.array([
            [1, 1, 1, 3, 3],
            [1, 1, 1, 3, 3],
            [1, 1, 1, 0, 0],
            [2, 0, 0, 0, 0],
            [2, 0, 0, 0, 0],
            [2, 0, 0, 0, 0],
            [2, 0, 0, 0, 0],
            [2, 0, 0, 0, 0],
            [2, 0, 0, 0, 0],
            [2, 0, 0, 0, 0]], dtype=arr.atom.type)

        self.assertTrue(common.areArraysEqual(data, expectedData))
开发者ID:alfonsodiecko,项目名称:PYTHON_DIST,代码行数:26,代码来源:test_hdf5compat.py

示例11: test05a_modifyColumns

    def test05a_modifyColumns(self):
        """Modifying one nested column (modifyColumns)."""

        tbl = self.h5file.createTable(
            '/', 'test', self._TestTDescr, title=self._getMethodName())
        tbl.append(self._testAData)
        tbl.flush()

        nColumn = self._testNestedCol
        # Get the nested column data and swap the first and last rows.
        raTable = self._testAData.copy()
        raColumn = raTable[nColumn]
        (raColumn[0], raColumn[-1]) = (raColumn[-1].copy(), raColumn[0].copy())
        newdtype = numpy.dtype([(nColumn, raTable.dtype.fields[nColumn][0])])

        # Write the resulting column and re-read the whole table.
        tbl.modifyColumns(names=[nColumn], columns=raColumn)
        tbl.flush()

        if self.reopen:
            self._reopen()
            tbl = self.h5file.root.test

        raReadTable = tbl.read()
        if common.verbose:
            print "Table read:", raReadTable
            print "Should look like:", raTable

        # Compare it to the written one.
        self.assert_(common.areArraysEqual(raTable, raReadTable),
                     "Written and read values differ.")
开发者ID:ilustreous,项目名称:PyTables,代码行数:31,代码来源:test_nestedtypes.py

示例12: test05b_modifyColumns

    def test05b_modifyColumns(self):
        """Modifying two nested columns (modify_columns)."""

        tbl = self.h5file.create_table("/", "test", self._TestTDescr, title=self._getMethodName())
        tbl.append(self._testAData)
        tbl.flush()

        # Get the nested column data and swap the first and last rows.
        colnames = ["x", "color"]  # Get the first two columns
        raCols = numpy.rec.fromarrays(
            [self._testAData["x"].copy(), self._testAData["color"].copy()], dtype=[("x", "(2,)i4"), ("color", "1a2")]
        )
        # descr=tbl.description._v_nested_descr[0:2])
        # or...
        # names=tbl.description._v_nested_names[0:2],
        # formats=tbl.description._v_nested_formats[0:2])
        (raCols[0], raCols[-1]) = (raCols[-1].copy(), raCols[0].copy())

        # Write the resulting columns
        tbl.modify_columns(names=colnames, columns=raCols)
        tbl.flush()

        if self.reopen:
            self._reopen()
            tbl = self.h5file.root.test

        # Re-read the appropriate columns
        raCols2 = numpy.rec.fromarrays([tbl.cols._f_col("x"), tbl.cols._f_col("color")], dtype=raCols.dtype)
        if common.verbose:
            print("Table read:", raCols2)
            print("Should look like:", raCols)

        # Compare it to the written one.
        self.assertTrue(common.areArraysEqual(raCols, raCols2), "Written and read values differ.")
开发者ID:B-Rich,项目名称:PyTables,代码行数:34,代码来源:test_nestedtypes.py

示例13: test02_NestedRecArrayCompat

    def test02_NestedRecArrayCompat(self):
        """Creating a compatible ``NestedRecArray``."""

        tbl = self.h5file.createTable(
            '/', 'test', self._TestTDescr, title=self._getMethodName())

        nrarr = numpy.array(testABuffer, dtype=tbl.description._v_nestedDescr)
        self.assert_(common.areArraysEqual(nrarr, self._testAData),
                     "Can not create a compatible record array.")
开发者ID:ilustreous,项目名称:PyTables,代码行数:9,代码来源:test_nestedtypes.py

示例14: testNRAFromArrayList

    def testNRAFromArrayList(self):
        """Check the fromarrays function.
        """

        # arrayList argument is a list of lists
        nra0 = nra.array(buffer=self.buffer, descr=self.descr)
        nra1 = nra.fromarrays(self.array_list, formats=self.formats)
        nra2 = nra.fromarrays(self.array_list,
            formats=self.formats, names=self.names)
        nra3 = nra.fromarrays(self.array_list, descr=self.descr)

        self.assertEqual(common.areArraysEqual(nra1, nra2), False)
        self.assert_(common.areArraysEqual(nra2, nra3))
        self.assert_(common.areArraysEqual(nra0, nra2))

        # arrayList argument is a list of NestedRecArrays
        nra0 = nra.array(buffer=[[1,4],[2,4]], formats=['f8','f4'])
        self.assertRaises(TypeError, nra.fromarrays,
            [nra0, nra0.field('c2')], formats=[['f8','f4'],'f4'])
开发者ID:87,项目名称:PyTables,代码行数:19,代码来源:test_nestedrecords.py

示例15: testGetBottomLevelField

    def testGetBottomLevelField(self):
        """Check the NestedRecArray.field method.
        """

        nra0 = nra.array(descr=self.descr, buffer=self.buffer)

        # Test bottom level fields
        nra1 = nra0.field('info/coord/x')
        ra1 = numarray.array([10, 0, 10], type='Float32')
        self.assert_(common.areArraysEqual(nra1, ra1))
开发者ID:87,项目名称:PyTables,代码行数:10,代码来源:test_nestedrecords.py


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