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

Python common.allequal函数代码示例

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

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



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

示例1: test03_read_float64

 def test03_read_float64(self):
     dtype = "float64"
     ds = getattr(self.fileh.root, dtype)
     self.assertFalse(isinstance(ds, UnImplemented))
     self.assertEqual(ds.shape, (self.ncols, self.nrows))
     self.assertEqual(ds.dtype, dtype)
     data = ds.read()
     common.allequal(data, self.values)
开发者ID:andreas-h,项目名称:PyTables,代码行数:8,代码来源:test_types.py


示例2: test01_read_float16

 def test01_read_float16(self):
     dtype = "float16"
     if hasattr(numpy, dtype):
         ds = getattr(self.fileh.root, dtype)
         self.assertFalse(isinstance(ds, UnImplemented))
         self.assertEqual(ds.shape, (self.ncols, self.nrows))
         self.assertEqual(ds.dtype, dtype)
         data = ds.read()
         common.allequal(data, self.values)
     else:
         ds = self.assertWarns(UserWarning, getattr, self.fileh.root, dtype)
         self.assertTrue(isinstance(ds, UnImplemented))
开发者ID:andreas-h,项目名称:PyTables,代码行数:12,代码来源:test_types.py


示例3: test08a_modifyingRows

    def test08a_modifyingRows(self):
        """Checking modifying just one row at once (using modifyRows)."""

        table = self.fileh.root.table
        # Read a chunk of the table
        chunk = table[3]
        # Modify it somewhat
        chunk.field('y')[:] = -1
        table.modifyRows(6, 7, 1, chunk)
        if self.close:
            self.fileh.close()
            self.fileh = openFile(self.file, "a")
            table = self.fileh.root.table
        # Check that some column has been actually modified
        ycol = zeros((2,2), 'Float64')-1
        data = table.cols.y[6]
        if common.verbose:
            print "Type of read:", type(data)
            print "First 3 elements of read:", data[:3]
            print "Length of the data read:", len(data)
        if common.verbose:
            print "ycol-->", ycol
            print "data-->", data
        # Check that both numarray objects are equal
        assert isinstance(data, NumArray)
        # Check the type
        assert data.type() == ycol.type()
        assert allequal(ycol, data, "numarray")
开发者ID:davem22101,项目名称:semanticscience,代码行数:28,代码来源:test_numarray.py


示例4: test01a_basicTableRead

    def test01a_basicTableRead(self):
        """Checking the return of a numarray in read()."""

        if self.close:
            self.fileh.close()
            self.fileh = openFile(self.file, "a")
        table = self.fileh.root.table
        data = table[:]
        if common.verbose:
            print "Type of read:", type(data)
            print "Formats of the record:", data._formats
            print "First 3 elements of read:", data[:3]
        # Check the type of the recarray
        assert isinstance(data, records.RecArray)
        # Check the value of some columns
        # A flat column
        col = table.cols.x[:3]
        assert isinstance(col, NumArray)
        npcol = zeros((3,2), type="Int32")
        if common.verbose:
            print "Plain column:"
            print "read column-->", col
            print "should look like-->", npcol
        assert allequal(col, npcol, "numarray")
        # A nested column
        col = table.cols.Info[:3]
        assert isinstance(col, records.RecArray)
        npcol = self._infozeros
        if common.verbose:
            print "Nested column:"
            print "read column-->", col
            print "should look like-->", npcol
        assert col.descr == npcol.descr
        assert str(col) == str(npcol)
开发者ID:davem22101,项目名称:semanticscience,代码行数:34,代码来源:test_numarray.py


示例5: test03_read_float64

 def test03_read_float64(self):
     dtype = "float64"
     ds = getattr(self.h5file.root, dtype)
     self.assertFalse(isinstance(ds, tables.UnImplemented))
     self.assertEqual(ds.shape, (self.nrows, self.ncols))
     self.assertEqual(ds.dtype, dtype)
     self.assertTrue(common.allequal(ds.read(), self.values.astype(dtype)))
