Skip to content

TST: test_units_errbarr in astropy/visualization/tests/test_units.py fails in dev job #13276

@pllim

Description

@pllim

Something changed upstream that has broken ax.errorbar with Quantity. A job in main that passed 2 days ago now fails like this:

______________________________ test_units_errbarr ______________________________

    @pytest.mark.skipif('not HAS_PLT')
    def test_units_errbarr():
        pytest.importorskip("matplotlib")
        plt.figure()
    
        with quantity_support():
            x = [1, 2, 3] * u.s
            y = [1, 2, 3] * u.m
            yerr = [3, 2, 1] * u.cm
    
            fig, ax = plt.subplots()
>           ax.errorbar(x, y, yerr=yerr)

../../.tox/py38-test-devdeps/lib/python3.8/site-packages/astropy/visualization/tests/test_units.py:52: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../.tox/py38-test-devdeps/lib/python3.8/site-packages/matplotlib/__init__.py:1412: in inner
    return func(ax, *map(sanitize_sequence, args), **kwargs)
../../.tox/py38-test-devdeps/lib/python3.8/site-packages/matplotlib/axes/_axes.py:3509: in errorbar
    if np.any(np.less(err, -err, out=res, where=(err == err))):
../../.tox/py38-test-devdeps/lib/python3.8/site-packages/astropy/units/quantity.py:607: in __array_ufunc__
    out_array = check_output(out, unit, inputs, function=function)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

output = <Quantity [False, False, False] cm>, unit = None
inputs = (<Quantity [3., 2., 1.] cm>, <Quantity [-3., -2., -1.] cm>)
function = <ufunc 'less'>

    def check_output(output, unit, inputs, function=None):
        """Check that function output can be stored in the output array given.
    
        Parameters
        ----------
        output : array or `~astropy.units.Quantity` or tuple
            Array that should hold the function output (or tuple of such arrays).
        unit : `~astropy.units.Unit` or None, or tuple
            Unit that the output will have, or `None` for pure numbers (should be
            tuple of same if output is a tuple of outputs).
        inputs : tuple
            Any input arguments.  These should be castable to the output.
        function : callable
            The function that will be producing the output.  If given, used to
            give a more informative error message.
    
        Returns
        -------
        arrays : ndarray view or tuple thereof
            The view(s) is of ``output``.
    
        Raises
        ------
        UnitTypeError : If ``unit`` is inconsistent with the class of ``output``
    
        TypeError : If the ``inputs`` cannot be cast safely to ``output``.
        """
        if isinstance(output, tuple):
            return tuple(check_output(output_, unit_, inputs, function)
                         for output_, unit_ in zip(output, unit))
    
        # ``None`` indicates no actual array is needed.  This can happen, e.g.,
        # with np.modf(a, out=(None, b)).
        if output is None:
            return None
    
        if hasattr(output, '__quantity_subclass__'):
            # Check that we're not trying to store a plain Numpy array or a
            # Quantity with an inconsistent unit (e.g., not angular for Angle).
            if unit is None:
>               raise TypeError("Cannot store non-quantity output{} in {} "
                                "instance".format(
                                    (f" from {function.__name__} function"
                                     if function is not None else ""),
                                    type(output)))
E               TypeError: Cannot store non-quantity output from less function in <class 'astropy.units.quantity.Quantity'> instance

../../.tox/py38-test-devdeps/lib/python3.8/site-packages/astropy/units/quantity_helper/converters.py:323: TypeError

I don't feel like building matplotlib from source. Anyone knows someone at matplotlib to ask about this? I asked over at matplotlib/matplotlib#22929 🤞

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions