'Turn result into a quantity with the given unit.
If no output is given, it will take a view of the array as a quantity,
and set the unit.  If output is given, those should be quantity views
of the result arrays, and the function will just set the unit.
Parameters
result : `~numpy.ndarray` or tuple of `~numpy.ndarray`
Array(s) which need to be turned into quantity.
unit : `~astropy.units.Unit` or None
Unit for the quantities to be returned (or `None` if the result
should not be a quantity).  Should be tuple if result is a tuple.
out : `~astropy.units.Quantity` or None
Possible output quantity. Should be `None` or a tuple if result
is a tuple.
Returns
out : `~astropy.units.Quantity`
With units set.'

def _result_as_quantity(self, result, unit, out):

    if isinstance(result, tuple):
        if (out is None):
            out = ((None,) * len(result))
        return tuple((self._result_as_quantity(result_, unit_, out_) for (result_, unit_, out_) in zip(result, unit, out)))
    if (out is None):
        return (result if (unit is None) else self._new_view(result, unit))
    out._set_unit(unit)
    return out