开发者ID:arvindchari88,项目名称:newGitTest,代码行数:7,代码来源:test_types.py


示例6: test07b_modifyingRows

    def test07b_modifyingRows(self):
        """Checking modifying several rows at once (using cols accessor)."""

        table = self.fileh.root.table
        # Read a chunk of the table
        chunk = table[0:3]
        # Modify it somewhat
        chunk['y'][:] = -1
        table.cols[3:6] = chunk
        if self.close:
            self.fileh.close()
            self.fileh = openFile(self.file, "a")
            table = self.fileh.root.table
        # Check that some column has been actually modified
        ycol = zeros((3,2,2), 'float64')-1
        data = table.cols.y[3:6]
        if common.verbose:
            print "Type of read:", type(data)
            print "Description of the record:", data.dtype.descr
            print "First 3 elements of read:", data[:3]
            print "Length of the data read:", len(data)
        # Check that both NumPy objects are equal
        assert isinstance(data, ndarray)
        # Check the type
        assert data.dtype.descr == ycol.dtype.descr
        if common.verbose:
            print "ycol-->", ycol
            print "data-->", data
        assert allequal(ycol, data, "numpy")
开发者ID:ilustreous,项目名称:PyTables,代码行数:29,代码来源:test_numpy.py


示例7: test03b_Compare64EArray

    def test03b_Compare64EArray(self):
        "Comparing several written and read 64-bit time values in an EArray."

        # Create test EArray with data.
        h5file = tables.openFile(
                self.h5fname, 'w', title = "Test for comparing Time64 E arrays")
        ea = h5file.createEArray(
                '/', 'test', tables.Time64Atom(), shape=(0, 2))

        # Size of the test.
        nrows = ea.nrowsinbuf + 34  # Add some more rows than buffer.
        # Only for home checks; the value above should check better
        # the I/O with multiple buffers.
        ##nrows = 10

        for i in xrange(nrows):
            j = i * 2
            ea.append(((j + 0.012, j + 1 + 0.012),))
        h5file.close()

        # Check the written data.
        h5file = tables.openFile(self.h5fname)
        arr = h5file.root.test.read()
        h5file.close()

        orig_val = numpy.arange(0, nrows*2, dtype=numpy.int32) + 0.012
        orig_val.shape = (nrows, 2)
        if common.verbose:
            print "Original values:", orig_val
            print "Retrieved values:", arr
        self.assertTrue(allequal(arr, orig_val),
                        "Stored and retrieved values do not match.")
开发者ID:andreas-h,项目名称:PyTables,代码行数:32,代码来源:test_timetype.py


示例8: _test

    def _test(self):
        self.assert_("/test_var/structure variable" in self.h5file)

        tbl = self.h5file.getNode("/test_var/structure variable")
        self.assert_(isinstance(tbl, tables.Table))

        self.assertEqual(tbl.colnames, ["a", "b", "c", "d"])

        self.assertEqual(tbl.coltypes["a"], "float64")
        self.assertEqual(tbl.coldtypes["a"].shape, ())

        self.assertEqual(tbl.coltypes["b"], "float64")
        self.assertEqual(tbl.coldtypes["b"].shape, ())

        self.assertEqual(tbl.coltypes["c"], "float64")
        self.assertEqual(tbl.coldtypes["c"].shape, (2,))

        self.assertEqual(tbl.coltypes["d"], "string")
        self.assertEqual(tbl.coldtypes["d"].shape, ())

        for row in tbl.iterrows():
            self.assertEqual(row["a"], 3.0)
            self.assertEqual(row["b"], 4.0)
            self.assert_(allequal(row["c"], numpy.array([2.0, 3.0], dtype="float64")))
            self.assertEqual(row["d"], "d")

        self.h5file.close()
开发者ID:vkarthi46,项目名称:PyTables,代码行数:27,代码来源:test_hdf5compat.py


示例9: test02_readCoordsChar

    def test02_readCoordsChar(self):
        """Column conversion into Numeric in readCoords(). Chars"""

        table = self.fileh.root.table
        table.flavor = "numeric"
        coords = (1, 2, 3)
        self.nrows = len(coords)
        for colname in table.colnames:
            numcol = table.readCoordinates(coords, field=colname)
            typecol = table.coltypes[colname]
            itemsizecol = table.description._v_dtypes[colname].base.itemsize
            nctypecode = numcol.typecode()
            if typecol == "string":
                if itemsizecol > 1:
                    orignumcol = array(['abcd']*self.nrows, typecode='c')
                else:
                    orignumcol = array(['a']*self.nrows, typecode='c')
                    orignumcol.shape=(self.nrows,)
                if common.verbose:
                    print "Typecode of Numeric column read:", nctypecode
                    print "Should look like:", 'c'
                    print "Itemsize of column:", itemsizecol
                    print "Shape of Numeric column read:", numcol.shape
                    print "Should look like:", orignumcol.shape
                    print "First 3 elements of read col:", numcol[:3]
                # Check that both Numeric objects are equal
                self.assertTrue(allequal(numcol, orignumcol, "numeric"))
开发者ID:andreas-h,项目名称:PyTables,代码行数:27,代码来源:test_Numeric.py


示例10: test07a_modifyingRows

    def test07a_modifyingRows(self):
        """Checking modifying several rows at once (using modifyRows)."""

        table = self.fileh.root.table
        # Read a chunk of the table
        chunk = table[0:3]
        # Modify it somewhat
        chunk.field('y')[:] = -1
        table.modifyRows(3, 6, 1, rows=chunk)
        if self.close:
            self.fileh.close()
            self.fileh = openFile(self.file, "a")
            table = self.fileh.root.table
        ycol = zeros((3, 2, 2), 'Float64')-1
        data = table.cols.y[3:6]
        if common.verbose:
            print "Type of read:", type(data)
            print "First 3 elements of read:", data[:3]
            print "Length of the data read:", len(data)
        if common.verbose:
            print "ycol-->", ycol
            print "data-->", data
        # Check that both numarray objects are equal
        self.assertTrue(isinstance(data, NumArray))
        # Check the type
        self.assertEqual(data.type(), ycol.type())
        self.assertTrue(allequal(ycol, data, "numarray"))
开发者ID:andreas-h,项目名称:PyTables,代码行数:27,代码来源:test_numarray.py


示例11: test01b_Compare64VLArray

    def test01b_Compare64VLArray(self):
        "Comparing several written and read 64-bit time values in a VLArray."

        # Create test VLArray with data.
        h5file = tables.open_file(self.h5fname, "w", title="Test for comparing Time64 VL arrays")
        vla = h5file.create_vlarray("/", "test", self.myTime64Atom)

        # Size of the test.
        nrows = vla.nrowsinbuf + 34  # Add some more rows than buffer.
        # Only for home checks; the value above should check better
        # the I/O with multiple buffers.
        # nrows = 10

        for i in range(nrows):
            j = i * 2
            vla.append((j + 0.012, j + 1 + 0.012))
        h5file.close()

        # Check the written data.
        h5file = tables.open_file(self.h5fname)
        arr = h5file.root.test.read()
        h5file.close()

        arr = numpy.array(arr)
        orig_val = numpy.arange(0, nrows * 2, dtype=numpy.int32) + 0.012
        orig_val.shape = (nrows, 1, 2)
        if common.verbose:
            print("Original values:", orig_val)
            print("Retrieved values:", arr)
        self.assertTrue(allequal(arr, orig_val), "Stored and retrieved values do not match.")
开发者ID:alfonsodiecko,项目名称:PYTHON_DIST,代码行数:30,代码来源:test_timetype.py


示例12: _test

    def _test(self):
        self.assertTrue('/test_var/structure variable' in self.h5file)

        tbl = self.h5file.get_node('/test_var/structure variable')
        self.assertTrue(isinstance(tbl, tables.Table))

        self.assertEqual(
            tbl.colnames,
            ['a', 'b', 'c', 'd'])

        self.assertEqual(tbl.coltypes['a'], 'float64')
        self.assertEqual(tbl.coldtypes['a'].shape, ())

        self.assertEqual(tbl.coltypes['b'], 'float64')
        self.assertEqual(tbl.coldtypes['b'].shape, ())

        self.assertEqual(tbl.coltypes['c'], 'float64')
        self.assertEqual(tbl.coldtypes['c'].shape, (2,))

        self.assertEqual(tbl.coltypes['d'], 'string')
        self.assertEqual(tbl.coldtypes['d'].shape, ())

        for row in tbl.iterrows():
            self.assertEqual(row['a'], 3.0)
            self.assertEqual(row['b'], 4.0)
            self.assertTrue(allequal(row['c'], numpy.array([2.0, 3.0],
                                                           dtype="float64")))
            self.assertEqual(row['d'], b"d")

        self.h5file.close()
开发者ID:alfonsodiecko,项目名称:PYTHON_DIST,代码行数:30,代码来源:test_hdf5compat.py


示例13: test04_read_longdouble

    def test04_read_longdouble(self):
        dtype = "longdouble"
        if "Float96Atom" in globals() or "Float128Atom" in globals():
            ds = getattr(self.fileh.root, dtype)
            self.assertFalse(isinstance(ds, UnImplemented))
            self.assertEqual(ds.shape, (self.nrows, self.ncols))
            self.assertEqual(ds.dtype, dtype)
            self.assertTrue(common.allequal(
                ds.read(), self.values.astype(dtype)))

            if "Float96Atom" in globals():
                self.assertEqual(ds.dtype, "float96")
            elif "Float128Atom" in globals():
                self.assertEqual(ds.dtype, "float128")
        else:
            # XXX: check
            # the behavior depends on the HDF5 lib configuration
            try:
                ds = self.assertWarns(UserWarning,
                                      getattr, self.fileh.root, dtype)
                self.assertTrue(isinstance(ds, UnImplemented))
            except AssertionError:
                from tables.utilsextension import _broken_hdf5_long_double
                if not _broken_hdf5_long_double():
                    ds = getattr(self.fileh.root, dtype)
                    self.assertEqual(ds.dtype, "float64")
开发者ID:B-Rich,项目名称:PyTables,代码行数:26,代码来源:test_types.py


示例14: test08b_modifyingRows

    def test08b_modifyingRows(self):
        """Checking modifying just one row at once (using cols accessor)."""

        table = self.fileh.root.table
        # Read a chunk of the table
        chunk = table[3]
        # Modify it somewhat
        chunk['y'][:] = -1
        table.cols[6] = chunk
        if self.close:
            self.fileh.close()
            self.fileh = openFile(self.file, "a")
            table = self.fileh.root.table
        # Check that some column has been actually modified
        ycol = zeros((2, 2), 'Float64')-1
        data = table.cols.y[6]
        if common.verbose:
            print "Type of read:", type(data)
            print "First 3 elements of read:", data[:3]
            print "Length of the data read:", len(data)
        if common.verbose:
            print "ycol-->", ycol
            print "data-->", data
        # Check that both numarray objects are equal
        self.assertTrue(isinstance(data, NumArray))
        # Check the type
        self.assertEqual(data.type(), ycol.type())
        self.assertTrue(allequal(ycol, data, "numarray"))
开发者ID:andreas-h,项目名称:PyTables,代码行数:28,代码来源:test_numarray.py


