Created
December 31, 2019 00:51
-
-
Save jthielen/8b9ade4fec46671e3388430af9c89340 to your computer and use it in GitHub Desktop.
MetPy Test Log after Pint PR #963
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.6.7, pytest-5.3.2, py-1.8.1, pluggy-0.12.0 | |
Matplotlib: 3.1.2 | |
Freetype: 2.6.1 | |
Dependencies: Matplotlib (3.1.2), NumPy (1.17.3), Pandas (0.25.3), Pint (0.10.dev373+gf36cc74), SciPy (1.4.1), Xarray (0.14.1) | |
rootdir: /home/jon/dev/MetPy, inifile: setup.cfg | |
plugins: xonsh-0.6.0, flake8-1.0.4, mpl-0.11, cov-2.8.1 | |
collected 969 items | |
tests/test_cbook.py ............ [ 1%] | |
tests/test_deprecation.py . [ 1%] | |
tests/test_testing.py .. [ 1%] | |
tests/test_xarray.py ................................................... [ 6%] | |
........................................................................ [ 14%] | |
............. [ 15%] | |
tests/calc/test_basic.py ...............F.....F..F...............F...... [ 20%] | |
............. [ 21%] | |
tests/calc/test_calc_tools.py .......................................... [ 26%] | |
........................................................................ [ 33%] | |
....... [ 34%] | |
tests/calc/test_cross_sections.py ............ [ 35%] | |
tests/calc/test_indices.py ................ [ 37%] | |
tests/calc/test_kinematics.py .................................F........ [ 41%] | |
............ [ 42%] | |
tests/calc/test_thermo.py .............................................. [ 47%] | |
.............................F.......................................... [ 54%] | |
.......F........ [ 56%] | |
tests/calc/test_turbulence.py ........................... [ 59%] | |
tests/interpolate/test_geometry.py ............. [ 60%] | |
tests/interpolate/test_grid.py ........................ [ 63%] | |
tests/interpolate/test_interpolate_tools.py ....... [ 63%] | |
tests/interpolate/test_one_dimension.py ................F [ 65%] | |
tests/interpolate/test_points.py ............... [ 67%] | |
tests/interpolate/test_slices.py ....... [ 67%] | |
tests/io/test_gini.py .......... [ 68%] | |
tests/io/test_metar.py ........... [ 70%] | |
tests/io/test_nexrad.py ................................................ [ 75%] | |
........................................................................ [ 82%] | |
............... [ 84%] | |
tests/plots/test_cartopy_utils.py .... [ 84%] | |
tests/plots/test_ctables.py ........... [ 85%] | |
tests/plots/test_declarative.py ........................ [ 88%] | |
tests/plots/test_mapping.py ................. [ 89%] | |
tests/plots/test_mpl.py . [ 89%] | |
tests/plots/test_skewt.py .............................X. [ 93%] | |
tests/plots/test_station_plot.py ...................... [ 95%] | |
tests/plots/test_util.py ............. [ 96%] | |
tests/plots/test_wx_symbols.py .... [ 97%] | |
tests/units/test_units.py ............................ [100%] | |
=================================== FAILURES =================================== | |
____________________________ test_windchill_invalid ____________________________ | |
actual = <Quantity([<Quantity(2.6230789, 'degree_Fahrenheit')> -- -- -- -- --], 'dimensionless')> | |
desired = <Quantity([2.6230789828094485 -- -- -- -- --], 'degree_Fahrenheit')> | |
def check_and_drop_units(actual, desired): | |
r"""Check that the units on the passed in arrays are compatible; return the magnitudes. | |
Parameters | |
---------- | |
actual : `pint.Quantity` or array-like | |
desired : `pint.Quantity` or array-like | |
Returns | |
------- | |
actual, desired | |
array-like versions of `actual` and `desired` once they have been | |
coerced to compatible units. | |
Raises | |
------ | |
AssertionError | |
If the units on the passed in objects are not compatible. | |
""" | |
try: | |
# If the desired result has units, add dimensionless units if necessary, then | |
# ensure that this is compatible to the desired result. | |
if hasattr(desired, 'units'): | |
if not hasattr(actual, 'units'): | |
actual = units.Quantity(actual, 'dimensionless') | |
> actual = actual.to(desired.units) | |
src/metpy/testing.py:114: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <Quantity([<Quantity(2.6230789, 'degree_Fahrenheit')> -- -- -- -- --], 'dimensionless')> | |
other = <UnitsContainer({'degree_Fahrenheit': 1.0})>, contexts = () | |
ctx_kwargs = {} | |
def to(self, other=None, *contexts, **ctx_kwargs): | |
"""Return Quantity rescaled to different units. | |
Parameters | |
---------- | |
other : pint.Quantity, str or dict | |
destination units. (Default value = None) | |
*contexts : str or Context | |
Contexts to use in the transformation. | |
**ctx_kwargs : | |
Values for the Context/s | |
Returns | |
------- | |
pint.Quantity | |
""" | |
other = to_units_container(other, self._REGISTRY) | |
> magnitude = self._convert_magnitude_not_inplace(other, *contexts, **ctx_kwargs) | |
../pint/pint/quantity.py:560: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <Quantity([<Quantity(2.6230789, 'degree_Fahrenheit')> -- -- -- -- --], 'dimensionless')> | |
other = <UnitsContainer({'degree_Fahrenheit': 1.0})>, contexts = () | |
ctx_kwargs = {} | |
def _convert_magnitude_not_inplace(self, other, *contexts, **ctx_kwargs): | |
if contexts: | |
with self._REGISTRY.context(*contexts, **ctx_kwargs): | |
return self._REGISTRY.convert(self._magnitude, self._units, other) | |
> return self._REGISTRY.convert(self._magnitude, self._units, other) | |
../pint/pint/quantity.py:507: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <pint.registry.UnitRegistry object at 0x7f5035f67f60> | |
value = masked_array(data=[<Quantity(2.6230789, 'degree_Fahrenheit')>, --, --, --, | |
--, --], | |
mask=[False, True, True, True, True, True], | |
fill_value='?', | |
dtype=object) | |
src = <UnitsContainer({})>, dst = <UnitsContainer({'degree_Fahrenheit': 1.0})> | |
inplace = False | |
def convert(self, value, src, dst, inplace=False): | |
"""Convert value from some source to destination units. | |
Parameters | |
---------- | |
value : | |
value | |
src : pint.Quantity or str | |
source units. | |
dst : pint.Quantity or str | |
destination units. | |
inplace : | |
(Default value = False) | |
Returns | |
------- | |
type | |
converted value | |
""" | |
src = to_units_container(src, self) | |
dst = to_units_container(dst, self) | |
if src == dst: | |
return value | |
> return self._convert(value, src, dst, inplace) | |
../pint/pint/registry.py:882: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <pint.registry.UnitRegistry object at 0x7f5035f67f60> | |
value = masked_array(data=[<Quantity(2.6230789, 'degree_Fahrenheit')>, --, --, --, | |
--, --], | |
mask=[False, True, True, True, True, True], | |
fill_value='?', | |
dtype=object) | |
src = <UnitsContainer({})>, dst = <UnitsContainer({'degree_Fahrenheit': 1.0})> | |
inplace = False | |
def _convert(self, value, src, dst, inplace=False): | |
"""Convert value from some source to destination units. | |
In addition to what is done by the BaseRegistry, | |
converts between units with different dimensions by following | |
transformation rules defined in the context. | |
Parameters | |
---------- | |
value : | |
value | |
src : UnitsContainer | |
source units. | |
dst : UnitsContainer | |
destination units. | |
inplace : | |
(Default value = False) | |
Returns | |
------- | |
callable | |
converted value | |
""" | |
# If there is an active context, we look for a path connecting source and | |
# destination dimensionality. If it exists, we transform the source value | |
# by applying sequentially each transformation of the path. | |
if self._active_ctx: | |
src_dim = self._get_dimensionality(src) | |
dst_dim = self._get_dimensionality(dst) | |
path = find_shortest_path(self._active_ctx.graph, src_dim, dst_dim) | |
if path: | |
src = self.Quantity(value, src) | |
for a, b in zip(path[:-1], path[1:]): | |
src = self._active_ctx.transform(a, b, self, src) | |
value, src = src._magnitude, src._units | |
> return super()._convert(value, src, dst, inplace) | |
../pint/pint/registry.py:1679: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <pint.registry.UnitRegistry object at 0x7f5035f67f60> | |
value = masked_array(data=[<Quantity(2.6230789, 'degree_Fahrenheit')>, --, --, --, | |
--, --], | |
mask=[False, True, True, True, True, True], | |
fill_value='?', | |
dtype=object) | |
src = <UnitsContainer({})>, dst = <UnitsContainer({'degree_Fahrenheit': 1.0})> | |
inplace = False | |
def _convert(self, value, src, dst, inplace=False): | |
"""Convert value from some source to destination units. | |
In addition to what is done by the BaseRegistry, | |
converts between non-multiplicative units. | |
Parameters | |
---------- | |
value : | |
value | |
src : UnitsContainer | |
source units. | |
dst : UnitsContainer | |
destination units. | |
inplace : | |
(Default value = False) | |
Returns | |
------- | |
type | |
converted value | |
""" | |
# Conversion needs to consider if non-multiplicative (AKA offset | |
# units) are involved. Conversion is only possible if src and dst | |
# have at most one offset unit per dimension. Other rules are applied | |
# by validate and extract. | |
try: | |
src_offset_unit = self._validate_and_extract(src) | |
except ValueError as ex: | |
raise DimensionalityError(src, dst, extra_msg=f" - In source units, {ex}") | |
try: | |
dst_offset_unit = self._validate_and_extract(dst) | |
except ValueError as ex: | |
raise DimensionalityError( | |
src, dst, extra_msg=f" - In destination units, {ex}" | |
) | |
if not (src_offset_unit or dst_offset_unit): | |
return super()._convert(value, src, dst, inplace) | |
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 'degree_Fahrenheit' ([temperature]) | |
../pint/pint/registry.py:1286: DimensionalityError | |
During handling of the above exception, another exception occurred: | |
def test_windchill_invalid(): | |
"""Test windchill for values that should be masked.""" | |
temp = np.array([10, 51, 49, 60, 80, 81]) * units.degF | |
speed = np.array([4, 4, 3, 1, 10, 39]) * units.mph | |
wc = windchill(temp, speed) | |
# We don't care about the masked values | |
truth = np.ma.array([2.6230789, np.nan, np.nan, np.nan, np.nan, np.nan], | |
mask=[False, True, True, True, True, True]) * units.degF | |
> assert_array_almost_equal(truth, wc) | |
tests/calc/test_basic.py:170: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
src/metpy/testing.py:165: in assert_array_almost_equal | |
actual, desired = check_and_drop_units(actual, desired) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = <Quantity([<Quantity(2.6230789, 'degree_Fahrenheit')> -- -- -- -- --], 'dimensionless')> | |
desired = <Quantity([2.6230789828094485 -- -- -- -- --], 'degree_Fahrenheit')> | |
def check_and_drop_units(actual, desired): | |
r"""Check that the units on the passed in arrays are compatible; return the magnitudes. | |
Parameters | |
---------- | |
actual : `pint.Quantity` or array-like | |
desired : `pint.Quantity` or array-like | |
Returns | |
------- | |
actual, desired | |
array-like versions of `actual` and `desired` once they have been | |
coerced to compatible units. | |
Raises | |
------ | |
AssertionError | |
If the units on the passed in objects are not compatible. | |
""" | |
try: | |
# If the desired result has units, add dimensionless units if necessary, then | |
# ensure that this is compatible to the desired result. | |
if hasattr(desired, 'units'): | |
if not hasattr(actual, 'units'): | |
actual = units.Quantity(actual, 'dimensionless') | |
actual = actual.to(desired.units) | |
# Otherwise, the desired result has no units. Convert the actual result to | |
# dimensionless units if it is a united quantity. | |
else: | |
if hasattr(actual, 'units'): | |
actual = actual.to('dimensionless') | |
except DimensionalityError: | |
raise AssertionError('Units are not compatible: {} should be {}'.format( | |
> actual.units, getattr(desired, 'units', 'dimensionless'))) | |
E AssertionError: Units are not compatible: dimensionless should be degree_Fahrenheit | |
src/metpy/testing.py:122: AssertionError | |
________________________ 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 = np.ma.array([40, 39, 2, 70, 50, 39]) * units.percent | |
> hi = heat_index(temp, rh, mask_undefined=False) | |
tests/calc/test_basic.py:224: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
src/metpy/xarray.py:655: in wrapper | |
return func(*args, **kwargs) | |
src/metpy/units.py:320: in wrapper | |
return func(*args, **kwargs) | |
src/metpy/calc/basic.py:294: in heat_index | |
* ((17. * units.delta_degF - np.abs(delta - 95. * units.delta_degF)) | |
../../miniconda3/envs/develop/lib/python3.6/site-packages/numpy/ma/core.py:4129: in __truediv__ | |
return true_divide(self, other) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <numpy.ma.core._DomainedBinaryOperation object at 0x7f502041c9b0> | |
a = masked_array(data=[<Quantity(-27.0, 'dimensionless')>, | |
<Quantity(-26.0, 'dimensionless')>, | |
... <Quantity(-26.0, 'dimensionless')>], | |
mask=False, | |
fill_value='?', | |
dtype=object) | |
b = 4.0, args = (), kwargs = {} | |
da = array([<Quantity(-27.0, 'dimensionless')>, | |
<Quantity(-26.0, 'dimensionless')>, | |
<Quantity(11.0, 'dimensio...'dimensionless')>, | |
<Quantity(-37.0, 'dimensionless')>, | |
<Quantity(-26.0, 'dimensionless')>], dtype=object) | |
db = array(4.) | |
result = array([<Quantity(-6.75, 'dimensionless')>, | |
<Quantity(-6.5, 'dimensionless')>, | |
<Quantity(2.75, 'dimension... 'dimensionless')>, | |
<Quantity(-9.25, 'dimensionless')>, | |
<Quantity(-6.5, 'dimensionless')>], dtype=object) | |
def __call__(self, a, b, *args, **kwargs): | |
"Execute the call behavior." | |
# Get the data | |
(da, db) = (getdata(a), getdata(b)) | |
# Get the result | |
with np.errstate(divide='ignore', invalid='ignore'): | |
result = self.f(da, db, *args, **kwargs) | |
# Get the mask as a combination of the source masks and invalid | |
> m = ~umath.isfinite(result) | |
E TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe'' | |
../../miniconda3/envs/develop/lib/python3.6/site-packages/numpy/ma/core.py:1160: TypeError | |
____________________________ test_heat_index_vs_nws ____________________________ | |
actual = <Quantity([86.56923910000003 121.02544394000003 -- 116.13116180000023], 'degree_Fahrenheit')> | |
desired = masked_array(data=[<Quantity(87, 'degree_Fahrenheit')>, | |
<Quantity(121, 'degree_Fahrenheit')>, --, | |
...degree_Fahrenheit')>], | |
mask=[False, False, True, False], | |
fill_value='?', | |
dtype=object) | |
def check_and_drop_units(actual, desired): | |
r"""Check that the units on the passed in arrays are compatible; return the magnitudes. | |
Parameters | |
---------- | |
actual : `pint.Quantity` or array-like | |
desired : `pint.Quantity` or array-like | |
Returns | |
------- | |
actual, desired | |
array-like versions of `actual` and `desired` once they have been | |
coerced to compatible units. | |
Raises | |
------ | |
AssertionError | |
If the units on the passed in objects are not compatible. | |
""" | |
try: | |
# If the desired result has units, add dimensionless units if necessary, then | |
# ensure that this is compatible to the desired result. | |
if hasattr(desired, 'units'): | |
if not hasattr(actual, 'units'): | |
actual = units.Quantity(actual, 'dimensionless') | |
actual = actual.to(desired.units) | |
# Otherwise, the desired result has no units. Convert the actual result to | |
# dimensionless units if it is a united quantity. | |
else: | |
if hasattr(actual, 'units'): | |
> actual = actual.to('dimensionless') | |
src/metpy/testing.py:119: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <Quantity([86.56923910000003 121.02544394000003 -- 116.13116180000023], 'degree_Fahrenheit')> | |
other = <UnitsContainer({})>, contexts = (), ctx_kwargs = {} | |
def to(self, other=None, *contexts, **ctx_kwargs): | |
"""Return Quantity rescaled to different units. | |
Parameters | |
---------- | |
other : pint.Quantity, str or dict | |
destination units. (Default value = None) | |
*contexts : str or Context | |
Contexts to use in the transformation. | |
**ctx_kwargs : | |
Values for the Context/s | |
Returns | |
------- | |
pint.Quantity | |
""" | |
other = to_units_container(other, self._REGISTRY) | |
> magnitude = self._convert_magnitude_not_inplace(other, *contexts, **ctx_kwargs) | |
../pint/pint/quantity.py:560: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <Quantity([86.56923910000003 121.02544394000003 -- 116.13116180000023], 'degree_Fahrenheit')> | |
other = <UnitsContainer({})>, contexts = (), ctx_kwargs = {} | |
def _convert_magnitude_not_inplace(self, other, *contexts, **ctx_kwargs): | |
if contexts: | |
with self._REGISTRY.context(*contexts, **ctx_kwargs): | |
return self._REGISTRY.convert(self._magnitude, self._units, other) | |
> return self._REGISTRY.convert(self._magnitude, self._units, other) | |
../pint/pint/quantity.py:507: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <pint.registry.UnitRegistry object at 0x7f5035f67f60> | |
value = masked_array(data=[86.56923910000003, 121.02544394000003, --, | |
116.13116180000023], | |
mask=[False, False, True, False], | |
fill_value=1e+20) | |
src = <UnitsContainer({'degree_Fahrenheit': 1.0})>, dst = <UnitsContainer({})> | |
inplace = False | |
def convert(self, value, src, dst, inplace=False): | |
"""Convert value from some source to destination units. | |
Parameters | |
---------- | |
value : | |
value | |
src : pint.Quantity or str | |
source units. | |
dst : pint.Quantity or str | |
destination units. | |
inplace : | |
(Default value = False) | |
Returns | |
------- | |
type | |
converted value | |
""" | |
src = to_units_container(src, self) | |
dst = to_units_container(dst, self) | |
if src == dst: | |
return value | |
> return self._convert(value, src, dst, inplace) | |
../pint/pint/registry.py:882: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <pint.registry.UnitRegistry object at 0x7f5035f67f60> | |
value = masked_array(data=[86.56923910000003, 121.02544394000003, --, | |
116.13116180000023], | |
mask=[False, False, True, False], | |
fill_value=1e+20) | |
src = <UnitsContainer({'degree_Fahrenheit': 1.0})>, dst = <UnitsContainer({})> | |
inplace = False | |
def _convert(self, value, src, dst, inplace=False): | |
"""Convert value from some source to destination units. | |
In addition to what is done by the BaseRegistry, | |
converts between units with different dimensions by following | |
transformation rules defined in the context. | |
Parameters | |
---------- | |
value : | |
value | |
src : UnitsContainer | |
source units. | |
dst : UnitsContainer | |
destination units. | |
inplace : | |
(Default value = False) | |
Returns | |
------- | |
callable | |
converted value | |
""" | |
# If there is an active context, we look for a path connecting source and | |
# destination dimensionality. If it exists, we transform the source value | |
# by applying sequentially each transformation of the path. | |
if self._active_ctx: | |
src_dim = self._get_dimensionality(src) | |
dst_dim = self._get_dimensionality(dst) | |
path = find_shortest_path(self._active_ctx.graph, src_dim, dst_dim) | |
if path: | |
src = self.Quantity(value, src) | |
for a, b in zip(path[:-1], path[1:]): | |
src = self._active_ctx.transform(a, b, self, src) | |
value, src = src._magnitude, src._units | |
> return super()._convert(value, src, dst, inplace) | |
../pint/pint/registry.py:1679: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <pint.registry.UnitRegistry object at 0x7f5035f67f60> | |
value = masked_array(data=[86.56923910000003, 121.02544394000003, --, | |
116.13116180000023], | |
mask=[False, False, True, False], | |
fill_value=1e+20) | |
src = <UnitsContainer({'degree_Fahrenheit': 1.0})>, dst = <UnitsContainer({})> | |
inplace = False | |
def _convert(self, value, src, dst, inplace=False): | |
"""Convert value from some source to destination units. | |
In addition to what is done by the BaseRegistry, | |
converts between non-multiplicative units. | |
Parameters | |
---------- | |
value : | |
value | |
src : UnitsContainer | |
source units. | |
dst : UnitsContainer | |
destination units. | |
inplace : | |
(Default value = False) | |
Returns | |
------- | |
type | |
converted value | |
""" | |
# Conversion needs to consider if non-multiplicative (AKA offset | |
# units) are involved. Conversion is only possible if src and dst | |
# have at most one offset unit per dimension. Other rules are applied | |
# by validate and extract. | |
try: | |
src_offset_unit = self._validate_and_extract(src) | |
except ValueError as ex: | |
raise DimensionalityError(src, dst, extra_msg=f" - In source units, {ex}") | |
try: | |
dst_offset_unit = self._validate_and_extract(dst) | |
except ValueError as ex: | |
raise DimensionalityError( | |
src, dst, extra_msg=f" - In destination units, {ex}" | |
) | |
if not (src_offset_unit or dst_offset_unit): | |
return super()._convert(value, src, dst, inplace) | |
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 'degree_Fahrenheit' ([temperature]) to 'dimensionless' (dimensionless) | |
../pint/pint/registry.py:1286: DimensionalityError | |
During handling of the above exception, another exception occurred: | |
def test_heat_index_vs_nws(): | |
"""Test heat_index against online calculated HI from NWS Website.""" | |
# https://www.wpc.ncep.noaa.gov/html/heatindex.shtml, visited 2019-Jul-17 | |
temp = units.Quantity(np.array([86, 111, 40, 96]), units.degF) | |
rh = np.ma.array([45, 27, 99, 60]) * units.percent | |
hi = heat_index(temp, rh) | |
truth = np.ma.array([87, 121, 40, 116], mask=[False, False, True, False]) * units.degF | |
> assert_array_almost_equal(hi, truth, 0) | |
tests/calc/test_basic.py:252: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
src/metpy/testing.py:165: in assert_array_almost_equal | |
actual, desired = check_and_drop_units(actual, desired) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = <Quantity([86.56923910000003 121.02544394000003 -- 116.13116180000023], 'degree_Fahrenheit')> | |
desired = masked_array(data=[<Quantity(87, 'degree_Fahrenheit')>, | |
<Quantity(121, 'degree_Fahrenheit')>, --, | |
...degree_Fahrenheit')>], | |
mask=[False, False, True, False], | |
fill_value='?', | |
dtype=object) | |
def check_and_drop_units(actual, desired): | |
r"""Check that the units on the passed in arrays are compatible; return the magnitudes. | |
Parameters | |
---------- | |
actual : `pint.Quantity` or array-like | |
desired : `pint.Quantity` or array-like | |
Returns | |
------- | |
actual, desired | |
array-like versions of `actual` and `desired` once they have been | |
coerced to compatible units. | |
Raises | |
------ | |
AssertionError | |
If the units on the passed in objects are not compatible. | |
""" | |
try: | |
# If the desired result has units, add dimensionless units if necessary, then | |
# ensure that this is compatible to the desired result. | |
if hasattr(desired, 'units'): | |
if not hasattr(actual, 'units'): | |
actual = units.Quantity(actual, 'dimensionless') | |
actual = actual.to(desired.units) | |
# Otherwise, the desired result has no units. Convert the actual result to | |
# dimensionless units if it is a united quantity. | |
else: | |
if hasattr(actual, 'units'): | |
actual = actual.to('dimensionless') | |
except DimensionalityError: | |
raise AssertionError('Units are not compatible: {} should be {}'.format( | |
> actual.units, getattr(desired, 'units', 'dimensionless'))) | |
E AssertionError: Units are not compatible: degree_Fahrenheit should be dimensionless | |
src/metpy/testing.py:122: AssertionError | |
__________________________ test_apparent_temperature ___________________________ | |
actual = <Quantity([[99.67771789999998 86.33576710000007 --] | |
[8.814066315997701 -- --]], 'degree_Fahrenheit')> | |
desired = masked_array( | |
data=[[<Quantity(99.6777178, 'degree_Fahrenheit')>, | |
<Quantity(86.3357671, 'degree_Fahrenheit'...hrenheit')>, --, --]], | |
mask=[[False, False, True], | |
[False, True, True]], | |
fill_value='?', | |
dtype=object) | |
def check_and_drop_units(actual, desired): | |
r"""Check that the units on the passed in arrays are compatible; return the magnitudes. | |
Parameters | |
---------- | |
actual : `pint.Quantity` or array-like | |
desired : `pint.Quantity` or array-like | |
Returns | |
------- | |
actual, desired | |
array-like versions of `actual` and `desired` once they have been | |
coerced to compatible units. | |
Raises | |
------ | |
AssertionError | |
If the units on the passed in objects are not compatible. | |
""" | |
try: | |
# If the desired result has units, add dimensionless units if necessary, then | |
# ensure that this is compatible to the desired result. | |
if hasattr(desired, 'units'): | |
if not hasattr(actual, 'units'): | |
actual = units.Quantity(actual, 'dimensionless') | |
actual = actual.to(desired.units) | |
# Otherwise, the desired result has no units. Convert the actual result to | |
# dimensionless units if it is a united quantity. | |
else: | |
if hasattr(actual, 'units'): | |
> actual = actual.to('dimensionless') | |
src/metpy/testing.py:119: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <Quantity([[99.67771789999998 86.33576710000007 --] | |
[8.814066315997701 -- --]], 'degree_Fahrenheit')> | |
other = <UnitsContainer({})>, contexts = (), ctx_kwargs = {} | |
def to(self, other=None, *contexts, **ctx_kwargs): | |
"""Return Quantity rescaled to different units. | |
Parameters | |
---------- | |
other : pint.Quantity, str or dict | |
destination units. (Default value = None) | |
*contexts : str or Context | |
Contexts to use in the transformation. | |
**ctx_kwargs : | |
Values for the Context/s | |
Returns | |
------- | |
pint.Quantity | |
""" | |
other = to_units_container(other, self._REGISTRY) | |
> magnitude = self._convert_magnitude_not_inplace(other, *contexts, **ctx_kwargs) | |
../pint/pint/quantity.py:560: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <Quantity([[99.67771789999998 86.33576710000007 --] | |
[8.814066315997701 -- --]], 'degree_Fahrenheit')> | |
other = <UnitsContainer({})>, contexts = (), ctx_kwargs = {} | |
def _convert_magnitude_not_inplace(self, other, *contexts, **ctx_kwargs): | |
if contexts: | |
with self._REGISTRY.context(*contexts, **ctx_kwargs): | |
return self._REGISTRY.convert(self._magnitude, self._units, other) | |
> return self._REGISTRY.convert(self._magnitude, self._units, other) | |
../pint/pint/quantity.py:507: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <pint.registry.UnitRegistry object at 0x7f5035f67f60> | |
value = masked_array( | |
data=[[99.67771789999998, 86.33576710000007, --], | |
[8.814066315997701, --, --]], | |
mask=[[False, False, True], | |
[False, True, True]], | |
fill_value=1e+20) | |
src = <UnitsContainer({'degree_Fahrenheit': 1.0})>, dst = <UnitsContainer({})> | |
inplace = False | |
def convert(self, value, src, dst, inplace=False): | |
"""Convert value from some source to destination units. | |
Parameters | |
---------- | |
value : | |
value | |
src : pint.Quantity or str | |
source units. | |
dst : pint.Quantity or str | |
destination units. | |
inplace : | |
(Default value = False) | |
Returns | |
------- | |
type | |
converted value | |
""" | |
src = to_units_container(src, self) | |
dst = to_units_container(dst, self) | |
if src == dst: | |
return value | |
> return self._convert(value, src, dst, inplace) | |
../pint/pint/registry.py:882: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <pint.registry.UnitRegistry object at 0x7f5035f67f60> | |
value = masked_array( | |
data=[[99.67771789999998, 86.33576710000007, --], | |
[8.814066315997701, --, --]], | |
mask=[[False, False, True], | |
[False, True, True]], | |
fill_value=1e+20) | |
src = <UnitsContainer({'degree_Fahrenheit': 1.0})>, dst = <UnitsContainer({})> | |
inplace = False | |
def _convert(self, value, src, dst, inplace=False): | |
"""Convert value from some source to destination units. | |
In addition to what is done by the BaseRegistry, | |
converts between units with different dimensions by following | |
transformation rules defined in the context. | |
Parameters | |
---------- | |
value : | |
value | |
src : UnitsContainer | |
source units. | |
dst : UnitsContainer | |
destination units. | |
inplace : | |
(Default value = False) | |
Returns | |
------- | |
callable | |
converted value | |
""" | |
# If there is an active context, we look for a path connecting source and | |
# destination dimensionality. If it exists, we transform the source value | |
# by applying sequentially each transformation of the path. | |
if self._active_ctx: | |
src_dim = self._get_dimensionality(src) | |
dst_dim = self._get_dimensionality(dst) | |
path = find_shortest_path(self._active_ctx.graph, src_dim, dst_dim) | |
if path: | |
src = self.Quantity(value, src) | |
for a, b in zip(path[:-1], path[1:]): | |
src = self._active_ctx.transform(a, b, self, src) | |
value, src = src._magnitude, src._units | |
> return super()._convert(value, src, dst, inplace) | |
../pint/pint/registry.py:1679: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <pint.registry.UnitRegistry object at 0x7f5035f67f60> | |
value = masked_array( | |
data=[[99.67771789999998, 86.33576710000007, --], | |
[8.814066315997701, --, --]], | |
mask=[[False, False, True], | |
[False, True, True]], | |
fill_value=1e+20) | |
src = <UnitsContainer({'degree_Fahrenheit': 1.0})>, dst = <UnitsContainer({})> | |
inplace = False | |
def _convert(self, value, src, dst, inplace=False): | |
"""Convert value from some source to destination units. | |
In addition to what is done by the BaseRegistry, | |
converts between non-multiplicative units. | |
Parameters | |
---------- | |
value : | |
value | |
src : UnitsContainer | |
source units. | |
dst : UnitsContainer | |
destination units. | |
inplace : | |
(Default value = False) | |
Returns | |
------- | |
type | |
converted value | |
""" | |
# Conversion needs to consider if non-multiplicative (AKA offset | |
# units) are involved. Conversion is only possible if src and dst | |
# have at most one offset unit per dimension. Other rules are applied | |
# by validate and extract. | |
try: | |
src_offset_unit = self._validate_and_extract(src) | |
except ValueError as ex: | |
raise DimensionalityError(src, dst, extra_msg=f" - In source units, {ex}") | |
try: | |
dst_offset_unit = self._validate_and_extract(dst) | |
except ValueError as ex: | |
raise DimensionalityError( | |
src, dst, extra_msg=f" - In destination units, {ex}" | |
) | |
if not (src_offset_unit or dst_offset_unit): | |
return super()._convert(value, src, dst, inplace) | |
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 'degree_Fahrenheit' ([temperature]) to 'dimensionless' (dimensionless) | |
../pint/pint/registry.py:1286: DimensionalityError | |
During handling of the above exception, another exception occurred: | |
def test_apparent_temperature(): | |
"""Test the apparent temperature calculation.""" | |
temperature = np.array([[90, 90, 70], | |
[20, 20, 60]]) * units.degF | |
rel_humidity = np.array([[60, 20, 60], | |
[10, 10, 10]]) * units.percent | |
wind = np.array([[5, 3, 3], | |
[10, 1, 10]]) * units.mph | |
truth = np.ma.array([[99.6777178, 86.3357671, 70], | |
[8.8140662, 20, 60]], | |
mask=[[False, False, True], [False, True, True]]) * units.degF | |
res = apparent_temperature(temperature, rel_humidity, wind) | |
> assert_array_almost_equal(res, truth, 6) | |
tests/calc/test_basic.py:419: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
src/metpy/testing.py:165: in assert_array_almost_equal | |
actual, desired = check_and_drop_units(actual, desired) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = <Quantity([[99.67771789999998 86.33576710000007 --] | |
[8.814066315997701 -- --]], 'degree_Fahrenheit')> | |
desired = masked_array( | |
data=[[<Quantity(99.6777178, 'degree_Fahrenheit')>, | |
<Quantity(86.3357671, 'degree_Fahrenheit'...hrenheit')>, --, --]], | |
mask=[[False, False, True], | |
[False, True, True]], | |
fill_value='?', | |
dtype=object) | |
def check_and_drop_units(actual, desired): | |
r"""Check that the units on the passed in arrays are compatible; return the magnitudes. | |
Parameters | |
---------- | |
actual : `pint.Quantity` or array-like | |
desired : `pint.Quantity` or array-like | |
Returns | |
------- | |
actual, desired | |
array-like versions of `actual` and `desired` once they have been | |
coerced to compatible units. | |
Raises | |
------ | |
AssertionError | |
If the units on the passed in objects are not compatible. | |
""" | |
try: | |
# If the desired result has units, add dimensionless units if necessary, then | |
# ensure that this is compatible to the desired result. | |
if hasattr(desired, 'units'): | |
if not hasattr(actual, 'units'): | |
actual = units.Quantity(actual, 'dimensionless') | |
actual = actual.to(desired.units) | |
# Otherwise, the desired result has no units. Convert the actual result to | |
# dimensionless units if it is a united quantity. | |
else: | |
if hasattr(actual, 'units'): | |
actual = actual.to('dimensionless') | |
except DimensionalityError: | |
raise AssertionError('Units are not compatible: {} should be {}'.format( | |
> actual.units, getattr(desired, 'units', 'dimensionless'))) | |
E AssertionError: Units are not compatible: degree_Fahrenheit should be dimensionless | |
src/metpy/testing.py:122: AssertionError | |
_____________________ test_storm_relative_helicity_masked ______________________ | |
@check_and_silence_warning(FutureWarning) | |
def test_storm_relative_helicity_masked(): | |
"""Test that srh does not return masked values.""" | |
h = np.ma.array([20.72, 234.85, 456.69, 683.21]) | |
u = np.ma.array([-2.32, -3.23, 0.736, 9.07]) | |
v = np.ma.array([8.31, 13.57, 25.56, 30.55]) | |
u = np.ma.array(np.zeros((4,))) | |
v = np.zeros_like(u) | |
pos, neg, com = storm_relative_helicity(units.knot * u, units.knot * v, units.meter * h, | |
depth=500 * units.meter, | |
storm_u=15.77463015050421 * units('m/s'), | |
> storm_v=21.179437759755647 * units('m/s')) | |
tests/calc/test_kinematics.py:489: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
src/metpy/xarray.py:655: in wrapper | |
return func(*args, **kwargs) | |
src/metpy/units.py:320: in wrapper | |
return func(*args, **kwargs) | |
src/metpy/calc/kinematics.py:586: in storm_relative_helicity | |
bottom=bottom, storm_u=storm_u, storm_v=storm_v) | |
src/metpy/xarray.py:655: in wrapper | |
return func(*args, **kwargs) | |
src/metpy/units.py:320: in wrapper | |
return func(*args, **kwargs) | |
src/metpy/future.py:167: in storm_relative_helicity | |
_, u, v = get_layer_heights(heights, depth, u, v, with_agl=True, bottom=bottom) | |
src/metpy/xarray.py:655: in wrapper | |
return func(*args, **kwargs) | |
src/metpy/units.py:320: in wrapper | |
return func(*args, **kwargs) | |
src/metpy/calc/tools.py:497: in get_layer_heights | |
datavar_interp = interpolate_1d(heights_interp, heights, datavar) | |
src/metpy/xarray.py:655: in wrapper | |
return func(*args, **kwargs) | |
src/metpy/interpolate/one_dimension.py:127: in interpolate_1d | |
minv = np.apply_along_axis(np.searchsorted, axis, xp, x[sort_x]) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
args = (<function searchsorted at 0x7f502091f158>, 0, <Quantity([ 0. 214.13 435.97 662.49], 'meter')>, masked_array(data=[... <Quantity(500.0, 'meter')>], | |
mask=False, | |
fill_value='?', | |
dtype=object)) | |
kwargs = {} | |
relevant_args = (<Quantity([ 0. 214.13 435.97 662.49], 'meter')>,) | |
> ??? | |
E TypeError: no implementation found for 'numpy.apply_along_axis' on types that implement __array_function__: [<class 'pint.quantity.build_quantity_class.<locals>.Quantity'>] | |
<__array_function__ internals>:6: TypeError | |
____________________ test_isentropic_pressure_masked_column ____________________ | |
def test_isentropic_pressure_masked_column(): | |
"""Test calculation of isentropic pressure function with a masked column (#769).""" | |
lev = [100000., 95000.] * units.Pa | |
tmp = np.ma.ones((len(lev), 5, 5)) | |
tmp[0, :] = 296. | |
tmp[1, :] = 292. | |
tmp[:, :, -1] = np.ma.masked | |
> isentprs = isentropic_interpolation([296.] * units.kelvin, lev, tmp * units.kelvin) | |
tests/calc/test_thermo.py:848: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
src/metpy/xarray.py:655: in wrapper | |
return func(*args, **kwargs) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
args = (<Quantity([296.], 'kelvin')>, <Quantity([100000. 95000.], 'pascal')>, masked_array( | |
data=[[[<Quantity(296.0, 'kelv...[False, False, False, False, True], | |
[False, False, False, False, True]]], | |
fill_value='?', | |
dtype=object)) | |
kwargs = {} | |
bound_args = <BoundArguments (theta_levels=<Quantity([296.], 'kelvin')>, pressure=<Quantity([100000. 95000.], 'pascal')>, temperat...False, False, False, False, True], | |
[False, False, False, False, True]]], | |
fill_value='?', | |
dtype=object))> | |
bad = [('temperature', 'none', '[temperature]')] | |
msg = '`isentropic_interpolation` given arguments with incorrect units: `temperature` requires "[temperature]" but given "no...able `x` can be assigned a unit as follows:\n from metpy.units import units\n x = x * units.meter / units.second' | |
@functools.wraps(func) | |
def wrapper(*args, **kwargs): | |
# Match all passed in value to their proper arguments so we can check units | |
bound_args = sig.bind(*args, **kwargs) | |
bad = list(_check_argument_units(bound_args.arguments, defaults, dims)) | |
# If there are any bad units, emit a proper error message making it clear | |
# what went wrong. | |
if bad: | |
msg = '`{}` given arguments with incorrect units: {}.'.format( | |
func.__name__, | |
', '.join('`{}` requires "{}" but given "{}"'.format(arg, req, given) | |
for arg, given, req in bad)) | |
if 'none' in msg: | |
msg += ('\nAny variable `x` can be assigned a unit as follows:\n' | |
' from metpy.units import units\n' | |
' x = x * units.meter / units.second') | |
> raise ValueError(msg) | |
E ValueError: `isentropic_interpolation` given arguments with incorrect units: `temperature` requires "[temperature]" but given "none". | |
E Any variable `x` can be assigned a unit as follows: | |
E from metpy.units import units | |
E x = x * units.meter / units.second | |
src/metpy/units.py:319: ValueError | |
________________________ test_parcel_profile_below_lcl _________________________ | |
def test_parcel_profile_below_lcl(): | |
"""Test parcel profile calculation when pressures do not reach LCL (#827).""" | |
pressure = np.array([981, 949.2, 925., 913.9, 903, 879.4, 878, 864, 855, | |
850, 846.3, 838, 820, 814.5, 799, 794]) * units.hPa | |
truth = np.array([276.35, 273.76110242, 271.74910213, 270.81364639, | |
269.88711359, 267.85332225, 267.73145436, 266.5050728, | |
265.70916946, 265.264412, 264.93408677, 264.18931638, | |
262.55585912, 262.0516423, 260.61745662, | |
260.15057861]) * units.kelvin | |
> profile = parcel_profile(pressure, 3.2 * units.degC, -10.8 * units.degC) | |
tests/calc/test_thermo.py:1498: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
src/metpy/xarray.py:655: in wrapper | |
return func(*args, **kwargs) | |
src/metpy/units.py:320: in wrapper | |
return func(*args, **kwargs) | |
src/metpy/calc/thermo.py:637: in parcel_profile | |
_, _, _, t_l, _, t_u = _parcel_profile_helper(pressure, temperature, dewpt) | |
src/metpy/calc/thermo.py:709: in _parcel_profile_helper | |
return (press_lower[:-1], press_lcl, np.array([]) * press_lower.units, | |
../pint/pint/unit.py:255: in __array_ufunc__ | |
**kwargs, | |
../pint/pint/quantity.py:1507: in __array_ufunc__ | |
return numpy_wrap("ufunc", ufunc, inputs, kwargs, types) | |
../pint/pint/numpy_func.py:888: in numpy_wrap | |
return handled[name](*args, **kwargs) | |
../pint/pint/numpy_func.py:268: in implementation | |
first_input_units = _get_first_input_units(args, kwargs) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
args = (array([], dtype=float64), <Quantity(1, 'hectopascal')>), kwargs = {} | |
def _get_first_input_units(args, kwargs=None): | |
"""Obtain the first valid unit from a collection of args and kwargs. | |
""" | |
kwargs = kwargs or {} | |
for arg in chain(args, kwargs.values()): | |
if _is_quantity(arg): | |
return arg.units | |
elif _is_quantity_sequence(arg): | |
> return arg[0].units | |
E IndexError: index 0 is out of bounds for axis 0 with size 0 | |
../pint/pint/numpy_func.py:69: IndexError | |
________________________ test_interpolate_masked_units _________________________ | |
def test_interpolate_masked_units(): | |
"""Test interpolating with masked arrays with units.""" | |
x = np.ma.array([1., 2., 3., 4.]) * units.m | |
y = np.ma.array([50., 60., 70., 80.]) * units.degC | |
x_interp = np.array([250., 350.]) * units.cm | |
y_interp_truth = np.array([65., 75.]) * units.degC | |
> y_interp = interpolate_1d(x_interp, x, y) | |
tests/interpolate/test_one_dimension.py:183: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
src/metpy/xarray.py:655: in wrapper | |
return func(*args, **kwargs) | |
src/metpy/interpolate/one_dimension.py:127: in interpolate_1d | |
minv = np.apply_along_axis(np.searchsorted, axis, xp, x[sort_x]) | |
<__array_function__ internals>:6: in apply_along_axis | |
??? | |
../../miniconda3/envs/develop/lib/python3.6/site-packages/numpy/lib/shape_base.py:379: in apply_along_axis | |
res = asanyarray(func1d(inarr_view[ind0], *args, **kwargs)) | |
<__array_function__ internals>:6: in searchsorted | |
??? | |
../../miniconda3/envs/develop/lib/python3.6/site-packages/numpy/core/fromnumeric.py:1296: in searchsorted | |
return _wrapfunc(a, 'searchsorted', v, side=side, sorter=sorter) | |
../../miniconda3/envs/develop/lib/python3.6/site-packages/numpy/core/fromnumeric.py:61: in _wrapfunc | |
return bound(*args, **kwds) | |
../pint/pint/quantity.py:1478: in <lambda> | |
__lt__ = lambda self, other: self.compare(other, op=operator.lt) | |
../pint/pint/quantity.py:106: in wrapped | |
result = f(self, *args, **kwargs) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <Quantity(3.0, 'meter')>, other = 250.0, op = <built-in function lt> | |
@check_implemented | |
def compare(self, other, op): | |
if not isinstance(other, self.__class__): | |
if self.dimensionless: | |
return op(self._convert_magnitude_not_inplace(UnitsContainer()), other) | |
elif eq(other, 0, True): | |
# Handle the special case in which we compare to zero | |
# (or an array of zeros) | |
if self._is_multiplicative: | |
# compare magnitude | |
return op(self._magnitude, other) | |
else: | |
# compare the magnitude after converting the | |
# non-multiplicative quantity to base units | |
if self._REGISTRY.autoconvert_offset_to_baseunit: | |
return op(self.to_base_units()._magnitude, other) | |
else: | |
raise OffsetUnitCalculusError(self._units) | |
else: | |
> raise ValueError("Cannot compare Quantity and {}".format(type(other))) | |
E ValueError: Cannot compare Quantity and <class 'float'> | |
../pint/pint/quantity.py:1468: ValueError | |
=============================== warnings summary =============================== | |
tests/test_xarray.py::test_coordinates_identical_false_number_of_coords | |
/home/jon/dev/MetPy/tests/test_xarray.py:455: PendingDeprecationWarning: dropping variables using `drop` will be deprecated; using drop_vars is encouraged. | |
other_ds = test_ds_generic.drop('e') | |
tests/test_xarray.py::test_auxilary_lat_lon_without_xy | |
tests/test_xarray.py::test_auxilary_lat_lon_without_xy_as_xy | |
tests/calc/test_cross_sections.py::test_distances_from_cross_section_given_bad_coords | |
/home/jon/dev/xarray/xarray/core/dataarray.py:1938: PendingDeprecationWarning: dropping variables using `drop` will be deprecated; using drop_vars is encouraged. | |
ds = self._to_temp_dataset().drop(labels, dim, errors=errors) | |
tests/calc/test_basic.py::test_heat_index_invalid | |
/home/jon/dev/pint/pint/quantity.py:1372: RuntimeWarning: invalid value encountered in sqrt | |
magnitude = new_self._magnitude ** exponent | |
tests/calc/test_cross_sections.py::test_distances_from_cross_section_given_lonlat | |
tests/calc/test_cross_sections.py::test_distances_from_cross_section_given_xy | |
tests/calc/test_cross_sections.py::test_distances_from_cross_section_given_bad_coords | |
tests/calc/test_cross_sections.py::test_latitude_from_cross_section_given_lat | |
tests/calc/test_cross_sections.py::test_latitude_from_cross_section_given_y | |
tests/calc/test_cross_sections.py::test_unit_vectors_from_cross_section_given_lonlat | |
tests/calc/test_cross_sections.py::test_unit_vectors_from_cross_section_given_xy | |
tests/calc/test_cross_sections.py::test_cross_section_components | |
tests/calc/test_cross_sections.py::test_tangential_component | |
tests/calc/test_cross_sections.py::test_normal_component | |
tests/calc/test_cross_sections.py::test_absolute_momentum_given_lonlat | |
tests/calc/test_cross_sections.py::test_absolute_momentum_given_xy | |
tests/interpolate/test_slices.py::test_cross_section_dataset_and_nearest_interp | |
/home/jon/dev/MetPy/src/metpy/interpolate/slices.py:148: PendingDeprecationWarning: Dataset.apply may be deprecated in the future. Using Dataset.map is encouraged | |
interp_type=interp_type) | |
tests/calc/test_kinematics.py::test_vorticity_4d | |
tests/calc/test_kinematics.py::test_divergence_4d | |
tests/calc/test_kinematics.py::test_shearing_deformation_4d | |
tests/calc/test_kinematics.py::test_stretching_deformation_4d | |
tests/calc/test_kinematics.py::test_total_deformation_4d | |
tests/calc/test_kinematics.py::test_frontogenesis_4d | |
tests/calc/test_kinematics.py::test_geostrophic_wind_4d | |
tests/calc/test_kinematics.py::test_intertial_advective_wind_4d | |
tests/calc/test_kinematics.py::test_q_vector_4d | |
/home/jon/dev/MetPy/tests/calc/test_kinematics.py:1131: PendingDeprecationWarning: dropping variables using `drop` will be deprecated; using drop_vars is encouraged. | |
'Relative_humidity_isobaric', 'reftime' | |
tests/io/test_metar.py::test_station_id_not_in_dictionary | |
tests/io/test_metar.py::test_broken_clouds | |
tests/io/test_metar.py::test_few_clouds_ | |
tests/io/test_metar.py::test_all_weather_given | |
tests/io/test_metar.py::test_missing_temp_dewp | |
tests/io/test_metar.py::test_missing_values | |
tests/io/test_metar.py::test_vertical_vis | |
tests/io/test_metar.py::test_date_time_given | |
tests/io/test_metar.py::test_named_tuple_test1 | |
/home/jon/dev/MetPy/src/metpy/io/metar.py:175: 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 = col_units | |
tests/io/test_metar.py::test_few_clouds_ | |
tests/io/test_metar.py::test_missing_temp_dewp | |
/home/jon/dev/MetPy/src/metpy/calc/basic.py:1011: RuntimeWarning: All-NaN slice encountered | |
if np.greater(np.nanmax(np.abs(value)), max_radians): | |
tests/io/test_metar.py::test_parse_file | |
tests/io/test_metar.py::test_parse_file_object | |
/home/jon/dev/MetPy/src/metpy/io/metar.py:627: 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 = col_units | |
tests/plots/test_declarative.py::test_declarative_upa_obs | |
/home/jon/miniconda3/envs/develop/lib/python3.6/site-packages/cartopy/mpl/geoaxes.py:1833: RuntimeWarning: invalid value encountered in less | |
u, v = self.projection.transform_vectors(t, x, y, u, v) | |
tests/plots/test_declarative.py::test_declarative_upa_obs | |
/home/jon/miniconda3/envs/develop/lib/python3.6/site-packages/cartopy/mpl/geoaxes.py:1833: RuntimeWarning: invalid value encountered in greater | |
u, v = self.projection.transform_vectors(t, x, y, u, v) | |
-- Docs: https://docs.pytest.org/en/latest/warnings.html | |
======= 8 failed, 960 passed, 1 xpassed, 42 warnings in 85.66s (0:01:25) ======= |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment