# Buggy code
def sample(self, values=None, method=mean_motion):
    """Samples an orbit to some specified time values.

    .. versionadded:: 0.8.0

    Parameters
    ----------
    values : Multiple options
        Number of interval points (default to 100),
        True anomaly values,
        Time values.

    Returns
    -------
    (Time, CartesianRepresentation)
        A tuple containing Time and Position vector in each
        given value.

    Notes
    -----
    When specifying a number of points, the initial and final
    position is present twice inside the result (first and
    last row). This is more useful for plotting.

    Examples
    --------
    >>> from astropy import units as u
    >>> from poliastro.examples import iss
    >>> iss.sample()
    >>> iss.sample(10)
    >>> iss.sample([0, 180] * u.deg)
    >>> iss.sample([0, 10, 20] * u.minute)
    >>> iss.sample([iss.epoch + iss.period / 2])

    """
    if values is None:
        return self.sample(100, method)

    elif isinstance(values, int):
        if self.ecc < 1:
            # first sample eccentric anomaly, then transform into true anomaly
            # why sampling eccentric anomaly uniformly to minimize error in the apocenter, see
            # http://www.dtic.mil/dtic/tr/fulltext/u2/a605040.pdf
            E_values = np.linspace(0, 2 * np.pi, values) * u.rad
            nu_values = E_to_nu(E_values, self.ecc)
        else:
            # Select a sensible limiting value for non-closed orbits
            # This corresponds to r = 3p
            nu_limit = np.arccos(-(1 - 1 / 3.0) / self.ecc)
            nu_values = np.linspace(-nu_limit, nu_limit, values)
            nu_values = np.insert(nu_values, 0, self.ecc)

        return self.sample(nu_values, method)

    elif hasattr(values, "unit") and values.unit in ("rad", "deg"):
        values = self._generate_time_values(values)
    return (values, self._sample(values, method))


# Traceback (ValueError)
/usr/local/lib/python3.6/site-packages/astropy/units/quantity.py:639: RuntimeWarning:

invalid value encountered in log

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/usr/local/lib/python3.6/site-packages/astropy/time/core.py in __add__(self, other)
1369             try:
-> 1370                 other = TimeDelta(other)
1371             except Exception:

/usr/local/lib/python3.6/site-packages/astropy/time/core.py in __init__(self, val, val2, format, scale, copy)
1539
-> 1540             self._init_from_vals(val, val2, format, scale, copy)
1541

/usr/local/lib/python3.6/site-packages/astropy/time/core.py in _init_from_vals(self, val, val2, format, scale, copy, precision, in_subfmt, out_subfmt)
329         self._time = self._get_time_fmt(val, val2, format, scale,
--> 330                                         precision, in_subfmt, out_subfmt)
331         self._format = self._time.name

/usr/local/lib/python3.6/site-packages/astropy/time/core.py in _get_time_fmt(self, val, val2, format, scale, precision, in_subfmt, out_subfmt)
373         else:
--> 374             raise ValueError('Input values did not match {0}'.format(err_msg))
375

ValueError: Input values did not match the format class jd

During handling of the above exception, another exception occurred:

OperandTypeError                          Traceback (most recent call last)
<ipython-input-5-f1d654cf6abc> in <module>()
2
3 op.plot(parking)
----> 4 op.plot(exit)
5
6 plt.xlim(-8000, 8000)

/usr/local/lib/python3.6/site-packages/poliastro-0.9.dev0-py3.6.egg/poliastro/plotting.py in plot(self, orbit, label, color)
152         lines = []
153
--> 154         _, positions = orbit.sample(self.num_points)
155         rr = positions.get_xyz().transpose()
156

/usr/local/lib/python3.6/site-packages/poliastro-0.9.dev0-py3.6.egg/poliastro/twobody/orbit.py in sample(self, values, function)
308                 nu_values = np.insert(nu_values, 0, self.ecc)
309
--> 310             return self.sample(nu_values, function)
311
312         elif hasattr(values, "unit") and values.unit in ('rad', 'deg'):

/usr/local/lib/python3.6/site-packages/poliastro-0.9.dev0-py3.6.egg/poliastro/twobody/orbit.py in sample(self, values, function)
311
312         elif hasattr(values, "unit") and values.unit in ('rad', 'deg'):
--> 313             values = self._generate_time_values(values)
314         return (values, self._sample(values, function))
315

/usr/local/lib/python3.6/site-packages/poliastro-0.9.dev0-py3.6.egg/poliastro/twobody/orbit.py in _generate_time_values(self, nu_vals)
324     def _generate_time_values(self, nu_vals):
325         M_vals = nu_to_M(nu_vals, self.ecc)
--> 326         time_values = self.epoch + (M_vals / self.n).decompose()
327         return time_values
328

/usr/local/lib/python3.6/site-packages/astropy/time/core.py in __add__(self, other)
1370                 other = TimeDelta(other)
1371             except Exception:
-> 1372                 raise OperandTypeError(self, other, '+')
1373
1374         # Tdelta + something is dealt with in TimeDelta, so we have

OperandTypeError: Unsupported operand type(s) for +: 'Time' and 'Quantity'

# Fixed code
def sample(self, values=None, method=mean_motion):
    """Samples an orbit to some specified time values.

    .. versionadded:: 0.8.0

    Parameters
    ----------
    values : Multiple options
        Number of interval points (default to 100),
        True anomaly values,
        Time values.

    Returns
    -------
    (Time, CartesianRepresentation)
        A tuple containing Time and Position vector in each
        given value.

    Notes
    -----
    When specifying a number of points, the initial and final
    position is present twice inside the result (first and
    last row). This is more useful for plotting.

    Examples
    --------
    >>> from astropy import units as u
    >>> from poliastro.examples import iss
    >>> iss.sample()
    >>> iss.sample(10)
    >>> iss.sample([0, 180] * u.deg)
    >>> iss.sample([0, 10, 20] * u.minute)
    >>> iss.sample([iss.epoch + iss.period / 2])

    """
    if values is None:
        return self.sample(100, method)

    elif isinstance(values, int):
        if self.ecc < 1:
            # first sample eccentric anomaly, then transform into true anomaly
            # why sampling eccentric anomaly uniformly to minimize error in the apocenter, see
            # http://www.dtic.mil/dtic/tr/fulltext/u2/a605040.pdf
            # Start from pericenter
            E_values = np.linspace(0, 2 * np.pi, values) * u.rad
            nu_values = E_to_nu(E_values, self.ecc)
        else:
            # Select a sensible limiting value for non-closed orbits
            # This corresponds to max(r = 3p, r = self.r)
            # We have to wrap nu in [-180, 180) to compare it with the output of
            # the arc cosine, which is in the range [0, 180)
            # Start from -nu_limit
            wrapped_nu = self.nu if self.nu < 180 * u.deg else self.nu - 360 * u.deg
            nu_limit = max(np.arccos(-(1 - 1 / 3.0) / self.ecc), wrapped_nu)
            nu_values = np.linspace(-nu_limit, nu_limit, values)

        return self.sample(nu_values, method)

    elif hasattr(values, "unit") and values.unit in ("rad", "deg"):
        values = self._generate_time_values(values)

    return values, self._sample(values, method)