示例15: test05b_modifyingColumns

    def test05b_modifyingColumns(self):
        """Checking modifying several columns at once."""

        table = self.fileh.root.table
        xcol = ones((3, 2), 'Int32')
        ycol = ones((3, 2, 2), 'Float64')
        zcol = zeros((3,), 'UInt8')
        table.modifyColumns(3, 6, 1, [xcol, ycol, zcol], ['x', 'y', 'z'])
        if self.close:
            self.fileh.close()
            self.fileh = openFile(self.file, "a")
            table = self.fileh.root.table
        data = table.cols.y[3:6]
        if common.verbose:
            print "Type of read:", type(data)
            print "First 3 elements of read:", data[:3]
            print "Length of the data read:", len(data)
        if common.verbose:
            print "ycol-->", ycol
            print "data-->", data
        # Check that both numarray objects are equal
        self.assertTrue(isinstance(data, NumArray))
        # Check the type
        self.assertEqual(data.type(), ycol.type())
        self.assertTrue(allequal(data, ycol, "numarray"))
开发者ID:andreas-h,项目名称:PyTables,代码行数:25,代码来源:test_numarray.py


示例16: test01b_basicTableRead

    def test01b_basicTableRead(self):
        """Checking the return of a numarray in read() (strided version)."""

        if self.close:
            self.fileh.close()
            self.fileh = openFile(self.file, "a")
        table = self.fileh.root.table
        data = table[::3]
        if common.verbose:
            print "Type of read:", type(data)
            print "Description of the record:", data.descr
            print "First 3 elements of read:", data[:3]
        # Check that both numarray objects are equal
        self.assertTrue(isinstance(data, records.RecArray))
        # Check the value of some columns
        # A flat column
        col = table.cols.x[:9:3]
        self.assertTrue(isinstance(col, NumArray))
        npcol = zeros((3, 2), dtype="Int32")
        if common.verbose:
            print "Plain column:"
            print "read column-->", col
            print "should look like-->", npcol
        self.assertTrue(allequal(col, npcol, "numarray"))
        # A nested column
        col = table.cols.Info[:9:3]
        self.assertTrue(isinstance(col, records.RecArray))
        npcol = self._infozeros
        if common.verbose:
            print "Nested column:"
            print "read column-->", col
            print "should look like-->", npcol
        self.assertEqual(col.descr, npcol.descr)
        self.assertEqual(str(col), str(npcol))
开发者ID:andreas-h,项目名称:PyTables,代码行数:34,代码来源:test_numarray.py


示例17: WriteRead

    def WriteRead(self, testArray):
        if common.verbose:
            print '\n', '-=' * 30
            print "Running test for array with typecode '%s'" % \
                  testArray.dtype.char,
            print "for class check:", self.title

        # Create an instance of HDF5 Table
        self.file = tempfile.mktemp(".h5")
        self.fileh = openFile(self.file, mode = "w")
        self.root = self.fileh.root
        # Create the array under root and name 'somearray'
        a = testArray
        self.fileh.createArray(self.root, 'somearray', a, "Some array")

        # Close the file
        self.fileh.close()

        # Re-open the file in read-only mode
        self.fileh = openFile(self.file, mode = "r")
        self.root = self.fileh.root

        # Read the saved array
        b = self.root.somearray.read()
        # For cases that read returns a python type instead of a numpy type
        if not hasattr(b, "shape"):
            b = array(b, dtype=a.dtype.str)

        # Compare them. They should be equal.
        #if not allequal(a,b, "numpy") and common.verbose:
        if common.verbose:
            print "Array written:", a
            print "Array written shape:", a.shape
            print "Array written itemsize:", a.itemsize
            print "Array written type:", a.dtype.char
            print "Array read:", b
            print "Array read shape:", b.shape
            print "Array read itemsize:", b.itemsize
            print "Array read type:", b.dtype.char

        type_ = self.root.somearray.atom.type
        # Check strictly the array equality
        assert type(a) == type(b)
        assert a.shape == b.shape
        assert a.shape == self.root.somearray.shape
        assert a.dtype == b.dtype
        if a.dtype.char[0] == "S":
            assert type_ == "string"
        else:
            assert a.dtype.base.name == type_

        assert allequal(a,b, "numpy")
        self.fileh.close()
        # Then, delete the file
        os.remove(self.file)
        return
