cython

Форк
0
/
builtin_divmod.py 
68 строк · 1.6 Кб
1
# mode: run
2

3
import cython
4

5
def divmod_regular(a,b):
6
    """
7
    >>> divmod_regular(10,5)
8
    (2, 0)
9
    >>> divmod_regular(9191,4096)
10
    (2, 999)
11
    >>> divmod_regular(10000,10010)
12
    (0, 10000)
13
    >>> divmod_regular(-999999,-111111)
14
    (9, 0)
15
    >>> divmod_regular(-888888,-11111)
16
    (80, -8)
17
    >>> divmod_regular(-10000,-10086)
18
    (0, -10000)
19
    >>> divmod_regular(5,-1)
20
    (-5, 0)
21
    >>> divmod_regular(-40,3)
22
    (-14, 2)
23
    >>> divmod_regular(11,-3)
24
    (-4, -1)
25
    >>> divmod_regular(0,9)
26
    (0, 0)
27
    >>> divmod_regular(0,-987654321)
28
    (0, 0)
29

30
    >>> divmod_regular(33,0)  #doctest: +ELLIPSIS
31
    Traceback (most recent call last):
32
    ZeroDivisionError: ...
33
    """
34
    return divmod(a,b)
35

36

37
@cython.test_assert_path_exists("//ReturnStatNode//NameNode[@entry.name = 'divmod']",
38
                                "//ReturnStatNode//NameNode[@entry.cname = '__Pyx_divmod_int']")
39
def divmod_int_regular(a: cython.int, b: cython.int):
40
    """
41
    >>> divmod_int_regular(10,5)
42
    (2, 0)
43
    >>> divmod_int_regular(9191,4096)
44
    (2, 999)
45
    >>> divmod_int_regular(10000,10010)
46
    (0, 10000)
47
    >>> divmod_int_regular(-999999,-111111)
48
    (9, 0)
49
    >>> divmod_int_regular(-888888,-11111)
50
    (80, -8)
51
    >>> divmod_int_regular(-10000,-10086)
52
    (0, -10000)
53
    >>> divmod_int_regular(-50,1)
54
    (-50, 0)
55
    >>> divmod_int_regular(-40,3)
56
    (-14, 2)
57
    >>> divmod_int_regular(11,-3)
58
    (-4, -1)
59
    >>> divmod_int_regular(0,9)
60
    (0, 0)
61
    >>> divmod_int_regular(0,-987654321)
62
    (0, 0)
63

64
    >>> divmod_int_regular(33,0)  #doctest: +ELLIPSIS
65
    Traceback (most recent call last):
66
    ZeroDivisionError: ...
67
    """
68
    return divmod(a,b)
69

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.