code: def accept_quantity(input_type=float, allow_none=False):
      
  
      def accept_quantity_wrapper(method):
  
          def handle_quantity(instance, value, *args, **kwargs):
  
              # For speed reasons, first run the case where the input is not a quantity, and fall back to the handling
              # of quantities if that fails. The parts that fails if the input is a Quantity is the conversion
              # input_type(value). This could have been handled more elegantly with a "finally" clause, but that would
              # have a 40 percent speed impact...
  
              try:
  
                  new_value = input_type(value)
  
                  return method(instance, new_value, *args, **kwargs)
  
              except TypeError:
  
                  # Slow for slow, check that we actually have a quantity or None (if allowed)
  
                  if isinstance(value, u.Quantity):
  
                      new_value = value.to(instance.unit).value
  
                      return method(instance, new_value, *args, **kwargs)
  
                  elif value is None:
  
                      if allow_none:
  
                          return method(instance, None, *args, **kwargs)
  
                      else: # pragma: no cover
  
                          raise TypeError("You cannot pass None as argument for "
                                          "method %s of %s" % (method.__name__, instance.name))
  
                  else: # pragma: no cover
  
                      raise TypeError("You need to pass either a %s or a astropy.Quantity "
                                      "to method %s of %s" % (input_type.__name__, method.__name__, instance.name))
  
          return handle_quantity
  
      return accept_quantity_wrapper
docs: A class-method decorator which allow a given method (typically the set_value method) to receive both a
          astropy.Quantity or a simple float, but to be coded like it's always receiving a pure float in the right units.
          This is to give a way to avoid the huge bottleneck that are astropy.units
  
          :param input_type: the expected type for the input (float, int)
          :param allow_none : whether to allow or not the passage of None as argument (default: False)
          :return: a decorator for the particular type