Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
test_size.py46 linesDownload Raw Back to tests
1import pytest
2
3import numpy as np
4
5from . import util
6
7
8class TestSizeSumExample(util.F2PyTest):
9    sources = [util.getpath("tests", "src", "size", "foo.f90")]
10
11    @pytest.mark.slow
12    def test_all(self):
13        r = self.module.foo([[]])
14        assert r == [0]
15
16        r = self.module.foo([[1, 2]])
17        assert r == [3]
18
19        r = self.module.foo([[1, 2], [3, 4]])
20        assert np.allclose(r, [3, 7])
21
22        r = self.module.foo([[1, 2], [3, 4], [5, 6]])
23        assert np.allclose(r, [3, 7, 11])
24
25    @pytest.mark.slow
26    def test_transpose(self):
27        r = self.module.trans([[]])
28        assert np.allclose(r.T, np.array([[]]))
29
30        r = self.module.trans([[1, 2]])
31        assert np.allclose(r, [[1.], [2.]])
32
33        r = self.module.trans([[1, 2, 3], [4, 5, 6]])
34        assert np.allclose(r, [[1, 4], [2, 5], [3, 6]])
35
36    @pytest.mark.slow
37    def test_flatten(self):
38        r = self.module.flatten([[]])
39        assert np.allclose(r, [])
40
41        r = self.module.flatten([[1, 2]])
42        assert np.allclose(r, [1, 2])
43
44        r = self.module.flatten([[1, 2, 3], [4, 5, 6]])
45        assert np.allclose(r, [1, 2, 3, 4, 5, 6])
46 
codekingpro/portable-devtools · Team Ai