• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rjfarmer / gfModParser / 15281216228

27 May 2025 04:58PM UTC coverage: 90.135% (-0.6%) from 90.69%
15281216228

push

github

rjfarmer
Start on unsigned variables

2 of 8 new or added lines in 2 files covered. (25.0%)

868 of 963 relevant lines covered (90.13%)

0.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

57.5
/gfModParser/utils.py
1
# SPDX-License-Identifier: GPL-2.0+
2

3
import numpy as np
1✔
4
from packaging.version import Version
1✔
5

6
try:
1✔
7
    import pyquadp as pyq
1✔
8

9
    PYQ_IMPORTED = True
×
10
except ImportError:
1✔
11
    PYQ_IMPORTED = False
1✔
12

13

14
"""
1✔
15
Map gfortran version to Mod file version
16
"""
17

18

19
def gfortran_mod_map(version):
1✔
20
    if version < Version("4.8.1"):
×
21
        return Version("9")
×
22
    elif version < Version("4.9.2"):
×
23
        return Version("10")
×
24
    elif version < Version("5.1.0"):
×
25
        return Version("12")
×
26
    elif version < Version("8.0.0"):
×
27
        return Version("14")
×
28
    elif version < Version("15.0.0"):
×
29
        return Version("15")
×
30
    elif version.major == 15:
×
31
        return Version("16")
×
32
    else:
33
        raise ValueError(f"Unknown gfortran version {version}")
×
34

35

36
def string_clean(string):
1✔
37
    if string is None:
1✔
38
        return
1✔
39
    if string.startswith("'") or string.startswith('"'):
1✔
40
        string = string[1:]
1✔
41
    if string.endswith("'") or string.endswith('"'):
1✔
42
        string = string[:-1]
1✔
43

44
    return string
1✔
45

46

47
def hextofloat(s, kind=4):
1✔
48
    # Given hex like parameter '0.12decde@9' returns 5065465344.0
49
    man, exp = s.split("@")
1✔
50
    exp = int(exp)
1✔
51
    decimal = man.index(".")
1✔
52
    negative = man[0] == "-"
1✔
53
    man = man[decimal + 1 :]
1✔
54
    man = man.ljust(exp, "0")
1✔
55
    man = man[:exp] + "." + man[exp:]
1✔
56
    man = man + "P0"
1✔
57
    if negative:
1✔
58
        man = "-" + man
1✔
59
    if PYQ_IMPORTED and kind == 16:
1✔
60
        return pyq.qfloat.fromhex(man)
×
61
    elif kind == 8:
1✔
62
        return np.double.fromhex(man)
1✔
63
    else:
64
        return float.fromhex(man)
1✔
65

66

67
def dtype(type, kind, len=-1):
1✔
68
    if type == "REAL":
1✔
69
        if kind == 4:
1✔
70
            return np.dtype(np.float32)
1✔
71
        elif kind == 8:
1✔
72
            return np.dtype(np.float64)
1✔
73
        elif kind == 16:
×
74
            return np.dtype(np.float128)
×
75
    elif type == "INTEGER":
1✔
76
        if kind == 4:
1✔
77
            return np.dtype(np.int32)
1✔
78
        elif kind == 8:
×
79
            return np.dtype(np.int64)
×
80
        elif kind == 16:
×
81
            return np.dtype(np.int128)
×
82
    elif type == "UNSIGNED":
1✔
NEW
83
        if kind == 4:
×
NEW
84
            return np.dtype(np.uint32)
×
NEW
85
        elif kind == 8:
×
NEW
86
            return np.dtype(np.uint64)
×
NEW
87
        elif kind == 16:
×
NEW
88
            return np.dtype(np.uint128)
×
89
    elif type == "CHARACTER":
1✔
90
        return np.dtype(f"S{len}")
1✔
91
    elif type == "COMPLEX":
1✔
92
        if kind == 4:
×
93
            return np.dtype(np.complex64)
×
94
        elif kind == 8:
×
95
            return np.dtype(np.complex128)
×
96
        elif kind == 16:
×
97
            return np.dtype(np.complex256)
×
98
    elif type == "LOGICAL":
1✔
99
        return np.dtype(np.int32)
1✔
100
    else:
101
        raise NotImplementedError(f"Type={type} kind={kind}")
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc