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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
U
¬ý°d¡ã@sddZddlmZddlZddlZddlmZmZm    Z    ddl
m Z dd„Z ddd    œd
d „Z d d „ZdS)aP
Missing data handling for arithmetic operations.
 
In particular, pandas conventions regarding division by zero differ
from numpy in the following ways:
    1) np.array([-1, 0, 1], dtype=dtype1) // np.array([0, 0, 0], dtype=dtype2)
       gives [nan, nan, nan] for most dtype combinations, and [0, 0, 0] for
       the remaining pairs
       (the remaining being dtype1==dtype2==intN and dtype==dtype2==uintN).
 
       pandas convention is to return [-inf, nan, inf] for all dtype
       combinations.
 
       Note: the numpy behavior described here is py3-specific.
 
    2) np.array([-1, 0, 1], dtype=dtype1) % np.array([0, 0, 0], dtype=dtype2)
       gives precisely the same results as the // operation.
 
       pandas convention is to return [nan, nan, nan] for all dtype
       combinations.
 
    3) divmod behavior consistent with 1) and 2).
é)Ú annotationsN)Úis_float_dtypeÚis_integer_dtypeÚ    is_scalar)Ú    roperatorcCs†t|jƒr|St|dƒ}t|ƒ}|s,|s,|S|r:t |¡}t|jƒr‚|dk}| ¡r‚|t |¡@}|j    ddd}t 
||tj ¡|S)zÁ
    If this is a reversed op, then flip x,y
 
    If we have an integer value (or array in y)
    and we have 0's, fill them with np.nan,
    return the result.
 
    Mask the nan's from x.
    ÚdtyperÚfloat64F©Úcopy) rrÚhasattrrÚnpÚarrayrÚanyÚisnanÚastypeZputmaskÚnan)ÚresultÚxÚyZis_variable_typeZis_scalar_typeZymaskÚmask©rúNd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/core/ops/missing.pyÚ _fill_zeros's
 
 
 
 
rz
np.ndarray)rÚreturnc     Csît|dƒst |¡}t|dƒs(t |¡}|dk}| ¡rê|t |¡@}||@}|dk}|dk}||dk@}tjdd&||@||@B}    ||@||@B}
W5QRX| ¡s¼|     ¡s¼|
 ¡rê|jddd}tj||<tj||
<tj ||    <|S)am
    Set results of  0 // 0 to np.nan, regardless of the dtypes
    of the numerator or the denominator.
 
    Parameters
    ----------
    x : ndarray
    y : ndarray
    result : ndarray
 
    Returns
    -------
    ndarray
        The filled result.
 
    Examples
    --------
    >>> x = np.array([1, 0, -1], dtype=np.int64)
    >>> x
    array([ 1,  0, -1])
    >>> y = 0       # int 0; numpy behavior is different with float
    >>> result = x // y
    >>> result      # raw numpy result does not fill division by zero
    array([0, 0, 0])
    >>> mask_zero_div_zero(x, y, result)
    array([ inf,  nan, -inf])
    rrÚignore)ÚinvalidrFr    )    r r r rZsignbitZerrstaterrÚinf) rrrZzmaskZ    zneg_maskZ    zpos_maskZx_lt0Zx_gt0Znan_maskZ neginf_maskZ posinf_maskrrrÚmask_zero_div_zeroLs(
 
 
 
 
 
 
 rcCs¸|tkr*t|||dƒt|d||ƒf}nŠ|tjkrVt|||dƒt|d||ƒf}n^|tjkrnt|||ƒ}nF|tjkr†t|||ƒ}n.|tjkržt|||ƒ}n|tj    kr´t|||ƒ}|S)a
    Call _fill_zeros with the appropriate fill value depending on the operation,
    with special logic for divmod and rdivmod.
 
    Parameters
    ----------
    op : function (operator.add, operator.div, ...)
    left : object (np.ndarray for non-reversed ops)
    right : object (np.ndarray for reversed ops)
    result : ndarray
 
    Returns
    -------
    result : np.ndarray
 
    Notes
    -----
    For divmod and rdivmod, the `result` parameter and returned `result`
    is a 2-tuple of ndarray objects.
    ré)
ÚdivmodrrrZrdivmodÚoperatorÚfloordivZ    rfloordivÚmodZrmod)ÚopÚleftÚrightrrrrÚdispatch_fill_zeros‰s"þ
þ
 
 
 
 r&)Ú__doc__Ú
__future__rr Únumpyr Zpandas.core.dtypes.commonrrrZpandas.core.opsrrrr&rrrrÚ<module>s  %=