File: cython_utils.pyx

package info (click to toggle)
py-stringmatching 0.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,956 kB
  • sloc: python: 3,979; makefile: 174; sh: 7
file content (83 lines) | stat: -rw-r--r-- 1,973 bytes parent folder | download | duplicates (2)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import cython


def cython_sim_ident(unicode char1, unicode char2):
    return 1 if char1 == char2 else 0


def int_max_two(int a, int b):
    """Finds the maximum integer of the given two integers.
        Args:
            integer1, integer2 (int): Input integers.
        Returns:
            Maximum integer (int).
    """
    if a > b : return a
    else: return b


def int_max_three(int a, int b, int c):
    """Finds the maximum integer of the given three integers.
        Args:
            integer1, integer2, integer3 (int): Input integers.
        Returns:
            Maximum integer (int).
    """
    cdef int max_int = a
    if b > max_int:
        max_int = b
    if c > max_int:
        max_int = c
    return max_int


def float_max_two(float a, float b):
    """Finds the maximum float of the given two floats.
        Args:
            float1, float2 (float): Input floats.
        Returns:
            Maximum float (float).
    """
    if a > b : return a
    else: return b


def float_max_three(float a, float b, float c):
    """Finds the maximum float of the given two float.
        Args:
            float1, float2, float3 (float): Input floats.
        Returns:
            Maximum float (float).
    """
    cdef float max_float = a
    if b > max_float:
        max_float = b
    if c > max_float:
        max_float = c
    return max_float


def int_min_two(int a, int b):
    """Finds the minimum integer of the given two integers.
    Args:
        integer a,integer b (int): Input integers.
    Returns:
        Minimum integer (int).
    """
    if a > b : return b
    else: return a


def int_min_three(int a, int b, int c):
    """Finds the minimum integer of the given two integers.
    Args:
        integer a, integer b, integer c (int): Input integers.
    Returns:
        Minimum integer (int).
    """
    cdef int min_int = a
    if b < min_int:
        min_int = b
    if c < min_int:
        min_int = c
    return min_int