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

Python common.areArraysEqual函数代码示例

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

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



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


示例16: test03_NRA

    def test03_NRA(self):
        """Creating a table from a nested record array object."""

        tbl = self.h5file.create_table("/", "test", self._testAData, title=self._getMethodName())
        tbl.flush()
        readAData = tbl.read()
        if common.verbose:
            print("Read data:", readAData)
            print("Should look like:", self._testAData)
        self.assertTrue(common.areArraysEqual(self._testAData, readAData), "Written and read values differ.")
开发者ID:B-Rich,项目名称:PyTables,代码行数:10,代码来源:test_nestedtypes.py


示例17: testGetTopLevelFlatField

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

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

        # Test top level flat fields
        nra1 = nra0.field('position')
        ra1 = numarray.array([1, 2, 3], type='Int64')
        self.assert_(common.areArraysEqual(nra1, ra1))
开发者ID:87,项目名称:PyTables,代码行数:10,代码来源:test_nestedrecords.py


示例18: testNestedRecordCreation

    def testNestedRecordCreation(self):
        """Check the creation of NestedRecord instances from NestedRecArrays.
        """

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

        nrecord = nra0[0]
        self.assert_(isinstance(nrecord, nra.NestedRecord))
        self.assert_(common.areArraysEqual(nra0, nrecord.array))
        self.assertEqual(nrecord.row, 0)
开发者ID:87,项目名称:PyTables,代码行数:10,代码来源:test_nestedrecords.py


示例19: test04_NRA2

    def test04_NRA2(self):
        """Creating a table from a generated nested record array object."""

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

        tbl2 = self.h5file.create_table("/", "test2", readAData, title=self._getMethodName())
        readAData2 = tbl2.read()

        self.assertTrue(common.areArraysEqual(self._testAData, readAData2), "Written and read values differ.")
开发者ID:B-Rich,项目名称:PyTables,代码行数:11,代码来源:test_nestedtypes.py


示例20: testFlattenNestedRecord

    def testFlattenNestedRecord(self):
        """Check the flattening of NestedRecord instances.
        """

        nra0 = nra.array(descr=self.descr, buffer=self.buffer)
        nrecord = nra0[0]
        frecord = nrecord.asRecord()

        self.assert_(isinstance(frecord, numarray.records.Record))
        self.assert_(common.areArraysEqual(nra0.asRecArray(), frecord.array))
        self.assertEqual(nrecord.row, frecord.row)
开发者ID:87,项目名称:PyTables,代码行数:11,代码来源:test_nestedrecords.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python common.verbosePrint函数代码示例发布时间:2022-05-27
下一篇:
Python common.allequal函数代码示例发布时间: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