HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Users/fred/anaconda3/Lib/site-packages/tables/tests/test_aux.py
import unittest
import numpy as np

import tables as tb
from tables.tests import common


class TestAuxiliaryFunctions(unittest.TestCase):
    def test_keysort(self):
        N = 1000
        rnd = np.random.randint(N, size=N)
        for dtype1 in ('S6', 'b1', 'i1', 'i8', 'u4', 'u8', 'f4', 'f8'):
            for dtype2 in ('u4', 'i8'):
                a = np.array(rnd, dtype1)
                b = np.array(rnd, dtype2)

                c = a.copy()
                d = c.argsort()
                e = c[d]
                f = b[d]

                tb.indexesextension.keysort(a, b)
                self.assertTrue((a == e).all())
                self.assertTrue((b == f).all())


def suite():
    theSuite = unittest.TestSuite()
    theSuite.addTest(common.make_suite(TestAuxiliaryFunctions))
    return theSuite


if __name__ == '__main__':
    unittest.main(defaultTest='suite')