Unidata / MetPy

MetPy is a collection of tools in Python for reading, visualizing and performing calculations with weather data.
https://unidata.github.io/MetPy/
BSD 3-Clause "New" or "Revised" License
1.25k stars 414 forks source link

Nightly build is failing #1867

Closed github-actions[bot] closed 3 years ago

github-actions[bot] commented 3 years ago

The Nightly workflow is failing.

platform linux -- Python 3.9.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
Matplotlib: 3.4.2
Freetype: 2.6.1
Dep Versions: Matplotlib 3.4.2, NumPy 1.20.3, Pandas 1.2.4, Pint 0.18.dev12+gfe3e8f7, Pooch v1.3.0
    PyProj 3.0.1, SciPy 1.6.3, Traitlets 5.0.5, Xarray 0.18.1.dev6+g6e14df62
rootdir: /home/runner/work/MetPy/MetPy, configfile: setup.cfg
plugins: mpl-0.12
collected 1124 items

tests/test_cbook.py .                                                    [  0%]
tests/test_deprecation.py .                                              [  0%]
tests/test_testing.py ....                                               [  0%]
tests/test_xarray.py ................................................... [  5%]
........................................................................ [ 11%]
........................................................................ [ 17%]
.......                                                                  [ 18%]
tests/calc/test_basic.py .....................FF........................ [ 22%]
....................                                                     [ 24%]
tests/calc/test_calc_tools.py .......................................... [ 28%]
........................................................................ [ 34%]
............                                                             [ 35%]
tests/calc/test_cross_sections.py ............                           [ 36%]
tests/calc/test_indices.py ..................                            [ 38%]
tests/calc/test_kinematics.py .......................................... [ 42%]
..............                                                           [ 43%]
tests/calc/test_thermo.py .............................................. [ 47%]
........................................................................ [ 53%]
.................................                                        [ 56%]
tests/calc/test_turbulence.py ...........................                [ 59%]
tests/interpolate/test_geometry.py .............                         [ 60%]
tests/interpolate/test_grid.py ........................                  [ 62%]
tests/interpolate/test_interpolate_tools.py .......                      [ 63%]
tests/interpolate/test_one_dimension.py .................                [ 64%]
tests/interpolate/test_points.py ...............                         [ 65%]
tests/interpolate/test_slices.py .......                                 [ 66%]
tests/io/test_gini.py ............                                       [ 67%]
tests/io/test_metar.py ..............                                    [ 68%]
tests/io/test_nexrad.py ................................................ [ 73%]
........................................................................ [ 79%]
..................................................                       [ 83%]
tests/io/test_station_data.py .                                          [ 84%]
tests/io/test_tools.py ..                                                [ 84%]
tests/plots/test_cartopy_utils.py .....                                  [ 84%]
tests/plots/test_ctables.py ..........                                   [ 85%]
tests/plots/test_declarative.py ........................................ [ 89%]
..                                                                       [ 89%]
tests/plots/test_mapping.py ....................                         [ 91%]
tests/plots/test_mpl.py .                                                [ 91%]
tests/plots/test_skewt.py ...............................                [ 93%]
tests/plots/test_station_plot.py .........................               [ 96%]
tests/plots/test_util.py .............                                   [ 97%]
tests/plots/test_wx_symbols.py ....                                      [ 97%]
tests/units/test_units.py ..........................                     [100%]

=================================== FAILURES ===================================
___________________________ test_heat_index_invalid ____________________________

    def test_heat_index_invalid():
        """Test heat index for values that should be masked."""
        temp = np.array([80, 88, 92, 79, 30, 81]) * units.degF
        rh = np.array([40, 39, 2, 70, 50, 39]) * units.percent

>       hi = heat_index(temp, rh)

tests/calc/test_basic.py:233: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/metpy/xarray.py:1216: in wrapper
    result = func(*bound_args.args, **bound_args.kwargs)
/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/metpy/units.py:246: in wrapper
    return func(*args, **kwargs)
/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/metpy/calc/basic.py:310: in heat_index
    hi[sel] = hi[sel] - units.Quantity(rh15adj, 'delta_degF')
/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/pint/quantity.py:240: in __new__
    magnitude = value.to(units)._magnitude
