code: def _check_unit(new_unit, old_unit):
      
  
      try:
  
          new_unit.physical_type
  
      except AttributeError:
  
          raise UnitMismatch("The provided unit (%s) has no physical type. Was expecting a unit for %s"
                             % (new_unit, old_unit.physical_type))
  
      if new_unit.physical_type != old_unit.physical_type:
  
          raise UnitMismatch("Physical type mismatch: you provided a unit for %s instead of a unit for %s"
                             % (new_unit.physical_type, old_unit.physical_type))
docs: Check that the new unit is compatible with the old unit for the quantity described by variable_name
  
      :param new_unit: instance of astropy.units.Unit
      :param old_unit: instance of astropy.units.Unit
      :return: nothin