コード例 #1
0
    def testSC(self):
        """test that datasets are unchanged after various compression/decompressions"""

        obt_np = compression.decByteOffset_numpy(compression.compByteOffset_numpy(self.ds))
        self.assertEqual(abs(self.ds - obt_np).max(), 0.0, "numpy-numpy algo")
        obt_cy = compression.decByteOffset_cython(compression.compByteOffset_numpy(self.ds))
        self.assertEqual(abs(self.ds - obt_cy).max(), 0.0, "cython-numpy algo")
        obt_cy2 = compression.decByteOffset_cython(compression.compByteOffset_numpy(self.ds), self.ds.size)
        self.assertEqual(abs(self.ds - obt_cy2).max(), 0.0, "cython2-numpy algo_orig")

        obt_np = compression.decByteOffset_numpy(compression.compByteOffset_cython(self.ds))
        self.assertEqual(abs(self.ds - obt_np).max(), 0.0, "numpy-numpy algo")
        obt_cy = compression.decByteOffset_cython(compression.compByteOffset_cython(self.ds))
        self.assertEqual(abs(self.ds - obt_cy).max(), 0.0, "cython-numpy algo")
        obt_cy2 = compression.decByteOffset_cython(compression.compByteOffset_cython(self.ds), self.ds.size)
        self.assertEqual(abs(self.ds - obt_cy2).max(), 0.0, "cython2-numpy algo_orig")
コード例 #2
0
ファイル: testcompression.py プロジェクト: vallsv/fabio
    def testSC(self):
        """test that datasets are unchanged after various compression/decompressions"""

        obt_np = compression.decByteOffset_numpy(compression.compByteOffset_numpy(self.ds))
        self.assertEqual(abs(self.ds - obt_np).max(), 0.0, "numpy-numpy algo")
        obt_cy = compression.decByteOffset_cython(compression.compByteOffset_numpy(self.ds))
        self.assertEqual(abs(self.ds - obt_cy).max(), 0.0, "cython-numpy algo")
        obt_cy2 = compression.decByteOffset_cython(compression.compByteOffset_numpy(self.ds), self.ds.size)
        self.assertEqual(abs(self.ds - obt_cy2).max(), 0.0, "cython2-numpy algo_orig")

        obt_np = compression.decByteOffset_numpy(compression.compByteOffset_cython(self.ds))
        self.assertEqual(abs(self.ds - obt_np).max(), 0.0, "numpy-numpy algo")
        obt_cy = compression.decByteOffset_cython(compression.compByteOffset_cython(self.ds))
        self.assertEqual(abs(self.ds - obt_cy).max(), 0.0, "cython-numpy algo")
        obt_cy2 = compression.decByteOffset_cython(compression.compByteOffset_cython(self.ds), self.ds.size)
        self.assertEqual(abs(self.ds - obt_cy2).max(), 0.0, "cython2-numpy algo_orig")
コード例 #3
0
    def testComp(self):
        """
        """
        # first with numpy
        ds = numpy.array([0, 128])
        ref = b"\x00\x80\x80\00"
        self.assertEqual(ref, compression.compByteOffset_numpy(ds),
                         "test +128")
        ds = numpy.array([0, -128])
        ref = b'\x00\x80\x80\xff'
        self.assertEqual(ref, compression.compByteOffset_numpy(ds),
                         "test -128")
        ds = numpy.array([10, -128])
        ref = b'\n\x80v\xff'
        self.assertEqual(ref, compression.compByteOffset_numpy(ds),
                         "test +10 -128")
        self.assertEqual(self.ref, compression.compByteOffset_numpy(self.ds),
                         "test larger")

        # Then with cython 32 bits
        ds = numpy.array([0, 128], dtype="int32")
        ref = b"\x00\x80\x80\00"
        self.assertEqual(ref, compression.compByteOffset_cython(ds),
                         "test +128")
        ds = numpy.array([0, -128], dtype="int32")
        ref = b'\x00\x80\x80\xff'
        self.assertEqual(ref, compression.compByteOffset_cython(ds),
                         "test -128")
        ds = numpy.array([10, -128], dtype="int32")
        ref = b'\n\x80v\xff'
        self.assertEqual(ref, compression.compByteOffset_cython(ds),
                         "test +10 -128")
        self.assertEqual(self.ref, compression.compByteOffset_cython(self.ds),
                         "test larger")

        # Then with cython 64bits
        ds = numpy.array([0, 128], dtype="int64")
        ref = b"\x00\x80\x80\00"
        self.assertEqual(ref, compression.compByteOffset_cython(ds),
                         "test +128")
        ds = numpy.array([0, -128], dtype="int64")
        ref = b'\x00\x80\x80\xff'
        self.assertEqual(ref, compression.compByteOffset_cython(ds),
                         "test -128")
        ds = numpy.array([10, -128], dtype="int64")
        ref = b'\n\x80v\xff'
        self.assertEqual(ref, compression.compByteOffset_cython(ds),
                         "test +10 -128")
        self.assertEqual(self.ref, compression.compByteOffset_cython(self.ds),
                         "test larger")
コード例 #4
0
ファイル: testcompression.py プロジェクト: vallsv/fabio
    def testComp(self):
        """
        """
        # first with numpy
        ds = numpy.array([0, 128])
        ref = b"\x00\x80\x80\00"
        self.assertEqual(ref, compression.compByteOffset_numpy(ds), "test +128")
        ds = numpy.array([0, -128])
        ref = b'\x00\x80\x80\xff'
        self.assertEqual(ref, compression.compByteOffset_numpy(ds), "test -128")
        ds = numpy.array([10, -128])
        ref = b'\n\x80v\xff'
        self.assertEqual(ref, compression.compByteOffset_numpy(ds), "test +10 -128")
        self.assertEqual(self.ref, compression.compByteOffset_numpy(self.ds), "test larger")

        # Then with cython 32 bits
        ds = numpy.array([0, 128], dtype="int32")
        ref = b"\x00\x80\x80\00"
        self.assertEqual(ref, compression.compByteOffset_cython(ds), "test +128")
        ds = numpy.array([0, -128], dtype="int32")
        ref = b'\x00\x80\x80\xff'
        self.assertEqual(ref, compression.compByteOffset_cython(ds), "test -128")
        ds = numpy.array([10, -128], dtype="int32")
        ref = b'\n\x80v\xff'
        self.assertEqual(ref, compression.compByteOffset_cython(ds), "test +10 -128")
        self.assertEqual(self.ref, compression.compByteOffset_cython(self.ds), "test larger")

        # Then with cython 64bits
        ds = numpy.array([0, 128], dtype="int64")
        ref = b"\x00\x80\x80\00"
        self.assertEqual(ref, compression.compByteOffset_cython(ds), "test +128")
        ds = numpy.array([0, -128], dtype="int64")
        ref = b'\x00\x80\x80\xff'
        self.assertEqual(ref, compression.compByteOffset_cython(ds), "test -128")
        ds = numpy.array([10, -128], dtype="int64")
        ref = b'\n\x80v\xff'
        self.assertEqual(ref, compression.compByteOffset_cython(ds), "test +10 -128")
        self.assertEqual(self.ref, compression.compByteOffset_cython(self.ds), "test larger")