Created
July 27, 2019 02:28
-
-
Save jthielen/f24c9a953ff4edc3a795179638a77f5e to your computer and use it in GitHub Desktop.
Results of a run of pytest with the current master branches of MetPy and pint (as of 2019-07-26)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
============================= test session starts ============================== | |
platform linux -- Python 3.7.3, pytest-4.6.2, py-1.8.0, pluggy-0.12.0 | |
Matplotlib: 3.0.2 | |
Freetype: 2.6.1 | |
Dependencies: Matplotlib (3.0.2), NumPy (1.16.4), Pint (0.10.dev0), SciPy (1.3.0) | |
rootdir: /home/jon/dev/MetPy, inifile: setup.cfg | |
plugins: flake8-1.0.4, cov-2.7.1, mpl-0.10 | |
collected 878 items | |
metpy/calc/tests/test_basic.py ............................FF.F.....F... [ 4%] | |
...............F.F. [ 6%] | |
metpy/calc/tests/test_calc_tools.py ...............................F.F.. [ 10%] | |
...F............F................................................. [ 18%] | |
metpy/calc/tests/test_cross_sections.py ............ [ 19%] | |
metpy/calc/tests/test_indices.py ............... [ 21%] | |
metpy/calc/tests/test_kinematics.py .................................... [ 25%] | |
.....FF........F [ 27%] | |
metpy/calc/tests/test_thermo.py ........................................ [ 32%] | |
......................FF..............FF................F.....FFFF...... [ 40%] | |
[ 40%] | |
metpy/calc/tests/test_turbulence.py ........................... [ 43%] | |
metpy/interpolate/tests/test_geometry.py ............. [ 44%] | |
metpy/interpolate/tests/test_grid.py ................................... [ 48%] | |
...... [ 49%] | |
metpy/interpolate/tests/test_interpolate_tools.py ...... [ 50%] | |
metpy/interpolate/tests/test_one_dimension.py ................. [ 52%] | |
metpy/interpolate/tests/test_points.py ............... [ 53%] | |
metpy/interpolate/tests/test_slices.py ....... [ 54%] | |
metpy/io/tests/test_gini.py .......... [ 55%] | |
metpy/io/tests/test_nexrad.py .......................................... [ 60%] | |
........................................................................ [ 68%] | |
................ [ 70%] | |
metpy/plots/tests/test_cartopy_utils.py .... [ 70%] | |
metpy/plots/tests/test_ctables.py .......... [ 72%] | |
metpy/plots/tests/test_declarative.py .............. [ 73%] | |
metpy/plots/tests/test_mapping.py ................. [ 75%] | |
metpy/plots/tests/test_mpl.py . [ 75%] | |
metpy/plots/tests/test_skewt.py ........................x [ 78%] | |
metpy/plots/tests/test_station_plot.py .................. [ 80%] | |
metpy/plots/tests/test_util.py ............. [ 82%] | |
metpy/plots/tests/test_wx_symbols.py ... [ 82%] | |
metpy/tests/test_cbook.py . [ 82%] | |
metpy/tests/test_deprecation.py . [ 82%] | |
metpy/tests/test_gridding.py . [ 82%] | |
metpy/tests/test_units.py ..FF...................... [ 85%] | |
metpy/tests/test_xarray.py ......F...................................... [ 90%] | |
........................................................................ [ 99%] | |
........ [100%] | |
=================================== FAILURES =================================== | |
_________________________ test_height_to_geopotential __________________________ | |
def test_height_to_geopotential(): | |
"""Test conversion from height to geopotential.""" | |
height = units.Quantity([0, 1000, 2000, 3000], units.m) | |
geopot = height_to_geopotential(height) | |
assert_array_almost_equal(geopot, units.Quantity([0., 9817, 19632, | |
> 29443], units('m**2 / second**2')), 0) | |
metpy/calc/tests/test_basic.py:293: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = array([ 0. , 9818.14474002, 19633.20840782, 29445.19245349]) | |
desired = array([ 0., 9817., 19632., 29443.]), decimal = 0 | |
def assert_array_almost_equal(actual, desired, decimal=7): | |
"""Check that arrays are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_array_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_array_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 0 decimals | |
E | |
E Mismatch: 25% | |
E Max absolute difference: 2.19245349 | |
E Max relative difference: nan | |
E x: array([ 0., 9818., 19633., 29445.]) | |
E y: array([ 0., 9817., 19632., 29443.]) | |
metpy/testing.py:160: AssertionError | |
______________________ test_height_to_geopotential_32bit _______________________ | |
def test_height_to_geopotential_32bit(): | |
"""Test conversion to geopotential with 32-bit values.""" | |
heights = np.linspace(20597, 20598, 11, dtype=np.float32) * units.m | |
truth = np.array([201590.422, 201591.391, 201592.375, 201593.344, | |
201594.312, 201595.297, 201596.266, 201597.250, | |
201598.219, 201599.203, 201600.172], dtype=np.float32) * units('J/kg') | |
> assert_almost_equal(height_to_geopotential(heights), truth, 2) | |
metpy/calc/tests/test_basic.py:303: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = array([201604.31, 201605.28, 201606.27, 201607.23, 201608.22, 201609.19, | |
201610.17, 201611.14, 201612.12, 201613.1 , 201614.06], | |
dtype=float32) | |
desired = array([201590.42, 201591.39, 201592.38, 201593.34, 201594.31, 201595.3 , | |
201596.27, 201597.25, 201598.22, 201599.2 , 201600.17], | |
dtype=float32) | |
decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E | |
E Mismatch: 100% | |
E Max absolute difference: 13.90625 | |
E Max relative difference: 6.898136e-05 | |
E x: array([201604.31, 201605.28, 201606.27, 201607.23, 201608.22, 201609.19, | |
E 201610.17, 201611.14, 201612.12, 201613.1 , 201614.06], | |
E dtype=float32) | |
E y: array([201590.42, 201591.39, 201592.38, 201593.34, 201594.31, 201595.3 , | |
E 201596.27, 201597.25, 201598.22, 201599.2 , 201600.17], | |
E dtype=float32) | |
metpy/testing.py:151: AssertionError | |
______________________ test_geopotential_to_height_32bit _______________________ | |
def test_geopotential_to_height_32bit(): | |
"""Test conversion from geopotential to height with 32-bit values.""" | |
geopot = np.arange(201590, 201600, dtype=np.float32) * units('J/kg') | |
truth = np.array([20596.957, 20597.059, 20597.162, 20597.266, | |
20597.365, 20597.469, 20597.570, 20597.674, | |
20597.777, 20597.881], dtype=np.float32) * units.m | |
> assert_almost_equal(geopotential_to_height(geopot), truth, 2) | |
metpy/calc/tests/test_basic.py:321: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = array([20595.531, 20595.635, 20595.736, 20595.84 , 20595.941, 20596.045, | |
20596.146, 20596.25 , 20596.354, 20596.455], dtype=float32) | |
desired = array([20596.957, 20597.059, 20597.162, 20597.266, 20597.365, 20597.469, | |
20597.57 , 20597.674, 20597.777, 20597.88 ], dtype=float32) | |
decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E | |
E Mismatch: 100% | |
E Max absolute difference: 1.4257812 | |
E Max relative difference: 6.922291e-05 | |
E x: array([20595.53, 20595.63, 20595.74, 20595.84, 20595.94, 20596.04, | |
E 20596.15, 20596.25, 20596.35, 20596.46], dtype=float32) | |
E y: array([20596.96, 20597.06, 20597.16, 20597.27, 20597.37, 20597.47, | |
E 20597.57, 20597.67, 20597.78, 20597.88], dtype=float32) | |
metpy/testing.py:151: AssertionError | |
_________________________ test_add_pressure_to_height __________________________ | |
def test_add_pressure_to_height(): | |
"""Test the height at pressure above height calculation.""" | |
height = add_pressure_to_height(110.8286757 * units.m, 100 * units.hPa) | |
> assert_almost_equal(height, 988.0028867 * units.meter, 5) | |
metpy/calc/tests/test_basic.py:398: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 988.0029400097312, desired = 988.0028867, decimal = 5 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 5 decimals | |
E ACTUAL: 988.0029400097312 | |
E DESIRED: 988.0028867 | |
metpy/testing.py:151: AssertionError | |
___________________ test_altimeter_to_station_pressure_inhg ____________________ | |
def test_altimeter_to_station_pressure_inhg(): | |
"""Test the altimeter to station pressure function with inches of mercury.""" | |
altim = 29.8 * units.inHg | |
elev = 500 * units.m | |
> res = altimeter_to_station_pressure(altim, elev) | |
metpy/calc/tests/test_basic.py:637: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
metpy/xarray.py:457: in wrapper | |
return func(*args, **kwargs) | |
metpy/calc/basic.py:919: in altimeter_to_station_pressure | |
return ((altimeter_value ** n - ((p0 ** n * gamma * height) / t0)) ** (1 / n) + ( | |
../pint/pint/quantity.py:830: in __sub__ | |
return self._add_sub(other, operator.sub) | |
../pint/pint/quantity.py:76: in wrapped | |
result = f(self, *args, **kwargs) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <Quantity(1.9076292329237703, 'inch_Hg ** 0.190267')> | |
other = <Quantity(0.04210930305337787, 'hectopascal ** 0.190267')> | |
op = <built-in function sub> | |
@check_implemented | |
def _add_sub(self, other, op): | |
"""Perform addition or subtraction operation and return the result. | |
:param other: object to be added to / subtracted from self | |
:type other: Quantity or any type accepted by :func:`_to_magnitude` | |
:param op: operator function (e.g. operator.add, operator.isub) | |
:type op: function | |
""" | |
if not self._check(other): | |
# other not from same Registry or not a Quantity | |
if _eq(other, 0, True): | |
# If the other value is 0 (but not Quantity 0) | |
# do the operation without checking units. | |
# We do the calculation instead of just returning the same | |
# value to enforce any shape checking and type casting due to | |
# the operation. | |
units = self._units | |
magnitude = op(self._magnitude, | |
_to_magnitude(other, self.force_ndarray)) | |
elif self.dimensionless: | |
units = UnitsContainer() | |
magnitude = op(self.to(units)._magnitude, | |
_to_magnitude(other, self.force_ndarray)) | |
else: | |
raise DimensionalityError(self._units, 'dimensionless') | |
return self.__class__(magnitude, units) | |
if not self.dimensionality == other.dimensionality: | |
raise DimensionalityError(self._units, other._units, | |
self.dimensionality, | |
> other.dimensionality) | |
E pint.errors.DimensionalityError: Cannot convert from 'inch_Hg ** 0.190267' ([mass] ** 0.190267 / [length] ** 0.190267 / [time] ** 0.380533) to 'hectopascal ** 0.190267' ([mass] ** 0.190267 / [length] ** 0.190267 / [time] ** 0.380533) | |
../pint/pint/quantity.py:736: DimensionalityError | |
__________________ test_altimiter_to_sea_level_pressure_inhg ___________________ | |
def test_altimiter_to_sea_level_pressure_inhg(): | |
"""Test the altimeter to sea level pressure function with inches of mercury.""" | |
altim = 29.8 * units.inHg | |
elev = 500 * units.m | |
temp = 30 * units.degC | |
> res = altimeter_to_sea_level_pressure(altim, elev, temp) | |
metpy/calc/tests/test_basic.py:656: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
metpy/xarray.py:457: in wrapper | |
return func(*args, **kwargs) | |
metpy/calc/basic.py:985: in altimeter_to_sea_level_pressure | |
psfc = altimeter_to_station_pressure(altimeter_value, height) | |
metpy/xarray.py:457: in wrapper | |
return func(*args, **kwargs) | |
metpy/calc/basic.py:919: in altimeter_to_station_pressure | |
return ((altimeter_value ** n - ((p0 ** n * gamma * height) / t0)) ** (1 / n) + ( | |
../pint/pint/quantity.py:830: in __sub__ | |
return self._add_sub(other, operator.sub) | |
../pint/pint/quantity.py:76: in wrapped | |
result = f(self, *args, **kwargs) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <Quantity(1.9076292329237703, 'inch_Hg ** 0.190267')> | |
other = <Quantity(0.04210930305337787, 'hectopascal ** 0.190267')> | |
op = <built-in function sub> | |
@check_implemented | |
def _add_sub(self, other, op): | |
"""Perform addition or subtraction operation and return the result. | |
:param other: object to be added to / subtracted from self | |
:type other: Quantity or any type accepted by :func:`_to_magnitude` | |
:param op: operator function (e.g. operator.add, operator.isub) | |
:type op: function | |
""" | |
if not self._check(other): | |
# other not from same Registry or not a Quantity | |
if _eq(other, 0, True): | |
# If the other value is 0 (but not Quantity 0) | |
# do the operation without checking units. | |
# We do the calculation instead of just returning the same | |
# value to enforce any shape checking and type casting due to | |
# the operation. | |
units = self._units | |
magnitude = op(self._magnitude, | |
_to_magnitude(other, self.force_ndarray)) | |
elif self.dimensionless: | |
units = UnitsContainer() | |
magnitude = op(self.to(units)._magnitude, | |
_to_magnitude(other, self.force_ndarray)) | |
else: | |
raise DimensionalityError(self._units, 'dimensionless') | |
return self.__class__(magnitude, units) | |
if not self.dimensionality == other.dimensionality: | |
raise DimensionalityError(self._units, other._units, | |
self.dimensionality, | |
> other.dimensionality) | |
E pint.errors.DimensionalityError: Cannot convert from 'inch_Hg ** 0.190267' ([mass] ** 0.190267 / [length] ** 0.190267 / [time] ** 0.380533) to 'hectopascal ** 0.190267' ([mass] ** 0.190267 / [length] ** 0.190267 / [time] ** 0.380533) | |
../pint/pint/quantity.py:736: DimensionalityError | |
_____ test_get_bound_pressure_height[pressure4-bound4-None-True-expected4] _____ | |
pressure = <Quantity([1000. 900. 800. 700. 600. 500. 400. 300. 200. 100.], 'hectopascal')> | |
bound = <Quantity(0.9880028, 'kilometer')>, hgts = None, interp = True | |
expected = (<Quantity(900, 'hectopascal')>, <Quantity(0.9880028, 'kilometer')>) | |
@pytest.mark.parametrize('pressure, bound, hgts, interp, expected', [ | |
(get_bounds_data()[0], 900 * units.hPa, None, True, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 900 * units.hPa, None, False, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 870 * units.hPa, None, True, | |
(870 * units.hPa, 1.2665298 * units.kilometer)), | |
(get_bounds_data()[0], 870 * units.hPa, None, False, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 0.9880028 * units.kilometer, None, True, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 0.9880028 * units.kilometer, None, False, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 1.2665298 * units.kilometer, None, True, | |
(870 * units.hPa, 1.2665298 * units.kilometer)), | |
(get_bounds_data()[0], 1.2665298 * units.kilometer, None, False, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 900 * units.hPa, get_bounds_data()[1], True, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 900 * units.hPa, get_bounds_data()[1], False, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 870 * units.hPa, get_bounds_data()[1], True, | |
(870 * units.hPa, 1.2643214 * units.kilometer)), | |
(get_bounds_data()[0], 870 * units.hPa, get_bounds_data()[1], False, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 0.9880028 * units.kilometer, get_bounds_data()[1], True, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 0.9880028 * units.kilometer, get_bounds_data()[1], False, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 1.2665298 * units.kilometer, get_bounds_data()[1], True, | |
(870.9869087 * units.hPa, 1.2665298 * units.kilometer)), | |
(get_bounds_data()[0], 1.2665298 * units.kilometer, get_bounds_data()[1], False, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 0.98800289 * units.kilometer, get_bounds_data()[1], True, | |
(900 * units.hPa, 0.9880028 * units.kilometer)) | |
]) | |
def test_get_bound_pressure_height(pressure, bound, hgts, interp, expected): | |
"""Test getting bounds in layers with various parameter combinations.""" | |
bounds = _get_bound_pressure_height(pressure, bound, heights=hgts, interpolate=interp) | |
> assert_array_almost_equal(bounds[0], expected[0], 5) | |
metpy/calc/tests/test_calc_tools.py:261: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = array(900.00001612), desired = 900, decimal = 5 | |
def assert_array_almost_equal(actual, desired, decimal=7): | |
"""Check that arrays are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_array_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_array_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 5 decimals | |
E | |
E Mismatch: 100% | |
E Max absolute difference: 1.61150167e-05 | |
E Max relative difference: 1.79055741e-08 | |
E x: array(900.00002) | |
E y: array(900) | |
metpy/testing.py:160: AssertionError | |
_____ test_get_bound_pressure_height[pressure6-bound6-None-True-expected6] _____ | |
pressure = <Quantity([1000. 900. 800. 700. 600. 500. 400. 300. 200. 100.], 'hectopascal')> | |
bound = <Quantity(1.2665298, 'kilometer')>, hgts = None, interp = True | |
expected = (<Quantity(870, 'hectopascal')>, <Quantity(1.2665298, 'kilometer')>) | |
@pytest.mark.parametrize('pressure, bound, hgts, interp, expected', [ | |
(get_bounds_data()[0], 900 * units.hPa, None, True, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 900 * units.hPa, None, False, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 870 * units.hPa, None, True, | |
(870 * units.hPa, 1.2665298 * units.kilometer)), | |
(get_bounds_data()[0], 870 * units.hPa, None, False, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 0.9880028 * units.kilometer, None, True, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 0.9880028 * units.kilometer, None, False, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 1.2665298 * units.kilometer, None, True, | |
(870 * units.hPa, 1.2665298 * units.kilometer)), | |
(get_bounds_data()[0], 1.2665298 * units.kilometer, None, False, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 900 * units.hPa, get_bounds_data()[1], True, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 900 * units.hPa, get_bounds_data()[1], False, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 870 * units.hPa, get_bounds_data()[1], True, | |
(870 * units.hPa, 1.2643214 * units.kilometer)), | |
(get_bounds_data()[0], 870 * units.hPa, get_bounds_data()[1], False, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 0.9880028 * units.kilometer, get_bounds_data()[1], True, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 0.9880028 * units.kilometer, get_bounds_data()[1], False, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 1.2665298 * units.kilometer, get_bounds_data()[1], True, | |
(870.9869087 * units.hPa, 1.2665298 * units.kilometer)), | |
(get_bounds_data()[0], 1.2665298 * units.kilometer, get_bounds_data()[1], False, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 0.98800289 * units.kilometer, get_bounds_data()[1], True, | |
(900 * units.hPa, 0.9880028 * units.kilometer)) | |
]) | |
def test_get_bound_pressure_height(pressure, bound, hgts, interp, expected): | |
"""Test getting bounds in layers with various parameter combinations.""" | |
bounds = _get_bound_pressure_height(pressure, bound, heights=hgts, interpolate=interp) | |
> assert_array_almost_equal(bounds[0], expected[0], 5) | |
metpy/calc/tests/test_calc_tools.py:261: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = array(870.00001703), desired = 870, decimal = 5 | |
def assert_array_almost_equal(actual, desired, decimal=7): | |
"""Check that arrays are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_array_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_array_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 5 decimals | |
E | |
E Mismatch: 100% | |
E Max absolute difference: 1.70334024e-05 | |
E Max relative difference: 1.95786234e-08 | |
E x: array(870.00002) | |
E y: array(870) | |
metpy/testing.py:160: AssertionError | |
__ test_get_bound_pressure_height[pressure12-bound12-hgts12-True-expected12] ___ | |
pressure = <Quantity([1000. 900. 800. 700. 600. 500. 400. 300. 200. 100.], 'hectopascal')> | |
bound = <Quantity(0.9880028, 'kilometer')> | |
hgts = <Quantity([ 0.11082868 0.98800295 1.94800727 3.01066437 4.20430412 5.57162493 | |
7.18180872 9.15932612 11.76894158 15.78930577], 'kilometer')> | |
interp = True | |
expected = (<Quantity(900, 'hectopascal')>, <Quantity(0.9880028, 'kilometer')>) | |
@pytest.mark.parametrize('pressure, bound, hgts, interp, expected', [ | |
(get_bounds_data()[0], 900 * units.hPa, None, True, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 900 * units.hPa, None, False, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 870 * units.hPa, None, True, | |
(870 * units.hPa, 1.2665298 * units.kilometer)), | |
(get_bounds_data()[0], 870 * units.hPa, None, False, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 0.9880028 * units.kilometer, None, True, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 0.9880028 * units.kilometer, None, False, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 1.2665298 * units.kilometer, None, True, | |
(870 * units.hPa, 1.2665298 * units.kilometer)), | |
(get_bounds_data()[0], 1.2665298 * units.kilometer, None, False, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 900 * units.hPa, get_bounds_data()[1], True, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 900 * units.hPa, get_bounds_data()[1], False, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 870 * units.hPa, get_bounds_data()[1], True, | |
(870 * units.hPa, 1.2643214 * units.kilometer)), | |
(get_bounds_data()[0], 870 * units.hPa, get_bounds_data()[1], False, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 0.9880028 * units.kilometer, get_bounds_data()[1], True, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 0.9880028 * units.kilometer, get_bounds_data()[1], False, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 1.2665298 * units.kilometer, get_bounds_data()[1], True, | |
(870.9869087 * units.hPa, 1.2665298 * units.kilometer)), | |
(get_bounds_data()[0], 1.2665298 * units.kilometer, get_bounds_data()[1], False, | |
(900 * units.hPa, 0.9880028 * units.kilometer)), | |
(get_bounds_data()[0], 0.98800289 * units.kilometer, get_bounds_data()[1], True, | |
(900 * units.hPa, 0.9880028 * units.kilometer)) | |
]) | |
def test_get_bound_pressure_height(pressure, bound, hgts, interp, expected): | |
"""Test getting bounds in layers with various parameter combinations.""" | |
bounds = _get_bound_pressure_height(pressure, bound, heights=hgts, interpolate=interp) | |
> assert_array_almost_equal(bounds[0], expected[0], 5) | |
metpy/calc/tests/test_calc_tools.py:261: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = array([900.00001682]), desired = 900, decimal = 5 | |
def assert_array_almost_equal(actual, desired, decimal=7): | |
"""Check that arrays are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_array_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_array_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 5 decimals | |
E | |
E Mismatch: 100% | |
E Max absolute difference: 1.68248043e-05 | |
E Max relative difference: 1.8694227e-08 | |
E x: array([900.00002]) | |
E y: array(900) | |
metpy/testing.py:160: AssertionError | |
____ test_get_layer[pressure2-variable2-None-bottom2-depth2-True-expected2] ____ | |
pressure = <Quantity([1000 900 800 700 600 500 400 300 200 100], 'hectopascal')> | |
variable = <Quantity([ 25. 16.66666667 8.33333333 0. -8.33333333 | |
-16.66666667 -25. -33.33333333 -41.66666667 -50. ], 'degree_Celsius')> | |
heights = None, bottom = <Quantity(2, 'kilometer')> | |
depth = <Quantity(3, 'kilometer')>, interp = True | |
expected = (<Quantity([794.85264282 700. 600. 540.01696548], 'hectopascal')>, <Quantity([ 7.93049516 0. -8.33333333 -13.14758845], 'degree_Celsius')>) | |
@pytest.mark.parametrize('pressure, variable, heights, bottom, depth, interp, expected', [ | |
(layer_test_data()[0], layer_test_data()[1], None, None, 150 * units.hPa, True, | |
(np.array([1000, 900, 850]) * units.hPa, | |
np.array([25.0, 16.666666, 12.62262]) * units.degC)), | |
(layer_test_data()[0], layer_test_data()[1], None, None, 150 * units.hPa, False, | |
(np.array([1000, 900]) * units.hPa, np.array([25.0, 16.666666]) * units.degC)), | |
(layer_test_data()[0], layer_test_data()[1], None, 2 * units.km, 3 * units.km, True, | |
(np.array([794.85264282, 700., 600., 540.01696548]) * units.hPa, | |
np.array([7.93049516, 0., -8.33333333, -13.14758845]) * units.degC)) | |
]) | |
def test_get_layer(pressure, variable, heights, bottom, depth, interp, expected): | |
"""Test get_layer functionality.""" | |
p_layer, y_layer = get_layer(pressure, variable, heights=heights, bottom=bottom, | |
depth=depth, interpolate=interp) | |
> assert_array_almost_equal(p_layer, expected[0], 5) | |
metpy/calc/tests/test_calc_tools.py:349: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = array([794.85265485, 700. , 600. , 540.01698666]) | |
desired = array([794.85264282, 700. , 600. , 540.01696548]) | |
decimal = 5 | |
def assert_array_almost_equal(actual, desired, decimal=7): | |
"""Check that arrays are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_array_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_array_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 5 decimals | |
E | |
E Mismatch: 25% | |
E Max absolute difference: 2.11808643e-05 | |
E Max relative difference: 3.92225906e-08 | |
E x: array([794.85265, 700. , 600. , 540.01699]) | |
E y: array([794.85264, 700. , 600. , 540.01697]) | |
metpy/testing.py:160: AssertionError | |
____________________ test_q_vector_without_static_stability ____________________ | |
q_vector_data = (<Quantity([[ 2.50000000e+01 8.68240888e+00 -8.68240888e+00 -2.50000000e+01] | |
[ 8.68240888e+00 -6.12323400e-15 -6.123...047447 185324.79047447 185324.79047447] | |
[185324.79047447 185324.79047447 185324.79047447 185324.79047447]], 'meter')>) | |
def test_q_vector_without_static_stability(q_vector_data): | |
"""Test the Q-vector function without using static stability.""" | |
u, v, temp, p, dx, dy = q_vector_data | |
# Treating as 700 hPa data | |
q1, q2 = q_vector(u, v, temp[1], p[1], dx, dy) | |
q1_truth = (np.array([[-2.7454089e-14, -3.0194267e-13, -3.0194267e-13, -2.7454089e-14], | |
[-1.8952185e-13, -2.2269905e-14, -2.2269905e-14, -1.8952185e-13], | |
[-1.9918390e-13, -2.3370829e-14, -2.3370829e-14, -1.9918390e-13], | |
[-5.6160772e-14, -3.5145951e-13, -3.5145951e-13, -5.6160772e-14]]) | |
* units('m^2 kg^-1 s^-1')) | |
q2_truth = (np.array([[-4.4976059e-14, -4.3582378e-13, 4.3582378e-13, 4.4976059e-14], | |
[-3.0124244e-13, -3.5724617e-14, 3.5724617e-14, 3.0124244e-13], | |
[3.1216232e-13, 3.6662900e-14, -3.6662900e-14, -3.1216232e-13], | |
[8.6038280e-14, 4.6968342e-13, -4.6968342e-13, -8.6038280e-14]]) | |
* units('m^2 kg^-1 s^-1')) | |
> assert_almost_equal(q1, q1_truth, 20) | |
metpy/calc/tests/test_kinematics.py:1062: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = array([[-2.74540907e-14, -3.01942689e-13, -3.01942689e-13, | |
-2.74540907e-14], | |
[-1.89521858e-13, -2.22699...07e-14, | |
-1.99183913e-13], | |
[-5.61607757e-14, -3.51459530e-13, -3.51459530e-13, | |
-5.61607757e-14]]) | |
desired = array([[-2.7454089e-14, -3.0194267e-13, -3.0194267e-13, -2.7454089e-14], | |
[-1.8952185e-13, -2.2269905e-14, -2.22...3370829e-14, -2.3370829e-14, -1.9918390e-13], | |
[-5.6160772e-14, -3.5145951e-13, -3.5145951e-13, -5.6160772e-14]]) | |
decimal = 20 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 20 decimals | |
E | |
E Mismatch: 25% | |
E Max absolute difference: 1.97713253e-20 | |
E Max relative difference: 7.30728665e-08 | |
E x: array([[-2.7454090723180448e-14, -3.0194268852999482e-13, | |
E -3.0194268852998139e-13, -2.7454090723230513e-14], | |
E [-1.8952185792609708e-13, -2.2269906036398466e-14,... | |
E y: array([[-2.7454089e-14, -3.0194267e-13, -3.0194267e-13, -2.7454089e-14], | |
E [-1.8952185e-13, -2.2269905e-14, -2.2269905e-14, -1.8952185e-13], | |
E [-1.9918390e-13, -2.3370829e-14, -2.3370829e-14, -1.9918390e-13], | |
E [-5.6160772e-14, -3.5145951e-13, -3.5145951e-13, -5.6160772e-14]]) | |
metpy/testing.py:151: AssertionError | |
_____________________ test_q_vector_with_static_stability ______________________ | |
q_vector_data = (<Quantity([[ 2.50000000e+01 8.68240888e+00 -8.68240888e+00 -2.50000000e+01] | |
[ 8.68240888e+00 -6.12323400e-15 -6.123...047447 185324.79047447 185324.79047447] | |
[185324.79047447 185324.79047447 185324.79047447 185324.79047447]], 'meter')>) | |
def test_q_vector_with_static_stability(q_vector_data): | |
"""Test the Q-vector function using static stability.""" | |
u, v, temp, p, dx, dy = q_vector_data | |
sigma = static_stability(p[:, np.newaxis, np.newaxis], temp) | |
# Treating as 700 hPa data | |
q1, q2 = q_vector(u, v, temp[1], p[1], dx, dy, sigma[1]) | |
q1_truth = (np.array([[-1.4158140e-08, -1.6197987e-07, -1.6875014e-07, -1.6010616e-08], | |
[-9.3971386e-08, -1.1252476e-08, -1.1252476e-08, -9.7617234e-08], | |
[-1.0785670e-07, -1.2403513e-08, -1.2403513e-08, -1.0364793e-07], | |
[-2.9186946e-08, -1.7577703e-07, -1.6937879e-07, -2.6112047e-08]]) | |
* units('kg m^-2 s^-3')) | |
q2_truth = (np.array([[-2.3194263e-08, -2.3380160e-07, 2.4357380e-07, 2.6229040e-08], | |
[-1.4936626e-07, -1.8050836e-08, 1.8050836e-08, 1.5516129e-07], | |
[1.6903373e-07, 1.9457964e-08, -1.9457964e-08, -1.6243771e-07], | |
[4.4714390e-08, 2.3490489e-07, -2.2635441e-07, -4.0003646e-08]]) | |
* units('kg m^-2 s^-3')) | |
> assert_almost_equal(q1, q1_truth, 14) | |
metpy/calc/tests/test_kinematics.py:1086: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = array([[-1.41581383e-08, -1.61979842e-07, -1.68750114e-07, | |
-1.60106130e-08], | |
[-9.39713720e-08, -1.12524...11e-08, | |
-1.03647910e-07], | |
[-2.91869419e-08, -1.75777003e-07, -1.69378764e-07, | |
-2.61120434e-08]]) | |
desired = array([[-1.4158140e-08, -1.6197987e-07, -1.6875014e-07, -1.6010616e-08], | |
[-9.3971386e-08, -1.1252476e-08, -1.12...2403513e-08, -1.2403513e-08, -1.0364793e-07], | |
[-2.9186946e-08, -1.7577703e-07, -1.6937879e-07, -2.6112047e-08]]) | |
decimal = 14 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 14 decimals | |
E | |
E Mismatch: 37.5% | |
E Max absolute difference: 2.83183781e-14 | |
E Max relative difference: 1.92526432e-07 | |
E x: array([[-1.41581383039852e-08, -1.61979841681622e-07, | |
E -1.68750114288469e-07, -1.60106129998105e-08], | |
E [-9.39713719856350e-08, -1.12524745467649e-08,... | |
E y: array([[-1.4158140e-08, -1.6197987e-07, -1.6875014e-07, -1.6010616e-08], | |
E [-9.3971386e-08, -1.1252476e-08, -1.1252476e-08, -9.7617234e-08], | |
E [-1.0785670e-07, -1.2403513e-08, -1.2403513e-08, -1.0364793e-07], | |
E [-2.9186946e-08, -1.7577703e-07, -1.6937879e-07, -2.6112047e-08]]) | |
metpy/testing.py:151: AssertionError | |
_______________________________ test_q_vector_4d _______________________________ | |
data_4d = D_4D_Test_Data(height=<Quantity([[[[5661.239 5572.5986 5500.839 5511.0386] | |
[5682.6787 5607.1587 5550.7188 5547.27...222107.84922049 -222107.84922049]]]], 'meter')>, latitude=<Quantity([[[[46.] | |
[44.] | |
[42.] | |
[40.]]]], 'degree')>) | |
def test_q_vector_4d(data_4d): | |
"""Test q_vector on a 4D (time, pressure, y, x) grid.""" | |
f = coriolis_parameter(data_4d.latitude) | |
u_g, v_g = geostrophic_wind(data_4d.height, f, data_4d.dx, data_4d.dy) | |
q1, q2 = q_vector(u_g, v_g, data_4d.temperature, data_4d.pressure, data_4d.dx, data_4d.dy) | |
q1_truth = np.array([[[[-8.98245364e-13, 2.03803219e-13, 2.88874668e-12, 2.18043424e-12], | |
[4.37446820e-13, 1.21145200e-13, 1.51859353e-12, 3.82803347e-12], | |
[-1.20538030e-12, 2.27477298e-12, 3.47570178e-12, 3.03123012e-12], | |
[-1.51597275e-12, 8.02915408e-12, 7.71292472e-12, -2.22078527e-12]], | |
[[5.72960497e-13, 1.04264321e-12, -1.75695523e-13, 1.20745997e-12], | |
[2.94807953e-13, 5.80261767e-13, 6.23668595e-13, 7.31474131e-13], | |
[-4.04218965e-14, 3.24794013e-13, 1.39539675e-12, 2.82242029e-12], | |
[3.27509076e-13, 5.61307677e-13, 1.13454829e-12, 4.63551274e-12]], | |
[[2.23877015e-13, 5.77177907e-13, 1.62133659e-12, 5.43858376e-13], | |
[2.65333917e-13, 2.41006445e-13, 3.72510595e-13, 7.35822030e-13], | |
[6.56644633e-14, 1.99773842e-13, 5.20573457e-13, 1.69706608e-12], | |
[4.15915138e-14, 1.19910880e-13, 1.03632944e-12, 1.99561829e-12]]], | |
[[[-2.68870846e-13, 1.35977736e-12, 4.17548337e-12, 1.50465522e-12], | |
[4.62457018e-14, 1.25888111e-13, 2.15928418e-12, 4.70656495e-12], | |
[-1.25393137e-12, 9.54737370e-13, 1.48443002e-12, 2.12375621e-12], | |
[-2.93284658e-12, 6.06555344e-12, 4.21151397e-12, -2.12250513e-12]], | |
[[4.23461674e-13, 1.39393686e-13, 5.89509120e-13, 2.55041326e-12], | |
[5.73125714e-13, 5.60965341e-13, 7.65040451e-13, 9.49571939e-13], | |
[2.17153819e-14, 3.97023968e-13, 1.09194718e-12, 1.90731542e-12], | |
[1.45101233e-13, 1.79588608e-13, 1.03018848e-12, 3.62186462e-12]], | |
[[5.32674437e-13, 5.13465061e-13, 1.15582657e-12, 1.04827520e-12], | |
[2.77261345e-13, 2.33645555e-13, 4.59592371e-13, 5.34293340e-13], | |
[1.47376125e-13, 1.95746242e-13, 3.45854003e-13, 7.47741411e-13], | |
[-2.14078421e-14, 1.75226662e-13, 4.85424103e-13, 1.10808035e-12]]], | |
[[[6.41348753e-13, 1.88256910e-12, 5.21213092e-12, 2.07707653e-12], | |
[1.30753737e-12, 4.77125469e-13, 2.15204760e-12, 3.07374453e-12], | |
[-2.30546806e-13, 2.49929428e-13, 8.82215204e-14, 2.45990265e-12], | |
[-7.25812141e-12, 8.47072439e-13, -2.06762495e-12, | |
-4.40132129e-12]], | |
[[6.03705941e-13, -6.71320661e-13, 9.10543636e-13, 5.82480651e-13], | |
[9.54081741e-13, 6.11781160e-13, 6.95995265e-13, 8.67169047e-13], | |
[7.86580678e-14, 5.27405484e-13, 7.45800341e-13, 1.33965768e-12], | |
[2.22480631e-13, -1.98920384e-13, 8.56608245e-13, 1.59793218e-12]], | |
[[4.47195537e-13, 2.18235390e-13, 3.30926531e-13, -4.06675908e-14], | |
[1.70517246e-13, 2.18234962e-13, 3.78622612e-13, 5.03962144e-13], | |
[2.59462161e-13, 2.65626826e-13, 2.04642555e-13, 6.02812047e-13], | |
[1.69339642e-13, 2.91716502e-13, -1.20043003e-14, | |
4.43770388e-13]]]]) * units('m^2 kg^-1 s^-1') | |
q2_truth = np.array([[[[3.33980776e-12, -1.32969763e-13, 1.01454470e-12, 6.02652581e-12], | |
[2.52898242e-13, -1.71069245e-13, -8.24708561e-13, 1.66384429e-13], | |
[-3.50646511e-12, -1.68929195e-12, 7.76215111e-13, 1.54486058e-12], | |
[-1.75492099e-12, -3.86524071e-12, -1.89368596e-12, | |
-5.14689517e-12]], | |
[[-2.09848775e-13, -6.25683634e-13, -1.40009292e-13, 1.08972893e-12], | |
[-2.58259284e-13, -2.67211578e-13, -6.41928957e-14, 5.90625597e-13], | |
[-2.73346325e-13, -2.28248227e-13, -4.76577835e-13, | |
-8.48559875e-13], | |
[1.21003124e-12, -5.10541546e-13, 6.35947149e-14, 2.44893915e-12]], | |
[[-6.72309334e-14, -3.56791270e-13, -4.13553842e-14, 3.81212108e-13], | |
[-3.55860413e-13, -1.22880634e-13, -3.19443665e-14, | |
-4.71232601e-14], | |
[-2.82289531e-13, -1.20965929e-13, 1.14160715e-13, -6.85113982e-14], | |
[5.17465531e-14, -4.61129211e-13, 5.33793701e-13, 1.28285338e-12]]], | |
[[[1.71894904e-12, -1.35675428e-12, 1.48328005e-13, 3.22454170e-12], | |
[-2.12666583e-13, -1.17551681e-13, -6.93968059e-13, 1.76659826e-12], | |
[-2.67906914e-12, -3.78250861e-13, -9.88730956e-13, 2.88200442e-12], | |
[1.48225123e-12, 2.15004833e-13, -4.84554577e-12, 2.77242999e-12]], | |
[[-3.09626209e-13, -2.52138997e-13, 4.58311589e-14, 2.03206766e-12], | |
[-3.95662347e-13, -2.99828956e-13, 1.08715446e-14, 1.06096030e-12], | |
[-2.46502471e-13, -2.43524217e-13, -3.81250581e-13, | |
-1.70270366e-13], | |
[8.12479206e-13, -1.38629628e-13, -8.05591138e-13, | |
-7.80286006e-13]], | |
[[-2.19626566e-13, -1.52852503e-13, 4.07706963e-13, 1.52323163e-12], | |
[-2.56235985e-13, -1.20817691e-13, 6.51260820e-15, 3.49591511e-13], | |
[-2.44063890e-13, -1.21871642e-13, -9.09798480e-14, | |
-1.59903476e-13], | |
[-2.47929201e-13, -1.77269110e-13, -1.12991330e-13, | |
-6.06795348e-13]]], | |
[[[-6.48288201e-13, -1.96951432e-12, -5.53508048e-13, 1.94507133e-12], | |
[-2.00769011e-12, -3.72469047e-13, -4.59116219e-13, 1.11322705e-13], | |
[-3.83507643e-12, 1.18054543e-13, -4.24001455e-13, -5.88688871e-13], | |
[-1.84528711e-12, 1.54974343e-12, -7.36123184e-13, 1.06256777e-13]], | |
[[-4.58487019e-13, -1.89124158e-13, 2.58416604e-13, 8.14652306e-13], | |
[-6.09664269e-13, -3.51509413e-13, 2.39576397e-13, 5.80539044e-13], | |
[-1.68850738e-13, -3.49553817e-13, -2.26470205e-13, 7.79989044e-13], | |
[2.23081718e-13, 1.20195366e-13, -1.01508013e-12, -2.15527487e-13]], | |
[[-1.68054338e-13, -5.06878852e-14, 2.77697698e-13, 8.37521961e-13], | |
[-1.39462599e-13, -1.36628363e-13, 3.13920124e-14, 4.55413406e-13], | |
[-1.06658890e-13, -2.19817426e-13, -8.35968065e-14, 1.88190788e-13], | |
[-2.27182863e-13, -2.74607819e-13, -1.10587309e-13, | |
-3.88915866e-13]]]]) * units('m^2 kg^-1 s^-1') | |
> assert_array_almost_equal(q1, q1_truth, 20) | |
metpy/calc/tests/test_kinematics.py:1702: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = array([[[[-8.98245420e-13, 2.03803231e-13, 2.88874686e-12, | |
2.18043437e-12], | |
[ 4.37446848e-13, 1... 6.02812085e-13], | |
[ 1.69339653e-13, 2.91716520e-13, -1.20043010e-14, | |
4.43770416e-13]]]]) | |
desired = array([[[[-8.98245364e-13, 2.03803219e-13, 2.88874668e-12, | |
2.18043424e-12], | |
[ 4.37446820e-13, 1... 6.02812047e-13], | |
[ 1.69339642e-13, 2.91716502e-13, -1.20043003e-14, | |
4.43770388e-13]]]]) | |
decimal = 20 | |
def assert_array_almost_equal(actual, desired, decimal=7): | |
"""Check that arrays are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_array_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_array_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 20 decimals | |
E | |
E Mismatch: 77.8% | |
E Max absolute difference: 5.00771366e-19 | |
E Max relative difference: 6.59987194e-08 | |
E x: array([[[[-8.9824541957213273e-13, 2.0380323138284710e-13, | |
E 2.8887468637244123e-12, 2.1804343746946653e-12], | |
E [ 4.3744684750934834e-13, 1.2114520784515458e-13,... | |
E y: array([[[[-8.98245364e-13, 2.03803219e-13, 2.88874668e-12, | |
E 2.18043424e-12], | |
E [ 4.37446820e-13, 1.21145200e-13, 1.51859353e-12,... | |
metpy/testing.py:160: AssertionError | |
________________________________ test_cape_cin _________________________________ | |
def test_cape_cin(): | |
"""Test the basic CAPE and CIN calculation.""" | |
p = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar | |
temperature = np.array([22.2, 14.6, 12., 9.4, 7., -38.]) * units.celsius | |
dewpoint = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius | |
parcel_prof = parcel_profile(p, temperature[0], dewpoint[0]) | |
cape, cin = cape_cin(p, temperature, dewpoint, parcel_prof) | |
> assert_almost_equal(cape, 75.7340825 * units('joule / kilogram'), 6) | |
metpy/calc/tests/test_thermo.py:698: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 75.73380786652106, desired = 75.7340825, decimal = 6 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 6 decimals | |
E ACTUAL: 75.73380786652106 | |
E DESIRED: 75.7340825 | |
metpy/testing.py:151: AssertionError | |
_____________________________ test_cape_cin_no_el ______________________________ | |
def test_cape_cin_no_el(): | |
"""Test that CAPE works with no EL.""" | |
p = np.array([959., 779.2, 751.3, 724.3]) * units.mbar | |
temperature = np.array([22.2, 14.6, 12., 9.4]) * units.celsius | |
dewpoint = np.array([19., -11.2, -10.8, -10.4]) * units.celsius | |
parcel_prof = parcel_profile(p, temperature[0], dewpoint[0]).to('degC') | |
cape, cin = cape_cin(p, temperature, dewpoint, parcel_prof) | |
assert_almost_equal(cape, 0.08610409 * units('joule / kilogram'), 6) | |
> assert_almost_equal(cin, -89.8179205 * units('joule / kilogram'), 6) | |
metpy/calc/tests/test_thermo.py:710: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = -89.81795976062058, desired = -89.8179205, decimal = 6 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 6 decimals | |
E ACTUAL: -89.81795976062058 | |
E DESIRED: -89.8179205 | |
metpy/testing.py:151: AssertionError | |
_________________________ test_surface_based_cape_cin __________________________ | |
def test_surface_based_cape_cin(): | |
"""Test the surface-based CAPE and CIN calculation.""" | |
p = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar | |
temperature = np.array([22.2, 14.6, 12., 9.4, 7., -38.]) * units.celsius | |
dewpoint = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius | |
cape, cin = surface_based_cape_cin(p, temperature, dewpoint) | |
> assert_almost_equal(cape, 75.7340825 * units('joule / kilogram'), 6) | |
metpy/calc/tests/test_thermo.py:952: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 75.73380786652106, desired = 75.7340825, decimal = 6 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 6 decimals | |
E ACTUAL: 75.73380786652106 | |
E DESIRED: 75.7340825 | |
metpy/testing.py:151: AssertionError | |
_____________________ test_most_unstable_cape_cin_surface ______________________ | |
def test_most_unstable_cape_cin_surface(): | |
"""Test the most unstable CAPE/CIN calculation when surface is most unstable.""" | |
pressure = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar | |
temperature = np.array([22.2, 14.6, 12., 9.4, 7., -38.]) * units.celsius | |
dewpoint = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius | |
mucape, mucin = most_unstable_cape_cin(pressure, temperature, dewpoint) | |
> assert_almost_equal(mucape, 75.7340825 * units('joule / kilogram'), 6) | |
metpy/calc/tests/test_thermo.py:962: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 75.73380786652106, desired = 75.7340825, decimal = 6 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 6 decimals | |
E ACTUAL: 75.73380786652106 | |
E DESIRED: 75.7340825 | |
metpy/testing.py:151: AssertionError | |
__________________________ test_wet_bulb_temperature ___________________________ | |
def test_wet_bulb_temperature(): | |
"""Test wet bulb calculation with scalars.""" | |
val = wet_bulb_temperature(1000 * units.hPa, 25 * units.degC, 15 * units.degC) | |
truth = 18.34345936 * units.degC # 18.59 from NWS calculator | |
> assert_almost_equal(val, truth) | |
metpy/calc/tests/test_thermo.py:1123: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 18.343459589135325, desired = 18.34345936, decimal = 7 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 7 decimals | |
E ACTUAL: 18.343459589135325 | |
E DESIRED: 18.34345936 | |
metpy/testing.py:151: AssertionError | |
____________________________ test_lfc_not_below_lcl ____________________________ | |
def test_lfc_not_below_lcl(): | |
"""Test sounding where LFC appears to be (but isn't) below LCL.""" | |
levels = np.array([1002.5, 1001.7, 1001., 1000.3, 999.7, 999., 998.2, 977.9, | |
966.2, 952.3, 940.6, 930.5, 919.8, 909.1, 898.9, 888.4, | |
878.3, 868.1, 858., 848., 837.2, 827., 816.7, 805.4]) * units.hPa | |
temperatures = np.array([17.9, 17.9, 17.8, 17.7, 17.7, 17.6, 17.5, 16., | |
15.2, 14.5, 13.8, 13., 12.5, 11.9, 11.4, 11., | |
10.3, 9.7, 9.2, 8.7, 8., 7.4, 6.8, 6.1]) * units.degC | |
dewpoints = np.array([13.6, 13.6, 13.5, 13.5, 13.5, 13.5, 13.4, 12.5, | |
12.1, 11.8, 11.4, 11.3, 11., 9.3, 10., 8.7, 8.9, | |
8.6, 8.1, 7.6, 7., 6.5, 6., 5.4]) * units.degC | |
lfc_pressure, lfc_temp = lfc(levels, temperatures, dewpoints) | |
# Before patch, LFC pressure would show 1000.5912165339967 hPa | |
> assert_almost_equal(lfc_pressure, 811.8263397 * units.mbar, 6) | |
metpy/calc/tests/test_thermo.py:1201: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 811.8262615743613, desired = 811.8263397, decimal = 6 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 6 decimals | |
E ACTUAL: 811.8262615743613 | |
E DESIRED: 811.8263397 | |
metpy/testing.py:151: AssertionError | |
______________________________ test_multiple_lfcs ______________________________ | |
def test_multiple_lfcs(): | |
"""Test sounding with multiple LFCs. | |
If which='top', return lowest-pressure LFC. | |
If which='all', return all LFCs | |
""" | |
levels = np.array([966., 937.2, 925., 904.6, 872.6, 853., 850., 836., 821., 811.6, 782.3, | |
754.2, 726.9, 700., 648.9, 624.6, 601.1, 595., 587., 576., 555.7, | |
534.2, 524., 500., 473.3, 400., 384.5, 358., 343., 308.3, 300., 276., | |
273., 268.5, 250., 244.2, 233., 200.]) * units.mbar | |
temperatures = np.array([18.2, 16.8, 16.2, 15.1, 13.3, 12.2, 12.4, 14., 14.4, | |
13.7, 11.4, 9.1, 6.8, 4.4, -1.4, -4.4, -7.3, -8.1, | |
-7.9, -7.7, -8.7, -9.8, -10.3, -13.5, -17.1, -28.1, -30.7, | |
-35.3, -37.1, -43.5, -45.1, -49.9, -50.4, -51.1, -54.1, -55., | |
-56.7, -57.5]) * units.degC | |
dewpoints = np.array([16.9, 15.9, 15.5, 14.2, 12.1, 10.8, 8.6, 0., -3.6, -4.4, | |
-6.9, -9.5, -12., -14.6, -15.8, -16.4, -16.9, -17.1, -27.9, -42.7, | |
-44.1, -45.6, -46.3, -45.5, -47.1, -52.1, -50.4, -47.3, -57.1, | |
-57.9, -58.1, -60.9, -61.4, -62.1, -65.1, -65.6, | |
-66.7, -70.5]) * units.degC | |
lfc_pressure_top, lfc_temp_top = lfc(levels, temperatures, dewpoints) | |
lfc_pressure_bottom, lfc_temp_bottom = lfc(levels, temperatures, dewpoints, | |
which='bottom') | |
lfc_pressure_all, _ = lfc(levels, temperatures, dewpoints, which='all') | |
> assert_almost_equal(lfc_pressure_top, 705.4346277 * units.mbar, 6) | |
metpy/calc/tests/test_thermo.py:1230: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 705.4345895435765, desired = 705.4346277, decimal = 6 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 6 decimals | |
E ACTUAL: 705.4345895435765 | |
E DESIRED: 705.4346277 | |
metpy/testing.py:151: AssertionError | |
______________________________ test_multiple_els _______________________________ | |
def test_multiple_els(): | |
"""Test sounding with multiple ELs. | |
If which='top', return lowest-pressure EL. | |
If which='all', return all ELs | |
""" | |
levels = np.array([966., 937.2, 925., 904.6, 872.6, 853., 850., 836., 821., 811.6, 782.3, | |
754.2, 726.9, 700., 648.9, 624.6, 601.1, 595., 587., 576., 555.7, | |
534.2, 524., 500., 473.3, 400., 384.5, 358., 343., 308.3, 300., 276., | |
273., 268.5, 250., 244.2, 233., 200.]) * units.mbar | |
temperatures = np.array([18.2, 16.8, 16.2, 15.1, 13.3, 12.2, 12.4, 14., 14.4, | |
13.7, 11.4, 9.1, 6.8, 4.4, -1.4, -4.4, -7.3, -8.1, | |
-7.9, -7.7, -8.7, -9.8, -10.3, -13.5, -17.1, -28.1, -30.7, | |
-35.3, -37.1, -43.5, -45.1, -49.9, -50.4, -51.1, -54.1, -55., | |
-56.7, -57.5]) * units.degC | |
dewpoints = np.array([16.9, 15.9, 15.5, 14.2, 12.1, 10.8, 8.6, 0., -3.6, -4.4, | |
-6.9, -9.5, -12., -14.6, -15.8, -16.4, -16.9, -17.1, -27.9, -42.7, | |
-44.1, -45.6, -46.3, -45.5, -47.1, -52.1, -50.4, -47.3, -57.1, | |
-57.9, -58.1, -60.9, -61.4, -62.1, -65.1, -65.6, | |
-66.7, -70.5]) * units.degC | |
el_pressure_top, el_temp_top = el(levels, temperatures, dewpoints) | |
el_pressure_bottom, el_temp_bottom = el(levels, temperatures, dewpoints, which='bottom') | |
el_pressure_all, _ = el(levels, temperatures, dewpoints, which='all') | |
> assert_almost_equal(el_pressure_top, 228.0575059 * units.mbar, 6) | |
metpy/calc/tests/test_thermo.py:1261: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 228.05753786963396, desired = 228.0575059, decimal = 6 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 6 decimals | |
E ACTUAL: 228.05753786963396 | |
E DESIRED: 228.0575059 | |
metpy/testing.py:151: AssertionError | |
_________________________ test_cape_cin_custom_profile _________________________ | |
def test_cape_cin_custom_profile(): | |
"""Test the CAPE and CIN calculation with a custom profile passed to LFC and EL.""" | |
p = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar | |
temperature = np.array([22.2, 14.6, 12., 9.4, 7., -38.]) * units.celsius | |
dewpoint = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius | |
parcel_prof = parcel_profile(p, temperature[0], dewpoint[0]) + 5 * units.delta_degC | |
cape, cin = cape_cin(p, temperature, dewpoint, parcel_prof) | |
> assert_almost_equal(cape, 1443.505086499895 * units('joule / kilogram'), 6) | |
metpy/calc/tests/test_thermo.py:1275: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 1443.5040016400164, desired = 1443.505086499895, decimal = 6 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 6 decimals | |
E ACTUAL: 1443.5040016400164 | |
E DESIRED: 1443.505086499895 | |
metpy/testing.py:151: AssertionError | |
_________________________________ test_axhline _________________________________ | |
self = <Quantity(930, 'millibar')>, key = 0 | |
def __getitem__(self, key): | |
try: | |
> value = self._magnitude[key] | |
E TypeError: 'int' object is not subscriptable | |
../pint/pint/quantity.py:1465: TypeError | |
During handling of the above exception, another exception occurred: | |
@pytest.mark.skipif(pint.__version__ == '0.9', reason=('Currently broken upstream (see ' | |
'pint#751')) | |
@pytest.mark.mpl_image_compare(tolerance=0, remove_text=True) | |
def test_axhline(): | |
r"""Ensure that passing a quantity to axhline does not error.""" | |
fig, ax = plt.subplots() | |
> ax.axhline(930 * units('mbar')) | |
metpy/tests/test_units.py:45: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
../../miniconda3/envs/dev/lib/python3.7/site-packages/matplotlib/axes/_axes.py:805: in axhline | |
yy = self.convert_yunits(y) | |
../../miniconda3/envs/dev/lib/python3.7/site-packages/matplotlib/artist.py:195: in convert_yunits | |
return ax.yaxis.convert_units(y) | |
../../miniconda3/envs/dev/lib/python3.7/site-packages/matplotlib/axis.py:1521: in convert_units | |
if munits.ConversionInterface.is_numlike(x): | |
../../miniconda3/envs/dev/lib/python3.7/site-packages/matplotlib/units.py:126: in is_numlike | |
for thisx in x: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <Quantity(930, 'millibar')>, key = 0 | |
def __getitem__(self, key): | |
try: | |
value = self._magnitude[key] | |
return self.__class__(value, self._units) | |
except TypeError: | |
raise TypeError("Neither Quantity object nor its magnitude ({})" | |
> "supports indexing".format(self._magnitude)) | |
E TypeError: Neither Quantity object nor its magnitude (930)supports indexing | |
../pint/pint/quantity.py:1469: TypeError | |
_________________________________ test_axvline _________________________________ | |
self = <Quantity(0, 'degree_Celsius')>, key = 0 | |
def __getitem__(self, key): | |
try: | |
> value = self._magnitude[key] | |
E TypeError: 'int' object is not subscriptable | |
../pint/pint/quantity.py:1465: TypeError | |
During handling of the above exception, another exception occurred: | |
@pytest.mark.skipif(pint.__version__ == '0.9', reason=('Currently broken upstream (see ' | |
'pint#751')) | |
@pytest.mark.mpl_image_compare(tolerance=0, remove_text=True) | |
def test_axvline(): | |
r"""Ensure that passing a quantity to axvline does not error.""" | |
fig, ax = plt.subplots() | |
> ax.axvline(0 * units('degC')) | |
metpy/tests/test_units.py:57: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
../../miniconda3/envs/dev/lib/python3.7/site-packages/matplotlib/axes/_axes.py:874: in axvline | |
xx = self.convert_xunits(x) | |
../../miniconda3/envs/dev/lib/python3.7/site-packages/matplotlib/artist.py:186: in convert_xunits | |
return ax.xaxis.convert_units(x) | |
../../miniconda3/envs/dev/lib/python3.7/site-packages/matplotlib/axis.py:1521: in convert_units | |
if munits.ConversionInterface.is_numlike(x): | |
../../miniconda3/envs/dev/lib/python3.7/site-packages/matplotlib/units.py:126: in is_numlike | |
for thisx in x: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <Quantity(0, 'degree_Celsius')>, key = 0 | |
def __getitem__(self, key): | |
try: | |
value = self._magnitude[key] | |
return self.__class__(value, self._units) | |
except TypeError: | |
raise TypeError("Neither Quantity object nor its magnitude ({})" | |
> "supports indexing".format(self._magnitude)) | |
E TypeError: Neither Quantity object nor its magnitude (0)supports indexing | |
../pint/pint/quantity.py:1469: TypeError | |
______________________________ test_convert_units ______________________________ | |
test_var = <xarray.DataArray 'Temperature' (time: 1, isobaric: 29, y: 118, x: 292)> | |
array([[[[ 18.440033, ..., 30.752533], | |
...e: Initialized analysis product | |
GRIB_level_type: 100 | |
GRIB_VectorComponentFlag: gridRelative | |
def test_convert_units(test_var): | |
"""Test in-place conversion of units.""" | |
test_var.metpy.convert_units('degC') | |
# Check that variable metadata is updated | |
> assert test_var.attrs['units'] == 'degC' | |
E AssertionError: assert 'degree_Celsius' == 'degC' | |
E - degree_Celsius | |
E + degC | |
metpy/tests/test_xarray.py:100: AssertionError | |
=============================== warnings summary =============================== | |
metpy/calc/tests/test_basic.py::test_windchill_invalid | |
/home/jon/miniconda3/envs/dev/lib/python3.7/site-packages/numpy/testing/_private/utils.py:1011: RuntimeWarning: invalid value encountered in less | |
return z < 1.5 * 10.0**(-decimal) | |
metpy/calc/tests/test_basic.py::test_heat_index_invalid | |
/home/jon/dev/pint/pint/quantity.py:1166: RuntimeWarning: invalid value encountered in sqrt | |
magnitude = new_self._magnitude ** _to_magnitude(other, self.force_ndarray) | |
metpy/plots/tests/test_declarative.py::test_latlon | |
/home/jon/miniconda3/envs/dev/lib/python3.7/site-packages/cartopy/mpl/geoaxes.py:1063: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working | |
if not isinstance(regrid_shape, collections.Sequence): | |
-- Docs: https://docs.pytest.org/en/latest/warnings.html | |
======== 25 failed, 852 passed, 1 xfailed, 3 warnings in 58.55 seconds ========= |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment