docs: def material_roughness(ID, D=None, optimism=None):
      r'''Searches through either a dict of clean pipe materials or used pipe
      materials and conditions and returns the ID of the nearest material.
      Search is performed with either the standard library's difflib or with
      the fuzzywuzzy module if available.
  
      Parameters
      ----------
      ID : str
          Search terms for matching pipe materials, [-]
      D : float, optional
          Diameter of desired pipe; used only if ID is in [2]_, [m]
      optimism : bool, optional
          For values in [1]_, a minimum, maximum, and average value is normally
          given; if True, returns the minimum roughness; if False, the maximum
          roughness; and if None, returns the average roughness. Most entries do
          not have all three values, so fallback logic to return the closest
          entry is used, [-]
  
      Returns
      -------
      roughness : float
          Retrieved or calculated roughness, [m]
  
      Examples
      --------
      >>> material_roughness('condensate pipes')
      0.0005
  
      References
      ----------
      .. [1] Idelʹchik, I. E, and A. S Ginevskiĭ. Handbook of Hydraulic 
         Resistance. Redding, CT: Begell House, 2007.
      .. [2] Farshad, Fred F., and Herman H. Rieke. "Surface Roughness Design 
         Values for Modern Pipes." SPE Drilling & Completion 21, no. 3 (September
         1, 2006): 212-215. doi:10.2118/89040-PA.
      '''
      if ID in _Farshad_roughness:
          return roughness_Farshad(ID, D)
      elif ID in _roughness:
          return _roughness[ID]
      elif ID in HHR_roughness:
          minimum, maximum, avg = HHR_roughness[ID]
          if optimism is None:
              return avg if avg else (maximum if maximum else minimum)
          elif optimism is True:
              return minimum if minimum else (avg if avg else maximum)
          else:
              return maximum if maximum else (avg if avg else minimum)
      else:
          return material_roughness(nearest_material_roughness(ID, clean=False), 
                                    D=D, optimism=optimism)