开发者ID:ilustreous,项目名称:PyTables,代码行数:56,代码来源:test_numpy.py


示例18: test01_readAttr

    def test01_readAttr(self):
        """Checking backward compatibility of old formats for attributes."""

        if common.verbose:
            print('\n', '-=' * 30)
            print("Running %s.test01_readAttr..." % self.__class__.__name__)

        # Read old formats
        a = self.h5file.get_node("/a")
        scalar = numpy.array(1, dtype="int32")
        vector = numpy.array([1], dtype="int32")
        if self.format == "1.3":
            self.assertTrue(allequal(a.attrs.arrdim1, vector))
            self.assertTrue(allequal(a.attrs.arrscalar, scalar))
            self.assertEqual(a.attrs.pythonscalar, 1)
        elif self.format == "1.4":
            self.assertTrue(allequal(a.attrs.arrdim1, vector))
            self.assertTrue(allequal(a.attrs.arrscalar, scalar))
            self.assertTrue(allequal(a.attrs.pythonscalar, scalar))
开发者ID:ESSS,项目名称:PyTables,代码行数:19,代码来源:test_backcompat.py


示例19: test00_CompareTable

    def test00_CompareTable(self):
        "Comparing written unaligned time data with read data in a Table."

        # Create test Table with data.
        h5file = tables.openFile(
                self.h5fname, 'w', title = "Test for comparing Time tables")
        tbl = h5file.createTable('/', 'test', self.MyTimeRow)

        # Size of the test.
        nrows = tbl.nrowsinbuf + 34  # Add some more rows than buffer.
        # Only for home checks; the value above should check better
        # the I/O with multiple buffers.
        ##nrows = 10

        row = tbl.row
        for i in xrange(nrows):
            row['i8col']  = i
            row['t32col'] = i
            j = i * 2
            row['t64col'] = (j+0.012, j+1+0.012)
            row.append()
        h5file.close()

        # Check the written data.
        h5file = tables.openFile(self.h5fname)
        recarr = h5file.root.test.read()
        h5file.close()

        # Int8 column.
        orig_val = numpy.arange(nrows, dtype=numpy.int8)
        if common.verbose:
            print "Original values:", orig_val
            print "Retrieved values:", recarr['i8col'][:]
        self.assert_(
                numpy.alltrue(recarr['i8col'][:] == orig_val),
                "Stored and retrieved values do not match.")

        # Time32 column.
        orig_val = numpy.arange(nrows, dtype=numpy.int32)
        if common.verbose:
            print "Original values:", orig_val
            print "Retrieved values:", recarr['t32col'][:]
        self.assert_(
                numpy.alltrue(recarr['t32col'][:] == orig_val),
                "Stored and retrieved values do not match.")

        # Time64 column.
        orig_val = numpy.arange(0, nrows*2, dtype=numpy.int32) + 0.012
        orig_val.shape = (nrows, 2)
        if common.verbose:
            print "Original values:", orig_val
            print "Retrieved values:", recarr['t64col'][:]
        self.assert_(
            allequal(recarr['t64col'][:], orig_val, numpy.float64),
            "Stored and retrieved values do not match.")
开发者ID:ilustreous,项目名称:PyTables,代码行数:55,代码来源:test_timetype.py


示例20: test01_read_float16

 def test01_read_float16(self):
     dtype = "float16"
     if hasattr(numpy, dtype):
         ds = getattr(self.h5file.root, dtype)
         self.assertFalse(isinstance(ds, tables.UnImplemented))
         self.assertEqual(ds.shape, (self.nrows, self.ncols))
         self.assertEqual(ds.dtype, dtype)
         self.assertTrue(common.allequal(ds.read(), self.values.astype(dtype)))
     else:
         with self.assertWarns(UserWarning):
             ds = getattr(self.h5file.root, dtype)
         self.assertTrue(isinstance(ds, tables.UnImplemented))
开发者ID:arvindchari88,项目名称:newGitTest,代码行数:12,代码来源:test_types.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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