/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/pint/quantity.py:657: in to
    magnitude = self._convert_magnitude_not_inplace(other, *contexts, **ctx_kwargs)
/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/pint/quantity.py:606: in _convert_magnitude_not_inplace
    return self._REGISTRY.convert(self._magnitude, self._units, other)
/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/pint/registry.py:947: in convert
    return self._convert(value, src, dst, inplace)
/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/pint/registry.py:1830: in _convert
    return super()._convert(value, src, dst, inplace)
/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/pint/registry.py:1433: in _convert
    return super()._convert(value, src, dst, inplace)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pint.registry.UnitRegistry object at 0x7fb1ecd1d610>
value = array([2.49558434]), src = <UnitsContainer({})>
dst = <UnitsContainer({'delta_degree_Fahrenheit': 1})>, inplace = False
check_dimensionality = True

    def _convert(self, value, src, dst, inplace=False, check_dimensionality=True):
        """Convert value from some source to destination units.

        Parameters
        ----------
        value :
            value
        src : UnitsContainer
            source units.
        dst : UnitsContainer
            destination units.
        inplace :
             (Default value = False)
        check_dimensionality :
             (Default value = True)

        Returns
        -------
        type
            converted value

        """

        if check_dimensionality:

            src_dim = self._get_dimensionality(src)
            dst_dim = self._get_dimensionality(dst)

            # If the source and destination dimensionality are different,
            # then the conversion cannot be performed.
            if src_dim != dst_dim:
>               raise DimensionalityError(src, dst, src_dim, dst_dim)
E               pint.errors.DimensionalityError: Cannot convert from 'dimensionless' (dimensionless) to 'delta_degree_Fahrenheit' ([temperature])

/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/pint/registry.py:980: DimensionalityError
________________________ test_heat_index_undefined_flag ________________________

    def test_heat_index_undefined_flag():
        """Test whether masking values can be disabled for heat index."""
        temp = units.Quantity(np.ma.array([80, 88, 92, 79, 30, 81]), units.degF)
        rh = units.Quantity(np.ma.array([40, 39, 2, 70, 50, 39]), units.percent)

>       hi = heat_index(temp, rh, mask_undefined=False)

tests/calc/test_basic.py:243: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/metpy/xarray.py:1216: in wrapper
    result = func(*bound_args.args, **bound_args.kwargs)
/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/metpy/units.py:246: in wrapper
    return func(*args, **kwargs)
/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/metpy/calc/basic.py:310: in heat_index
    hi[sel] = hi[sel] - units.Quantity(rh15adj, 'delta_degF')
/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/pint/quantity.py:240: in __new__
    magnitude = value.to(units)._magnitude
/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/pint/quantity.py:657: in to
    magnitude = self._convert_magnitude_not_inplace(other, *contexts, **ctx_kwargs)
/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/pint/quantity.py:606: in _convert_magnitude_not_inplace
    return self._REGISTRY.convert(self._magnitude, self._units, other)
/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/pint/registry.py:947: in convert
    return self._convert(value, src, dst, inplace)
/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/pint/registry.py:1830: in _convert
    return super()._convert(value, src, dst, inplace)
/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/pint/registry.py:1433: in _convert
    return super()._convert(value, src, dst, inplace)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pint.registry.UnitRegistry object at 0x7fb1ecd1d610>
value = masked_array(data=[2.495584335675833],
             mask=[False],
       fill_value=1e+20)
src = <UnitsContainer({})>
dst = <UnitsContainer({'delta_degree_Fahrenheit': 1})>, inplace = False
check_dimensionality = True

    def _convert(self, value, src, dst, inplace=False, check_dimensionality=True):
        """Convert value from some source to destination units.

        Parameters
        ----------
        value :
            value
        src : UnitsContainer
            source units.
        dst : UnitsContainer
            destination units.
        inplace :
             (Default value = False)
        check_dimensionality :
             (Default value = True)

        Returns
        -------
        type
            converted value

        """

        if check_dimensionality:

            src_dim = self._get_dimensionality(src)
            dst_dim = self._get_dimensionality(dst)

            # If the source and destination dimensionality are different,
            # then the conversion cannot be performed.
            if src_dim != dst_dim:
