parameters: (x, y, result)
return_statement: return result
docstring: 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])
docstring_summary: Set results of  0 // 0 to np.nan, regardless of the dtypes
      of the numerator or the denominator.
docstring_tokens: Set results of 0 // 0 to np . nan regardless of the dtypes of the numerator or the denominator .
function: def mask_zero_div_zero(x, y, result):
      """
      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])
      """
      if not isinstance(result, np.ndarray):
          # FIXME: SparseArray would raise TypeError with np.putmask
          return result
  
      if is_scalar(y):
          y = np.array(y)
  
      zmask = y == 0
  
      if isinstance(zmask, bool):
          # FIXME: numpy did not evaluate pointwise, seen in docs build
          return result
  
      if zmask.any():
  
          # Flip sign if necessary for -0.0
          zneg_mask = zmask & np.signbit(y)
          zpos_mask = zmask & ~zneg_mask
  
          nan_mask = zmask & (x == 0)
          with np.errstate(invalid="ignore"):
              neginf_mask = (zpos_mask & (x < 0)) | (zneg_mask & (x > 0))
              posinf_mask = (zpos_mask & (x > 0)) | (zneg_mask & (x < 0))
  
          if nan_mask.any() or neginf_mask.any() or posinf_mask.any():
              # Fill negative/0 with -inf, positive/0 with +inf, 0/0 with NaN
              result = result.astype("float64", copy=False)
  
              result[nan_mask] = np.nan
              result[posinf_mask] = np.inf
              result[neginf_mask] = -np.inf
  
      return result
function_tokens: def mask_zero_div_zero ( x , y , result ) : if not isinstance ( result , np . ndarray ) : # FIXME: SparseArray would raise TypeError with np.putmask return result if is_scalar ( y ) : y = np . array ( y ) zmask = y == 0 if isinstance ( zmask , bool ) : # FIXME: numpy did not evaluate pointwise, seen in docs build return result if zmask . any ( ) : # Flip sign if necessary for -0.0 zneg_mask = zmask & np . signbit ( y ) zpos_mask = zmask & ~ zneg_mask nan_mask = zmask & ( x == 0 ) with np . errstate ( invalid = "ignore" ) : neginf_mask = ( zpos_mask & ( x < 0 ) ) | ( zneg_mask & ( x > 0 ) ) posinf_mask = ( zpos_mask & ( x > 0 ) ) | ( zneg_mask & ( x < 0 ) ) if nan_mask . any ( ) or neginf_mask . any ( ) or posinf_mask . any ( ) : # Fill negative/0 with -inf, positive/0 with +inf, 0/0 with NaN result = result . astype ( "float64" , copy = False ) result [ nan_mask ] = np . nan result [ posinf_mask ] = np . inf result [ neginf_mask ] = - np . inf return result