# Buggy code
def _find_append_zero_crossings(x, y):
    r"""
    Find and interpolate zero crossings.

    Estimate the zero crossings of an x,y series and add estimated crossings to series,
    returning a sorted array with no duplicate values.

    Parameters
    ----------
    x : `pint.Quantity`
        x values of data
    y : `pint.Quantity`
        y values of data

    Returns
    -------
    x : `pint.Quantity`
        x values of data
    y : `pint.Quantity`
        y values of data

    """
    crossings = find_intersections(
        x[1:], y[1:], np.zeros_like(y[1:]) * y.units, log_x=True
    )
    x = concatenate((x, crossings[0]))
    y = concatenate((y, crossings[1]))

    # Resort so that data are in order
    sort_idx = np.argsort(x)
    x = x[sort_idx]
    y = y[sort_idx]

    # Remove duplicate data points if there are any
    keep_idx = np.ediff1d(x.magnitude, to_end=[1]) > 1e-6
    x = x[keep_idx]
    y = y[keep_idx]
    return x, y


# Traceback (ValueError)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-8-d3bf39d73e06> in <module>
7 td = units.degC * np.ma.array([20, 10, -5])
8
----> 9 mpcalc.surface_based_cape_cin(pressure, t, td)

~/repos/metpy/src/metpy/xarray.py in wrapper(*args, **kwargs)
1065         kwargs = {name: (v.metpy.unit_array if isinstance(v, xr.DataArray) else v)
1066                   for name, v in kwargs.items()}
-> 1067         return func(*args, **kwargs)
1068     return wrapper
1069

~/repos/metpy/src/metpy/units.py in wrapper(*args, **kwargs)
231                             '    x = x * units.meter / units.second')
232                 raise ValueError(msg)
--> 233             return func(*args, **kwargs)
234
235         return wrapper

~/repos/metpy/src/metpy/calc/thermo.py in surface_based_cape_cin(pressure, temperature, dewpoint)
1826     pressure, temperature, dewpoint = _remove_nans(pressure, temperature, dewpoint)
1827     p, t, td, profile = parcel_profile_with_lcl(pressure, temperature, dewpoint)
-> 1828     return cape_cin(p, t, td, profile)
1829
1830

~/repos/metpy/src/metpy/xarray.py in wrapper(*args, **kwargs)
1065         kwargs = {name: (v.metpy.unit_array if isinstance(v, xr.DataArray) else v)
1066                   for name, v in kwargs.items()}
-> 1067         return func(*args, **kwargs)
1068     return wrapper
1069

~/repos/metpy/src/metpy/units.py in wrapper(*args, **kwargs)
230                             '    from metpy.units import units\n'
231                             '    x = x * units.meter / units.second')
--> 232                 raise ValueError(msg)
233             return func(*args, **kwargs)
234

ValueError: `cape_cin` given arguments with incorrect units: `temperature` requires "[temperature]" but given "none", `dewpoint` requires "[temperature]" but given "none"
Any variable `x` can be assigned a unit as follows:
from metpy.units import units
x = x * units.meter / units.second

# Fixed code
def _find_append_zero_crossings(x, y):
    r"""
    Find and interpolate zero crossings.

    Estimate the zero crossings of an x,y series and add estimated crossings to series,
    returning a sorted array with no duplicate values.

    Parameters
    ----------
    x : `pint.Quantity`
        x values of data
    y : `pint.Quantity`
        y values of data

    Returns
    -------
    x : `pint.Quantity`
        x values of data
    y : `pint.Quantity`
        y values of data

    """
    crossings = find_intersections(
        x[1:], y[1:], y.units * np.zeros_like(y[1:]), log_x=True
    )
    x = concatenate((x, crossings[0]))
    y = concatenate((y, crossings[1]))

    # Resort so that data are in order
    sort_idx = np.argsort(x)
    x = x[sort_idx]
    y = y[sort_idx]

    # Remove duplicate data points if there are any
    keep_idx = np.ediff1d(x.magnitude, to_end=[1]) > 1e-6
    x = x[keep_idx]
    y = y[keep_idx]
    return x, y