>               raise DimensionalityError(src, dst, src_dim, dst_dim)
E               pint.errors.DimensionalityError: Cannot convert from 'dimensionless' (dimensionless) to 'delta_degree_Fahrenheit' ([temperature])

/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/pint/registry.py:980: DimensionalityError
=============================== warnings summary ===============================
tests/test_xarray.py::test_quantify
tests/test_xarray.py::test_dataset_quantify
tests/calc/test_calc_tools.py::test_parse_angle_invalid_arr
tests/calc/test_calc_tools.py::test_gradient_2d
tests/calc/test_calc_tools.py::test_gradient_4d
tests/calc/test_calc_tools.py::test_gradient_restricted_axes
tests/calc/test_calc_tools.py::test_3d_gradient_3d_data_no_axes
tests/calc/test_calc_tools.py::test_2d_gradient_4d_data_2_axes_3_deltas
tests/calc/test_calc_tools.py::test_2d_gradient_4d_data_2_axes_2_deltas
  /opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/numpy/testing/_private/utils.py:704: UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray.
    x = array(x, copy=False, subok=True)

tests/test_xarray.py::test_quantify
tests/test_xarray.py::test_dataset_quantify
tests/calc/test_calc_tools.py::test_find_intersections[all-expected0]
tests/calc/test_calc_tools.py::test_find_intersections[increasing-expected1]
tests/calc/test_calc_tools.py::test_find_intersections[decreasing-expected2]
tests/calc/test_calc_tools.py::test_find_intersections_no_intersections
tests/calc/test_calc_tools.py::test_find_intersections_intersections_in_data_at_ends[all-expected0]
tests/calc/test_calc_tools.py::test_find_intersections_intersections_in_data_at_ends[increasing-expected1]
tests/calc/test_calc_tools.py::test_find_intersections_intersections_in_data_at_ends[decreasing-expected2]
  /opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/numpy/testing/_private/utils.py:705: UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray.
    y = array(y, copy=False, subok=True)

tests/test_xarray.py: 1 warning
tests/calc/test_calc_tools.py: 20 warnings
tests/calc/test_cross_sections.py: 22 warnings
tests/calc/test_indices.py: 1 warning
tests/interpolate/test_slices.py: 2 warnings
tests/io/test_metar.py: 12 warnings
tests/plots/test_declarative.py: 4 warnings
tests/plots/test_skewt.py: 1 warning
  /opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/numpy/core/_asarray.py:102: UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray.
    return array(a, dtype, copy=False, order=order)

