File: test_aux.py

package info (click to toggle)
pytables 3.11.0-2
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 15,284 kB
  • sloc: ansic: 82,216; python: 65,566; cpp: 753; sh: 394; makefile: 106
file content (35 lines) | stat: -rw-r--r-- 886 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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")