Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
test_isoc.py57 linesDownload Raw Back to tests
1import pytest
2
3import numpy as np
4from numpy.testing import assert_allclose
5
6from . import util
7
8
9class TestISOC(util.F2PyTest):
10    sources = [
11        util.getpath("tests", "src", "isocintrin", "isoCtests.f90"),
12    ]
13
14    # gh-24553
15    @pytest.mark.slow
16    def test_c_double(self):
17        out = self.module.coddity.c_add(1, 2)
18        exp_out = 3
19        assert out == exp_out
20
21    # gh-9693
22    def test_bindc_function(self):
23        out = self.module.coddity.wat(1, 20)
24        exp_out = 8
25        assert out == exp_out
26
27    # gh-25207
28    def test_bindc_kinds(self):
29        out = self.module.coddity.c_add_int64(1, 20)
30        exp_out = 21
31        assert out == exp_out
32
33    # gh-25207
34    def test_bindc_add_arr(self):
35        a = np.array([1, 2, 3])
36        b = np.array([1, 2, 3])
37        out = self.module.coddity.add_arr(a, b)
38        exp_out = a * 2
39        assert_allclose(out, exp_out)
40
41
42def test_process_f2cmap_dict():
43    from numpy.f2py.auxfuncs import process_f2cmap_dict
44
45    f2cmap_all = {"integer": {"8": "rubbish_type"}}
46    new_map = {"INTEGER": {"4": "int"}}
47    c2py_map = {"int": "int", "rubbish_type": "long"}
48
49    exp_map, exp_maptyp = ({"integer": {"8": "rubbish_type", "4": "int"}}, ["int"])
50
51    # Call the function
52    res_map, res_maptyp = process_f2cmap_dict(f2cmap_all, new_map, c2py_map)
53
54    # Assert the result is as expected
55    assert res_map == exp_map
56    assert res_maptyp == exp_maptyp
57 
codekingpro/portable-devtools · Team Ai