tests/test_xarray.py::test_preprocess_and_wrap_with_variable
  /opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/metpy/xarray.py:1192: UserWarning: Argument b given as xarray Variable...casting to its data. xarray DataArrays are recommended instead.
    warnings.warn(

tests/test_xarray.py::test_preprocess_and_wrap_with_variable
  /opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/metpy/xarray.py:1192: UserWarning: Argument a given as xarray Variable...casting to its data. xarray DataArrays are recommended instead.
    warnings.warn(

tests/calc/test_basic.py: 11 warnings
tests/plots/test_skewt.py: 5 warnings
  /opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/numpy/ma/core.py:2825: UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray.
    _data = np.array(data, dtype=dtype, copy=copy,

tests/calc/test_basic.py::test_apparent_temperature_scalar
tests/calc/test_basic.py::test_apparent_temperature_windchill
tests/calc/test_thermo.py::test_saturation_equivalent_potential_temperature_masked
  /opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/numpy/ma/core.py:711: UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray.
    data = np.array(a, copy=False, subok=subok)

tests/calc/test_calc_tools.py: 11 warnings
  /opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/pint/quantity.py:1860: UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray.
    self._magnitude[key] = value

tests/calc/test_calc_tools.py::test_first_derivative_xarray_lonlat
tests/calc/test_calc_tools.py::test_first_derivative_xarray_lonlat
tests/calc/test_calc_tools.py::test_second_derivative_xarray_lonlat
tests/calc/test_calc_tools.py::test_second_derivative_xarray_lonlat
tests/calc/test_calc_tools.py::test_gradient_xarray
tests/calc/test_calc_tools.py::test_gradient_xarray
tests/calc/test_calc_tools.py::test_laplacian_xarray_lonlat
tests/calc/test_calc_tools.py::test_laplacian_xarray_lonlat
  /opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/xarray/core/variable.py:121: DeprecationWarning: Using a DataArray object to construct a variable is ambiguous, please extract the data using the .data property. This will raise a TypeError in 0.19.0.
    warnings.warn(

tests/calc/test_kinematics.py::test_advection_xarray
  /opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/metpy/xarray.py:1471: UserWarning: Vertical dimension number not found. Defaulting to (..., Z, Y, X) order.
    warnings.warn(

tests/plots/test_declarative.py::test_plotobs_units_with_formatter
  /home/runner/work/MetPy/MetPy/tests/plots/test_declarative.py:732: UserWarning: Pandas doesn't allow columns to be created via a new attribute name - see https://pandas.pydata.org/pandas-docs/stable/indexing.html#attribute-access
    df.units = {'alti': 'inHg'}

tests/plots/test_declarative.py::test_declarative_upa_obs_convert_barb_units
tests/plots/test_declarative.py::test_declarative_upa_obs_convert_barb_units
tests/plots/test_station_plot.py::test_barb_projection_list
tests/plots/test_station_plot.py::test_arrow_projection_list
tests/plots/test_station_plot.py::test_barb_unit_conversion
tests/plots/test_station_plot.py::test_arrow_unit_conversion
tests/plots/test_station_plot.py::test_barb_no_default_unit_conversion
  /opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/metpy/plots/station_plot.py:340: UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray.
    u = np.array(u)

tests/plots/test_declarative.py::test_declarative_upa_obs_convert_barb_units
tests/plots/test_declarative.py::test_declarative_upa_obs_convert_barb_units
tests/plots/test_station_plot.py::test_barb_projection_list
tests/plots/test_station_plot.py::test_arrow_projection_list
tests/plots/test_station_plot.py::test_barb_unit_conversion
tests/plots/test_station_plot.py::test_arrow_unit_conversion
tests/plots/test_station_plot.py::test_barb_no_default_unit_conversion
  /opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/metpy/plots/station_plot.py:341: UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray.
    v = np.array(v)

tests/plots/test_skewt.py::test_skewt_api_units
tests/plots/test_skewt.py::test_skewt_barb_unit_conversion
tests/plots/test_skewt.py::test_skewt_barb_no_default_unit_conversion
  /opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/numpy/ma/core.py:2357: UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray.
    a = np.array(a, copy=copy, subok=True)

tests/plots/test_skewt.py::test_hodograph_api
tests/plots/test_skewt.py::test_hodograph_units
tests/plots/test_skewt.py::test_hodograph_plot_colormapped
tests/plots/test_skewt.py::test_hodograph_plot_layers
tests/plots/test_skewt.py::test_hodograph_plot_layers_different_units
tests/plots/test_skewt.py::test_hodograph_plot_layers_bound_units
tests/plots/test_skewt.py::test_hodograph_plot_arbitrary_layer
  /opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/numpy/lib/stride_tricks.py:97: UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray.
    x = np.array(x, copy=False, subok=subok)

-- Docs: https://docs.pytest.org/en/stable/warnings.html
=========================== short test summary info ============================
FAILED tests/calc/test_basic.py::test_heat_index_invalid - pint.errors.Dimens...
FAILED tests/calc/test_basic.py::test_heat_index_undefined_flag - pint.errors...
=========== 2 failed, 1122 passed, 147 warnings in 219.13s (0:03:39) ===========
jthielen commented 3 years ago

This looks to be caused by https://github.com/hgrecco/pint/pull/1282 and an order of operations change in https://github.com/Unidata/MetPy/pull/1819/commits/c7b0b9b9db3b895dbc38fc231412d3b1c6baa2fd. I would guess that the best fix would be reworking the dimensionality of rh15adj to be more similar to the original formulation prior to https://github.com/Unidata/MetPy/pull/1819/commits/c7b0b9b9db3b895dbc38fc231412d3b1c6baa2fd (i.e., multiplying by 1/17 delta_degF instead of dividing by 17 delta_degF) so that we don't try changing the units of a dimensionless quantity, and just get the quantity in its proper delta temperature units.