code: def FillDepressions(
    dem,
    epsilon  = False,
    in_place = False,
    topology = 'D8'
  ):
    
    if type(dem) is not rdarray:
      raise Exception("A richdem.rdarray or numpy.ndarray is required!")
  
    if topology not in ['D8','D4']:
      raise Exception("Unknown topology!")
  
    if not in_place:
      dem = dem.copy()
  
    _AddAnalysis(dem, "FillDepressions(dem, epsilon={0})".format(epsilon))
  
    demw = dem.wrap()
  
    if epsilon:
      if topology=='D8':
        _richdem.rdPFepsilonD8(demw)
      elif topology=='D4':
        _richdem.rdPFepsilonD4(demw)
    else:
      if topology=='D8':
        _richdem.rdFillDepressionsD8(demw)
      elif topology=='D4':
        _richdem.rdFillDepressionsD4(demw)
  
    dem.copyFromWrapped(demw)
  
    if not in_place:
      return dem
docs: Fills all depressions in a DEM.
  
       Args:
           dem     (rdarray): An elevation model
           epsilon (float):   If True, an epsilon gradient is imposed to all flat regions.
                              This ensures that there is always a local gradient.
           in_place (bool):   If True, the DEM is modified in place and there is
                              no return; otherwise, a new, altered DEM is returned.                                     
           topology (string): A topology indicator
  
       Returns:
           DEM without depressions.