code: def shift(arr, num: int, fill_value: int = np.nan):
      """Rolls a 1d-array in either direction, and applies a fill value on a portion of the array
  
      Parameters
      ----------
      arr : array-like, 1-D
          Array to roll and apply partial mask on
      num : `int`
          The patterns to be kept.
      fill_value: `int`
          After shifting elements, a value to fill in place of NAs in the resulint shifted array
  
      Returns
      -------
      arr : array-like, 1-D
          Rolled and partially-masked array
      """
      arr = np.roll(arr, num)
      if num < 0:
          arr[num:] = fill_value
      elif num > 0:
          arr[:num] = fill_value
      return arr
  
file_path: greykite/greykite/detection/common/ad_evaluation_utils.py
imports: from typing import List
  from typing import Optional
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: shift(arr, num, fill_value) and returns: arr