Adding floating point exception checks to GitHub Actions #2
30 fail, 17 602 pass in 3m 36s
Annotations
Check warning on line 0 in tests.Distorb.LL2.test_LL2.Test_LL2
github-actions / Test Results
test_benchmark[log.initial.Venus.DYoblDtDistRot--2.916372e-13-unit113-param_options113] (tests.Distorb.LL2.test_LL2.Test_LL2) failed
junit/test-results.xml [took 0s]
Raw output
astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
self = <Quantity -2.916372e-13 1 / sec>, unit = Unit(dimensionless)
equivalencies = []
def to_value(self, unit=None, equivalencies=[]):
"""
The numerical value, possibly in a different unit.
Parameters
----------
unit : unit-like, optional
The unit in which the value should be given. If not given or `None`,
use the current unit.
equivalencies : list of tuple, optional
A list of equivalence pairs to try if the units are not directly
convertible (see :ref:`unit_equivalencies`). If not provided or
``[]``, class default equivalencies will be used (none for
`~astropy.units.Quantity`, but may be set for subclasses).
If `None`, no equivalencies will be applied at all, not even any
set globally or within a context.
Returns
-------
value : ndarray or scalar
The value in the units specified. For arrays, this will be a view
of the data if no unit conversion was necessary.
See also
--------
to : Get a new instance in a different unit.
"""
if unit is None or unit is self.unit:
value = self.view(np.ndarray)
else:
unit = Unit(unit)
# We want a view if the unit does not change. One could check
# with "==", but that calculates the scale that we need anyway.
# TODO: would be better for `unit.to` to have an in-place flag.
try:
> scale = self.unit._to(unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:747:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), other = Unit(dimensionless)
def _to(self, other):
"""
Returns the scale to the specified unit.
See `to`, except that a Unit object should be given (i.e., no
string), and that all defaults are used, i.e., no
equivalencies and value=1.
"""
# There are many cases where we just want to ensure a Quantity is
# of a particular unit, without checking whether it's already in
# a particular unit. If we're being asked to convert from a unit
# to itself, we can short-circuit all of this.
if self is other:
return 1.0
# Don't presume decomposition is possible; e.g.,
# conversion to function units is through equivalencies.
if isinstance(other, UnitBase):
self_decomposed = self.decompose()
other_decomposed = other.decompose()
# Check quickly whether equivalent. This is faster than
# `is_equivalent`, because it doesn't generate the entire
# physical type list of both units. In other words it "fails
# fast".
if(self_decomposed.powers == other_decomposed.powers and
all(self_base is other_base for (self_base, other_base)
in zip(self_decomposed.bases, other_decomposed.bases))):
return self_decomposed.scale / other_decomposed.scale
raise UnitConversionError(
> f"'{self!r}' is not a scaled version of '{other!r}'")
E astropy.units.core.UnitConversionError: 'Unit("1 / sec")' is not a scaled version of 'Unit(dimensionless)'
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1097: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_LL2.Test_LL2 object at 0x7fa5b4566290>
vplanet_output = <vplanet.Output: solarsys>
param = 'log.initial.Venus.DYoblDtDistRot', value = -2.916372e-13
unit = <Quantity 1. 1 / sec>, param_options = {}
def test_benchmark(self, vplanet_output, param, value, unit, param_options):
# The value returned by vplanet
output_value = recursive_getattr(vplanet_output, param)
# Are we comparing a specific index of an array?
index = param_options.pop("index", None)
if index is not None:
output_value = output_value[index]
# The expected value
benchmark_value = value * unit
# Check
> if np.allclose(output_value, benchmark_value, **param_options) == 0:
tests/benchmark.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<__array_function__ internals>:6: in allclose
???
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1525: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:544: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1356: in _to_own_unit
_value = value.to_value(self.unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:750: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:670: in _to_value
equivalencies=equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1134: in to
equivalencies=equivalencies)(value)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1064: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1050: in _get_converter
self, other, self._normalize_equivalencies(equivalencies))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), unit = Unit("1 / sec"), other = Unit(dimensionless)
equivalencies = []
def _apply_equivalencies(self, unit, other, equivalencies):
"""
Internal function (used from `_get_converter`) to apply
equivalence pairs.
"""
def make_converter(scale1, func, scale2):
def convert(v):
return func(_condition_arg(v) / scale1) * scale2
return convert
for funit, tunit, a, b in equivalencies:
if tunit is None:
try:
ratio_in_funit = (other.decompose() /
unit.decompose()).decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.)
except UnitsError:
pass
else:
try:
scale1 = funit._to(unit)
scale2 = tunit._to(other)
return make_converter(scale1, a, scale2)
except UnitsError:
pass
try:
scale1 = tunit._to(unit)
scale2 = funit._to(other)
return make_converter(scale1, b, scale2)
except UnitsError:
pass
def get_err_str(unit):
unit_str = unit.to_string('unscaled')
physical_type = unit.physical_type
if physical_type != 'unknown':
unit_str = f"'{unit_str}' ({physical_type})"
else:
unit_str = f"'{unit_str}'"
return unit_str
unit_str = get_err_str(unit)
other_str = get_err_str(other)
raise UnitConversionError(
> f"{unit_str} and {other_str} are not convertible")
E astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1026: UnitConversionError
Check warning on line 0 in tests.Distorb.LL2.test_LL2.Test_LL2
github-actions / Test Results
test_benchmark[log.initial.Earth.DYoblDtDistRot-9.732005e-13-unit176-param_options176] (tests.Distorb.LL2.test_LL2.Test_LL2) failed
junit/test-results.xml [took 0s]
Raw output
astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
self = <Quantity 9.732005e-13 1 / sec>, unit = Unit(dimensionless)
equivalencies = []
def to_value(self, unit=None, equivalencies=[]):
"""
The numerical value, possibly in a different unit.
Parameters
----------
unit : unit-like, optional
The unit in which the value should be given. If not given or `None`,
use the current unit.
equivalencies : list of tuple, optional
A list of equivalence pairs to try if the units are not directly
convertible (see :ref:`unit_equivalencies`). If not provided or
``[]``, class default equivalencies will be used (none for
`~astropy.units.Quantity`, but may be set for subclasses).
If `None`, no equivalencies will be applied at all, not even any
set globally or within a context.
Returns
-------
value : ndarray or scalar
The value in the units specified. For arrays, this will be a view
of the data if no unit conversion was necessary.
See also
--------
to : Get a new instance in a different unit.
"""
if unit is None or unit is self.unit:
value = self.view(np.ndarray)
else:
unit = Unit(unit)
# We want a view if the unit does not change. One could check
# with "==", but that calculates the scale that we need anyway.
# TODO: would be better for `unit.to` to have an in-place flag.
try:
> scale = self.unit._to(unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:747:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), other = Unit(dimensionless)
def _to(self, other):
"""
Returns the scale to the specified unit.
See `to`, except that a Unit object should be given (i.e., no
string), and that all defaults are used, i.e., no
equivalencies and value=1.
"""
# There are many cases where we just want to ensure a Quantity is
# of a particular unit, without checking whether it's already in
# a particular unit. If we're being asked to convert from a unit
# to itself, we can short-circuit all of this.
if self is other:
return 1.0
# Don't presume decomposition is possible; e.g.,
# conversion to function units is through equivalencies.
if isinstance(other, UnitBase):
self_decomposed = self.decompose()
other_decomposed = other.decompose()
# Check quickly whether equivalent. This is faster than
# `is_equivalent`, because it doesn't generate the entire
# physical type list of both units. In other words it "fails
# fast".
if(self_decomposed.powers == other_decomposed.powers and
all(self_base is other_base for (self_base, other_base)
in zip(self_decomposed.bases, other_decomposed.bases))):
return self_decomposed.scale / other_decomposed.scale
raise UnitConversionError(
> f"'{self!r}' is not a scaled version of '{other!r}'")
E astropy.units.core.UnitConversionError: 'Unit("1 / sec")' is not a scaled version of 'Unit(dimensionless)'
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1097: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_LL2.Test_LL2 object at 0x7fa5b4513290>
vplanet_output = <vplanet.Output: solarsys>
param = 'log.initial.Earth.DYoblDtDistRot', value = 9.732005e-13
unit = <Quantity 1. 1 / sec>, param_options = {}
def test_benchmark(self, vplanet_output, param, value, unit, param_options):
# The value returned by vplanet
output_value = recursive_getattr(vplanet_output, param)
# Are we comparing a specific index of an array?
index = param_options.pop("index", None)
if index is not None:
output_value = output_value[index]
# The expected value
benchmark_value = value * unit
# Check
> if np.allclose(output_value, benchmark_value, **param_options) == 0:
tests/benchmark.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<__array_function__ internals>:6: in allclose
???
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1525: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:544: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1356: in _to_own_unit
_value = value.to_value(self.unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:750: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:670: in _to_value
equivalencies=equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1134: in to
equivalencies=equivalencies)(value)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1064: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1050: in _get_converter
self, other, self._normalize_equivalencies(equivalencies))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), unit = Unit("1 / sec"), other = Unit(dimensionless)
equivalencies = []
def _apply_equivalencies(self, unit, other, equivalencies):
"""
Internal function (used from `_get_converter`) to apply
equivalence pairs.
"""
def make_converter(scale1, func, scale2):
def convert(v):
return func(_condition_arg(v) / scale1) * scale2
return convert
for funit, tunit, a, b in equivalencies:
if tunit is None:
try:
ratio_in_funit = (other.decompose() /
unit.decompose()).decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.)
except UnitsError:
pass
else:
try:
scale1 = funit._to(unit)
scale2 = tunit._to(other)
return make_converter(scale1, a, scale2)
except UnitsError:
pass
try:
scale1 = tunit._to(unit)
scale2 = funit._to(other)
return make_converter(scale1, b, scale2)
except UnitsError:
pass
def get_err_str(unit):
unit_str = unit.to_string('unscaled')
physical_type = unit.physical_type
if physical_type != 'unknown':
unit_str = f"'{unit_str}' ({physical_type})"
else:
unit_str = f"'{unit_str}'"
return unit_str
unit_str = get_err_str(unit)
other_str = get_err_str(other)
raise UnitConversionError(
> f"{unit_str} and {other_str} are not convertible")
E astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1026: UnitConversionError
Check warning on line 0 in tests.Distorb.LL2.test_LL2.Test_LL2
github-actions / Test Results
test_benchmark[log.initial.Mars.DYoblDtDistRot-5.571058e-13-unit239-param_options239] (tests.Distorb.LL2.test_LL2.Test_LL2) failed
junit/test-results.xml [took 0s]
Raw output
astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
self = <Quantity 5.571058e-13 1 / sec>, unit = Unit(dimensionless)
equivalencies = []
def to_value(self, unit=None, equivalencies=[]):
"""
The numerical value, possibly in a different unit.
Parameters
----------
unit : unit-like, optional
The unit in which the value should be given. If not given or `None`,
use the current unit.
equivalencies : list of tuple, optional
A list of equivalence pairs to try if the units are not directly
convertible (see :ref:`unit_equivalencies`). If not provided or
``[]``, class default equivalencies will be used (none for
`~astropy.units.Quantity`, but may be set for subclasses).
If `None`, no equivalencies will be applied at all, not even any
set globally or within a context.
Returns
-------
value : ndarray or scalar
The value in the units specified. For arrays, this will be a view
of the data if no unit conversion was necessary.
See also
--------
to : Get a new instance in a different unit.
"""
if unit is None or unit is self.unit:
value = self.view(np.ndarray)
else:
unit = Unit(unit)
# We want a view if the unit does not change. One could check
# with "==", but that calculates the scale that we need anyway.
# TODO: would be better for `unit.to` to have an in-place flag.
try:
> scale = self.unit._to(unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:747:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), other = Unit(dimensionless)
def _to(self, other):
"""
Returns the scale to the specified unit.
See `to`, except that a Unit object should be given (i.e., no
string), and that all defaults are used, i.e., no
equivalencies and value=1.
"""
# There are many cases where we just want to ensure a Quantity is
# of a particular unit, without checking whether it's already in
# a particular unit. If we're being asked to convert from a unit
# to itself, we can short-circuit all of this.
if self is other:
return 1.0
# Don't presume decomposition is possible; e.g.,
# conversion to function units is through equivalencies.
if isinstance(other, UnitBase):
self_decomposed = self.decompose()
other_decomposed = other.decompose()
# Check quickly whether equivalent. This is faster than
# `is_equivalent`, because it doesn't generate the entire
# physical type list of both units. In other words it "fails
# fast".
if(self_decomposed.powers == other_decomposed.powers and
all(self_base is other_base for (self_base, other_base)
in zip(self_decomposed.bases, other_decomposed.bases))):
return self_decomposed.scale / other_decomposed.scale
raise UnitConversionError(
> f"'{self!r}' is not a scaled version of '{other!r}'")
E astropy.units.core.UnitConversionError: 'Unit("1 / sec")' is not a scaled version of 'Unit(dimensionless)'
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1097: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_LL2.Test_LL2 object at 0x7fa5b4542290>
vplanet_output = <vplanet.Output: solarsys>
param = 'log.initial.Mars.DYoblDtDistRot', value = 5.571058e-13
unit = <Quantity 1. 1 / sec>, param_options = {}
def test_benchmark(self, vplanet_output, param, value, unit, param_options):
# The value returned by vplanet
output_value = recursive_getattr(vplanet_output, param)
# Are we comparing a specific index of an array?
index = param_options.pop("index", None)
if index is not None:
output_value = output_value[index]
# The expected value
benchmark_value = value * unit
# Check
> if np.allclose(output_value, benchmark_value, **param_options) == 0:
tests/benchmark.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<__array_function__ internals>:6: in allclose
???
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1525: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:544: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1356: in _to_own_unit
_value = value.to_value(self.unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:750: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:670: in _to_value
equivalencies=equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1134: in to
equivalencies=equivalencies)(value)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1064: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1050: in _get_converter
self, other, self._normalize_equivalencies(equivalencies))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), unit = Unit("1 / sec"), other = Unit(dimensionless)
equivalencies = []
def _apply_equivalencies(self, unit, other, equivalencies):
"""
Internal function (used from `_get_converter`) to apply
equivalence pairs.
"""
def make_converter(scale1, func, scale2):
def convert(v):
return func(_condition_arg(v) / scale1) * scale2
return convert
for funit, tunit, a, b in equivalencies:
if tunit is None:
try:
ratio_in_funit = (other.decompose() /
unit.decompose()).decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.)
except UnitsError:
pass
else:
try:
scale1 = funit._to(unit)
scale2 = tunit._to(other)
return make_converter(scale1, a, scale2)
except UnitsError:
pass
try:
scale1 = tunit._to(unit)
scale2 = funit._to(other)
return make_converter(scale1, b, scale2)
except UnitsError:
pass
def get_err_str(unit):
unit_str = unit.to_string('unscaled')
physical_type = unit.physical_type
if physical_type != 'unknown':
unit_str = f"'{unit_str}' ({physical_type})"
else:
unit_str = f"'{unit_str}'"
return unit_str
unit_str = get_err_str(unit)
other_str = get_err_str(other)
raise UnitConversionError(
> f"{unit_str} and {other_str} are not convertible")
E astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1026: UnitConversionError
Check warning on line 0 in tests.Distorb.LL2.test_LL2.Test_LL2
github-actions / Test Results
test_benchmark[log.final.Venus.DYoblDtDistRot--1.760723e-13-unit521-param_options521] (tests.Distorb.LL2.test_LL2.Test_LL2) failed
junit/test-results.xml [took 0s]
Raw output
astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
self = <Quantity -1.760723e-13 1 / sec>, unit = Unit(dimensionless)
equivalencies = []
def to_value(self, unit=None, equivalencies=[]):
"""
The numerical value, possibly in a different unit.
Parameters
----------
unit : unit-like, optional
The unit in which the value should be given. If not given or `None`,
use the current unit.
equivalencies : list of tuple, optional
A list of equivalence pairs to try if the units are not directly
convertible (see :ref:`unit_equivalencies`). If not provided or
``[]``, class default equivalencies will be used (none for
`~astropy.units.Quantity`, but may be set for subclasses).
If `None`, no equivalencies will be applied at all, not even any
set globally or within a context.
Returns
-------
value : ndarray or scalar
The value in the units specified. For arrays, this will be a view
of the data if no unit conversion was necessary.
See also
--------
to : Get a new instance in a different unit.
"""
if unit is None or unit is self.unit:
value = self.view(np.ndarray)
else:
unit = Unit(unit)
# We want a view if the unit does not change. One could check
# with "==", but that calculates the scale that we need anyway.
# TODO: would be better for `unit.to` to have an in-place flag.
try:
> scale = self.unit._to(unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:747:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), other = Unit(dimensionless)
def _to(self, other):
"""
Returns the scale to the specified unit.
See `to`, except that a Unit object should be given (i.e., no
string), and that all defaults are used, i.e., no
equivalencies and value=1.
"""
# There are many cases where we just want to ensure a Quantity is
# of a particular unit, without checking whether it's already in
# a particular unit. If we're being asked to convert from a unit
# to itself, we can short-circuit all of this.
if self is other:
return 1.0
# Don't presume decomposition is possible; e.g.,
# conversion to function units is through equivalencies.
if isinstance(other, UnitBase):
self_decomposed = self.decompose()
other_decomposed = other.decompose()
# Check quickly whether equivalent. This is faster than
# `is_equivalent`, because it doesn't generate the entire
# physical type list of both units. In other words it "fails
# fast".
if(self_decomposed.powers == other_decomposed.powers and
all(self_base is other_base for (self_base, other_base)
in zip(self_decomposed.bases, other_decomposed.bases))):
return self_decomposed.scale / other_decomposed.scale
raise UnitConversionError(
> f"'{self!r}' is not a scaled version of '{other!r}'")
E astropy.units.core.UnitConversionError: 'Unit("1 / sec")' is not a scaled version of 'Unit(dimensionless)'
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1097: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_LL2.Test_LL2 object at 0x7fa5b4411950>
vplanet_output = <vplanet.Output: solarsys>
param = 'log.final.Venus.DYoblDtDistRot', value = -1.760723e-13
unit = <Quantity 1. 1 / sec>, param_options = {}
def test_benchmark(self, vplanet_output, param, value, unit, param_options):
# The value returned by vplanet
output_value = recursive_getattr(vplanet_output, param)
# Are we comparing a specific index of an array?
index = param_options.pop("index", None)
if index is not None:
output_value = output_value[index]
# The expected value
benchmark_value = value * unit
# Check
> if np.allclose(output_value, benchmark_value, **param_options) == 0:
tests/benchmark.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<__array_function__ internals>:6: in allclose
???
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1525: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:544: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1356: in _to_own_unit
_value = value.to_value(self.unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:750: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:670: in _to_value
equivalencies=equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1134: in to
equivalencies=equivalencies)(value)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1064: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1050: in _get_converter
self, other, self._normalize_equivalencies(equivalencies))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), unit = Unit("1 / sec"), other = Unit(dimensionless)
equivalencies = []
def _apply_equivalencies(self, unit, other, equivalencies):
"""
Internal function (used from `_get_converter`) to apply
equivalence pairs.
"""
def make_converter(scale1, func, scale2):
def convert(v):
return func(_condition_arg(v) / scale1) * scale2
return convert
for funit, tunit, a, b in equivalencies:
if tunit is None:
try:
ratio_in_funit = (other.decompose() /
unit.decompose()).decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.)
except UnitsError:
pass
else:
try:
scale1 = funit._to(unit)
scale2 = tunit._to(other)
return make_converter(scale1, a, scale2)
except UnitsError:
pass
try:
scale1 = tunit._to(unit)
scale2 = funit._to(other)
return make_converter(scale1, b, scale2)
except UnitsError:
pass
def get_err_str(unit):
unit_str = unit.to_string('unscaled')
physical_type = unit.physical_type
if physical_type != 'unknown':
unit_str = f"'{unit_str}' ({physical_type})"
else:
unit_str = f"'{unit_str}'"
return unit_str
unit_str = get_err_str(unit)
other_str = get_err_str(other)
raise UnitConversionError(
> f"{unit_str} and {other_str} are not convertible")
E astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1026: UnitConversionError
Check warning on line 0 in tests.Distorb.LL2.test_LL2.Test_LL2
github-actions / Test Results
test_benchmark[log.final.Earth.DYoblDtDistRot-8.569418e-13-unit584-param_options584] (tests.Distorb.LL2.test_LL2.Test_LL2) failed
junit/test-results.xml [took 0s]
Raw output
astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
self = <Quantity 8.569418e-13 1 / sec>, unit = Unit(dimensionless)
equivalencies = []
def to_value(self, unit=None, equivalencies=[]):
"""
The numerical value, possibly in a different unit.
Parameters
----------
unit : unit-like, optional
The unit in which the value should be given. If not given or `None`,
use the current unit.
equivalencies : list of tuple, optional
A list of equivalence pairs to try if the units are not directly
convertible (see :ref:`unit_equivalencies`). If not provided or
``[]``, class default equivalencies will be used (none for
`~astropy.units.Quantity`, but may be set for subclasses).
If `None`, no equivalencies will be applied at all, not even any
set globally or within a context.
Returns
-------
value : ndarray or scalar
The value in the units specified. For arrays, this will be a view
of the data if no unit conversion was necessary.
See also
--------
to : Get a new instance in a different unit.
"""
if unit is None or unit is self.unit:
value = self.view(np.ndarray)
else:
unit = Unit(unit)
# We want a view if the unit does not change. One could check
# with "==", but that calculates the scale that we need anyway.
# TODO: would be better for `unit.to` to have an in-place flag.
try:
> scale = self.unit._to(unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:747:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), other = Unit(dimensionless)
def _to(self, other):
"""
Returns the scale to the specified unit.
See `to`, except that a Unit object should be given (i.e., no
string), and that all defaults are used, i.e., no
equivalencies and value=1.
"""
# There are many cases where we just want to ensure a Quantity is
# of a particular unit, without checking whether it's already in
# a particular unit. If we're being asked to convert from a unit
# to itself, we can short-circuit all of this.
if self is other:
return 1.0
# Don't presume decomposition is possible; e.g.,
# conversion to function units is through equivalencies.
if isinstance(other, UnitBase):
self_decomposed = self.decompose()
other_decomposed = other.decompose()
# Check quickly whether equivalent. This is faster than
# `is_equivalent`, because it doesn't generate the entire
# physical type list of both units. In other words it "fails
# fast".
if(self_decomposed.powers == other_decomposed.powers and
all(self_base is other_base for (self_base, other_base)
in zip(self_decomposed.bases, other_decomposed.bases))):
return self_decomposed.scale / other_decomposed.scale
raise UnitConversionError(
> f"'{self!r}' is not a scaled version of '{other!r}'")
E astropy.units.core.UnitConversionError: 'Unit("1 / sec")' is not a scaled version of 'Unit(dimensionless)'
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1097: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_LL2.Test_LL2 object at 0x7fa5b4443950>
vplanet_output = <vplanet.Output: solarsys>
param = 'log.final.Earth.DYoblDtDistRot', value = 8.569418e-13
unit = <Quantity 1. 1 / sec>, param_options = {}
def test_benchmark(self, vplanet_output, param, value, unit, param_options):
# The value returned by vplanet
output_value = recursive_getattr(vplanet_output, param)
# Are we comparing a specific index of an array?
index = param_options.pop("index", None)
if index is not None:
output_value = output_value[index]
# The expected value
benchmark_value = value * unit
# Check
> if np.allclose(output_value, benchmark_value, **param_options) == 0:
tests/benchmark.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<__array_function__ internals>:6: in allclose
???
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1525: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:544: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1356: in _to_own_unit
_value = value.to_value(self.unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:750: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:670: in _to_value
equivalencies=equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1134: in to
equivalencies=equivalencies)(value)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1064: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1050: in _get_converter
self, other, self._normalize_equivalencies(equivalencies))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), unit = Unit("1 / sec"), other = Unit(dimensionless)
equivalencies = []
def _apply_equivalencies(self, unit, other, equivalencies):
"""
Internal function (used from `_get_converter`) to apply
equivalence pairs.
"""
def make_converter(scale1, func, scale2):
def convert(v):
return func(_condition_arg(v) / scale1) * scale2
return convert
for funit, tunit, a, b in equivalencies:
if tunit is None:
try:
ratio_in_funit = (other.decompose() /
unit.decompose()).decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.)
except UnitsError:
pass
else:
try:
scale1 = funit._to(unit)
scale2 = tunit._to(other)
return make_converter(scale1, a, scale2)
except UnitsError:
pass
try:
scale1 = tunit._to(unit)
scale2 = funit._to(other)
return make_converter(scale1, b, scale2)
except UnitsError:
pass
def get_err_str(unit):
unit_str = unit.to_string('unscaled')
physical_type = unit.physical_type
if physical_type != 'unknown':
unit_str = f"'{unit_str}' ({physical_type})"
else:
unit_str = f"'{unit_str}'"
return unit_str
unit_str = get_err_str(unit)
other_str = get_err_str(other)
raise UnitConversionError(
> f"{unit_str} and {other_str} are not convertible")
E astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1026: UnitConversionError
Check warning on line 0 in tests.Distorb.LL2.test_LL2.Test_LL2
github-actions / Test Results
test_benchmark[log.final.Mars.DYoblDtDistRot-5.537936e-13-unit647-param_options647] (tests.Distorb.LL2.test_LL2.Test_LL2) failed
junit/test-results.xml [took 0s]
Raw output
astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
self = <Quantity 5.537936e-13 1 / sec>, unit = Unit(dimensionless)
equivalencies = []
def to_value(self, unit=None, equivalencies=[]):
"""
The numerical value, possibly in a different unit.
Parameters
----------
unit : unit-like, optional
The unit in which the value should be given. If not given or `None`,
use the current unit.
equivalencies : list of tuple, optional
A list of equivalence pairs to try if the units are not directly
convertible (see :ref:`unit_equivalencies`). If not provided or
``[]``, class default equivalencies will be used (none for
`~astropy.units.Quantity`, but may be set for subclasses).
If `None`, no equivalencies will be applied at all, not even any
set globally or within a context.
Returns
-------
value : ndarray or scalar
The value in the units specified. For arrays, this will be a view
of the data if no unit conversion was necessary.
See also
--------
to : Get a new instance in a different unit.
"""
if unit is None or unit is self.unit:
value = self.view(np.ndarray)
else:
unit = Unit(unit)
# We want a view if the unit does not change. One could check
# with "==", but that calculates the scale that we need anyway.
# TODO: would be better for `unit.to` to have an in-place flag.
try:
> scale = self.unit._to(unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:747:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), other = Unit(dimensionless)
def _to(self, other):
"""
Returns the scale to the specified unit.
See `to`, except that a Unit object should be given (i.e., no
string), and that all defaults are used, i.e., no
equivalencies and value=1.
"""
# There are many cases where we just want to ensure a Quantity is
# of a particular unit, without checking whether it's already in
# a particular unit. If we're being asked to convert from a unit
# to itself, we can short-circuit all of this.
if self is other:
return 1.0
# Don't presume decomposition is possible; e.g.,
# conversion to function units is through equivalencies.
if isinstance(other, UnitBase):
self_decomposed = self.decompose()
other_decomposed = other.decompose()
# Check quickly whether equivalent. This is faster than
# `is_equivalent`, because it doesn't generate the entire
# physical type list of both units. In other words it "fails
# fast".
if(self_decomposed.powers == other_decomposed.powers and
all(self_base is other_base for (self_base, other_base)
in zip(self_decomposed.bases, other_decomposed.bases))):
return self_decomposed.scale / other_decomposed.scale
raise UnitConversionError(
> f"'{self!r}' is not a scaled version of '{other!r}'")
E astropy.units.core.UnitConversionError: 'Unit("1 / sec")' is not a scaled version of 'Unit(dimensionless)'
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1097: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_LL2.Test_LL2 object at 0x7fa5b43f2950>
vplanet_output = <vplanet.Output: solarsys>
param = 'log.final.Mars.DYoblDtDistRot', value = 5.537936e-13
unit = <Quantity 1. 1 / sec>, param_options = {}
def test_benchmark(self, vplanet_output, param, value, unit, param_options):
# The value returned by vplanet
output_value = recursive_getattr(vplanet_output, param)
# Are we comparing a specific index of an array?
index = param_options.pop("index", None)
if index is not None:
output_value = output_value[index]
# The expected value
benchmark_value = value * unit
# Check
> if np.allclose(output_value, benchmark_value, **param_options) == 0:
tests/benchmark.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<__array_function__ internals>:6: in allclose
???
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1525: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:544: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1356: in _to_own_unit
_value = value.to_value(self.unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:750: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:670: in _to_value
equivalencies=equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1134: in to
equivalencies=equivalencies)(value)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1064: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1050: in _get_converter
self, other, self._normalize_equivalencies(equivalencies))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), unit = Unit("1 / sec"), other = Unit(dimensionless)
equivalencies = []
def _apply_equivalencies(self, unit, other, equivalencies):
"""
Internal function (used from `_get_converter`) to apply
equivalence pairs.
"""
def make_converter(scale1, func, scale2):
def convert(v):
return func(_condition_arg(v) / scale1) * scale2
return convert
for funit, tunit, a, b in equivalencies:
if tunit is None:
try:
ratio_in_funit = (other.decompose() /
unit.decompose()).decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.)
except UnitsError:
pass
else:
try:
scale1 = funit._to(unit)
scale2 = tunit._to(other)
return make_converter(scale1, a, scale2)
except UnitsError:
pass
try:
scale1 = tunit._to(unit)
scale2 = funit._to(other)
return make_converter(scale1, b, scale2)
except UnitsError:
pass
def get_err_str(unit):
unit_str = unit.to_string('unscaled')
physical_type = unit.physical_type
if physical_type != 'unknown':
unit_str = f"'{unit_str}' ({physical_type})"
else:
unit_str = f"'{unit_str}'"
return unit_str
unit_str = get_err_str(unit)
other_str = get_err_str(other)
raise UnitConversionError(
> f"{unit_str} and {other_str} are not convertible")
E astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1026: UnitConversionError
Check warning on line 0 in tests.Distorb.RD4.test_RD4.Test_RD4
github-actions / Test Results
test_benchmark[log.initial.Venus.DYoblDtDistRot--2.924774e-13-unit113-param_options113] (tests.Distorb.RD4.test_RD4.Test_RD4) failed
junit/test-results.xml [took 0s]
Raw output
astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
self = <Quantity -2.924774e-13 1 / sec>, unit = Unit(dimensionless)
equivalencies = []
def to_value(self, unit=None, equivalencies=[]):
"""
The numerical value, possibly in a different unit.
Parameters
----------
unit : unit-like, optional
The unit in which the value should be given. If not given or `None`,
use the current unit.
equivalencies : list of tuple, optional
A list of equivalence pairs to try if the units are not directly
convertible (see :ref:`unit_equivalencies`). If not provided or
``[]``, class default equivalencies will be used (none for
`~astropy.units.Quantity`, but may be set for subclasses).
If `None`, no equivalencies will be applied at all, not even any
set globally or within a context.
Returns
-------
value : ndarray or scalar
The value in the units specified. For arrays, this will be a view
of the data if no unit conversion was necessary.
See also
--------
to : Get a new instance in a different unit.
"""
if unit is None or unit is self.unit:
value = self.view(np.ndarray)
else:
unit = Unit(unit)
# We want a view if the unit does not change. One could check
# with "==", but that calculates the scale that we need anyway.
# TODO: would be better for `unit.to` to have an in-place flag.
try:
> scale = self.unit._to(unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:747:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), other = Unit(dimensionless)
def _to(self, other):
"""
Returns the scale to the specified unit.
See `to`, except that a Unit object should be given (i.e., no
string), and that all defaults are used, i.e., no
equivalencies and value=1.
"""
# There are many cases where we just want to ensure a Quantity is
# of a particular unit, without checking whether it's already in
# a particular unit. If we're being asked to convert from a unit
# to itself, we can short-circuit all of this.
if self is other:
return 1.0
# Don't presume decomposition is possible; e.g.,
# conversion to function units is through equivalencies.
if isinstance(other, UnitBase):
self_decomposed = self.decompose()
other_decomposed = other.decompose()
# Check quickly whether equivalent. This is faster than
# `is_equivalent`, because it doesn't generate the entire
# physical type list of both units. In other words it "fails
# fast".
if(self_decomposed.powers == other_decomposed.powers and
all(self_base is other_base for (self_base, other_base)
in zip(self_decomposed.bases, other_decomposed.bases))):
return self_decomposed.scale / other_decomposed.scale
raise UnitConversionError(
> f"'{self!r}' is not a scaled version of '{other!r}'")
E astropy.units.core.UnitConversionError: 'Unit("1 / sec")' is not a scaled version of 'Unit(dimensionless)'
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1097: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_RD4.Test_RD4 object at 0x7fa5b411add0>
vplanet_output = <vplanet.Output: solarsys>
param = 'log.initial.Venus.DYoblDtDistRot', value = -2.924774e-13
unit = <Quantity 1. 1 / sec>, param_options = {}
def test_benchmark(self, vplanet_output, param, value, unit, param_options):
# The value returned by vplanet
output_value = recursive_getattr(vplanet_output, param)
# Are we comparing a specific index of an array?
index = param_options.pop("index", None)
if index is not None:
output_value = output_value[index]
# The expected value
benchmark_value = value * unit
# Check
> if np.allclose(output_value, benchmark_value, **param_options) == 0:
tests/benchmark.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<__array_function__ internals>:6: in allclose
???
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1525: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:544: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1356: in _to_own_unit
_value = value.to_value(self.unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:750: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:670: in _to_value
equivalencies=equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1134: in to
equivalencies=equivalencies)(value)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1064: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1050: in _get_converter
self, other, self._normalize_equivalencies(equivalencies))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), unit = Unit("1 / sec"), other = Unit(dimensionless)
equivalencies = []
def _apply_equivalencies(self, unit, other, equivalencies):
"""
Internal function (used from `_get_converter`) to apply
equivalence pairs.
"""
def make_converter(scale1, func, scale2):
def convert(v):
return func(_condition_arg(v) / scale1) * scale2
return convert
for funit, tunit, a, b in equivalencies:
if tunit is None:
try:
ratio_in_funit = (other.decompose() /
unit.decompose()).decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.)
except UnitsError:
pass
else:
try:
scale1 = funit._to(unit)
scale2 = tunit._to(other)
return make_converter(scale1, a, scale2)
except UnitsError:
pass
try:
scale1 = tunit._to(unit)
scale2 = funit._to(other)
return make_converter(scale1, b, scale2)
except UnitsError:
pass
def get_err_str(unit):
unit_str = unit.to_string('unscaled')
physical_type = unit.physical_type
if physical_type != 'unknown':
unit_str = f"'{unit_str}' ({physical_type})"
else:
unit_str = f"'{unit_str}'"
return unit_str
unit_str = get_err_str(unit)
other_str = get_err_str(other)
raise UnitConversionError(
> f"{unit_str} and {other_str} are not convertible")
E astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1026: UnitConversionError
Check warning on line 0 in tests.Distorb.RD4.test_RD4.Test_RD4
github-actions / Test Results
test_benchmark[log.initial.Earth.DYoblDtDistRot-3.067482e-12-unit176-param_options176] (tests.Distorb.RD4.test_RD4.Test_RD4) failed
junit/test-results.xml [took 0s]
Raw output
astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
self = <Quantity 3.067482e-12 1 / sec>, unit = Unit(dimensionless)
equivalencies = []
def to_value(self, unit=None, equivalencies=[]):
"""
The numerical value, possibly in a different unit.
Parameters
----------
unit : unit-like, optional
The unit in which the value should be given. If not given or `None`,
use the current unit.
equivalencies : list of tuple, optional
A list of equivalence pairs to try if the units are not directly
convertible (see :ref:`unit_equivalencies`). If not provided or
``[]``, class default equivalencies will be used (none for
`~astropy.units.Quantity`, but may be set for subclasses).
If `None`, no equivalencies will be applied at all, not even any
set globally or within a context.
Returns
-------
value : ndarray or scalar
The value in the units specified. For arrays, this will be a view
of the data if no unit conversion was necessary.
See also
--------
to : Get a new instance in a different unit.
"""
if unit is None or unit is self.unit:
value = self.view(np.ndarray)
else:
unit = Unit(unit)
# We want a view if the unit does not change. One could check
# with "==", but that calculates the scale that we need anyway.
# TODO: would be better for `unit.to` to have an in-place flag.
try:
> scale = self.unit._to(unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:747:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), other = Unit(dimensionless)
def _to(self, other):
"""
Returns the scale to the specified unit.
See `to`, except that a Unit object should be given (i.e., no
string), and that all defaults are used, i.e., no
equivalencies and value=1.
"""
# There are many cases where we just want to ensure a Quantity is
# of a particular unit, without checking whether it's already in
# a particular unit. If we're being asked to convert from a unit
# to itself, we can short-circuit all of this.
if self is other:
return 1.0
# Don't presume decomposition is possible; e.g.,
# conversion to function units is through equivalencies.
if isinstance(other, UnitBase):
self_decomposed = self.decompose()
other_decomposed = other.decompose()
# Check quickly whether equivalent. This is faster than
# `is_equivalent`, because it doesn't generate the entire
# physical type list of both units. In other words it "fails
# fast".
if(self_decomposed.powers == other_decomposed.powers and
all(self_base is other_base for (self_base, other_base)
in zip(self_decomposed.bases, other_decomposed.bases))):
return self_decomposed.scale / other_decomposed.scale
raise UnitConversionError(
> f"'{self!r}' is not a scaled version of '{other!r}'")
E astropy.units.core.UnitConversionError: 'Unit("1 / sec")' is not a scaled version of 'Unit(dimensionless)'
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1097: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_RD4.Test_RD4 object at 0x7fa5b4142dd0>
vplanet_output = <vplanet.Output: solarsys>
param = 'log.initial.Earth.DYoblDtDistRot', value = 3.067482e-12
unit = <Quantity 1. 1 / sec>, param_options = {}
def test_benchmark(self, vplanet_output, param, value, unit, param_options):
# The value returned by vplanet
output_value = recursive_getattr(vplanet_output, param)
# Are we comparing a specific index of an array?
index = param_options.pop("index", None)
if index is not None:
output_value = output_value[index]
# The expected value
benchmark_value = value * unit
# Check
> if np.allclose(output_value, benchmark_value, **param_options) == 0:
tests/benchmark.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<__array_function__ internals>:6: in allclose
???
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1525: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:544: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1356: in _to_own_unit
_value = value.to_value(self.unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:750: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:670: in _to_value
equivalencies=equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1134: in to
equivalencies=equivalencies)(value)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1064: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1050: in _get_converter
self, other, self._normalize_equivalencies(equivalencies))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), unit = Unit("1 / sec"), other = Unit(dimensionless)
equivalencies = []
def _apply_equivalencies(self, unit, other, equivalencies):
"""
Internal function (used from `_get_converter`) to apply
equivalence pairs.
"""
def make_converter(scale1, func, scale2):
def convert(v):
return func(_condition_arg(v) / scale1) * scale2
return convert
for funit, tunit, a, b in equivalencies:
if tunit is None:
try:
ratio_in_funit = (other.decompose() /
unit.decompose()).decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.)
except UnitsError:
pass
else:
try:
scale1 = funit._to(unit)
scale2 = tunit._to(other)
return make_converter(scale1, a, scale2)
except UnitsError:
pass
try:
scale1 = tunit._to(unit)
scale2 = funit._to(other)
return make_converter(scale1, b, scale2)
except UnitsError:
pass
def get_err_str(unit):
unit_str = unit.to_string('unscaled')
physical_type = unit.physical_type
if physical_type != 'unknown':
unit_str = f"'{unit_str}' ({physical_type})"
else:
unit_str = f"'{unit_str}'"
return unit_str
unit_str = get_err_str(unit)
other_str = get_err_str(other)
raise UnitConversionError(
> f"{unit_str} and {other_str} are not convertible")
E astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1026: UnitConversionError
Check warning on line 0 in tests.Distorb.RD4.test_RD4.Test_RD4
github-actions / Test Results
test_benchmark[log.initial.Mars.DYoblDtDistRot-5.583147e-13-unit239-param_options239] (tests.Distorb.RD4.test_RD4.Test_RD4) failed
junit/test-results.xml [took 0s]
Raw output
astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
self = <Quantity 5.583147e-13 1 / sec>, unit = Unit(dimensionless)
equivalencies = []
def to_value(self, unit=None, equivalencies=[]):
"""
The numerical value, possibly in a different unit.
Parameters
----------
unit : unit-like, optional
The unit in which the value should be given. If not given or `None`,
use the current unit.
equivalencies : list of tuple, optional
A list of equivalence pairs to try if the units are not directly
convertible (see :ref:`unit_equivalencies`). If not provided or
``[]``, class default equivalencies will be used (none for
`~astropy.units.Quantity`, but may be set for subclasses).
If `None`, no equivalencies will be applied at all, not even any
set globally or within a context.
Returns
-------
value : ndarray or scalar
The value in the units specified. For arrays, this will be a view
of the data if no unit conversion was necessary.
See also
--------
to : Get a new instance in a different unit.
"""
if unit is None or unit is self.unit:
value = self.view(np.ndarray)
else:
unit = Unit(unit)
# We want a view if the unit does not change. One could check
# with "==", but that calculates the scale that we need anyway.
# TODO: would be better for `unit.to` to have an in-place flag.
try:
> scale = self.unit._to(unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:747:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), other = Unit(dimensionless)
def _to(self, other):
"""
Returns the scale to the specified unit.
See `to`, except that a Unit object should be given (i.e., no
string), and that all defaults are used, i.e., no
equivalencies and value=1.
"""
# There are many cases where we just want to ensure a Quantity is
# of a particular unit, without checking whether it's already in
# a particular unit. If we're being asked to convert from a unit
# to itself, we can short-circuit all of this.
if self is other:
return 1.0
# Don't presume decomposition is possible; e.g.,
# conversion to function units is through equivalencies.
if isinstance(other, UnitBase):
self_decomposed = self.decompose()
other_decomposed = other.decompose()
# Check quickly whether equivalent. This is faster than
# `is_equivalent`, because it doesn't generate the entire
# physical type list of both units. In other words it "fails
# fast".
if(self_decomposed.powers == other_decomposed.powers and
all(self_base is other_base for (self_base, other_base)
in zip(self_decomposed.bases, other_decomposed.bases))):
return self_decomposed.scale / other_decomposed.scale
raise UnitConversionError(
> f"'{self!r}' is not a scaled version of '{other!r}'")
E astropy.units.core.UnitConversionError: 'Unit("1 / sec")' is not a scaled version of 'Unit(dimensionless)'
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1097: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_RD4.Test_RD4 object at 0x7fa5b40f3dd0>
vplanet_output = <vplanet.Output: solarsys>
param = 'log.initial.Mars.DYoblDtDistRot', value = 5.583147e-13
unit = <Quantity 1. 1 / sec>, param_options = {}
def test_benchmark(self, vplanet_output, param, value, unit, param_options):
# The value returned by vplanet
output_value = recursive_getattr(vplanet_output, param)
# Are we comparing a specific index of an array?
index = param_options.pop("index", None)
if index is not None:
output_value = output_value[index]
# The expected value
benchmark_value = value * unit
# Check
> if np.allclose(output_value, benchmark_value, **param_options) == 0:
tests/benchmark.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<__array_function__ internals>:6: in allclose
???
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1525: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:544: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1356: in _to_own_unit
_value = value.to_value(self.unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:750: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:670: in _to_value
equivalencies=equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1134: in to
equivalencies=equivalencies)(value)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1064: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1050: in _get_converter
self, other, self._normalize_equivalencies(equivalencies))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), unit = Unit("1 / sec"), other = Unit(dimensionless)
equivalencies = []
def _apply_equivalencies(self, unit, other, equivalencies):
"""
Internal function (used from `_get_converter`) to apply
equivalence pairs.
"""
def make_converter(scale1, func, scale2):
def convert(v):
return func(_condition_arg(v) / scale1) * scale2
return convert
for funit, tunit, a, b in equivalencies:
if tunit is None:
try:
ratio_in_funit = (other.decompose() /
unit.decompose()).decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.)
except UnitsError:
pass
else:
try:
scale1 = funit._to(unit)
scale2 = tunit._to(other)
return make_converter(scale1, a, scale2)
except UnitsError:
pass
try:
scale1 = tunit._to(unit)
scale2 = funit._to(other)
return make_converter(scale1, b, scale2)
except UnitsError:
pass
def get_err_str(unit):
unit_str = unit.to_string('unscaled')
physical_type = unit.physical_type
if physical_type != 'unknown':
unit_str = f"'{unit_str}' ({physical_type})"
else:
unit_str = f"'{unit_str}'"
return unit_str
unit_str = get_err_str(unit)
other_str = get_err_str(other)
raise UnitConversionError(
> f"{unit_str} and {other_str} are not convertible")
E astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1026: UnitConversionError
Check warning on line 0 in tests.Distorb.RD4.test_RD4.Test_RD4
github-actions / Test Results
test_benchmark[log.final.Venus.DYoblDtDistRot--1.766696e-13-unit521-param_options521] (tests.Distorb.RD4.test_RD4.Test_RD4) failed
junit/test-results.xml [took 0s]
Raw output
astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
self = <Quantity -1.766696e-13 1 / sec>, unit = Unit(dimensionless)
equivalencies = []
def to_value(self, unit=None, equivalencies=[]):
"""
The numerical value, possibly in a different unit.
Parameters
----------
unit : unit-like, optional
The unit in which the value should be given. If not given or `None`,
use the current unit.
equivalencies : list of tuple, optional
A list of equivalence pairs to try if the units are not directly
convertible (see :ref:`unit_equivalencies`). If not provided or
``[]``, class default equivalencies will be used (none for
`~astropy.units.Quantity`, but may be set for subclasses).
If `None`, no equivalencies will be applied at all, not even any
set globally or within a context.
Returns
-------
value : ndarray or scalar
The value in the units specified. For arrays, this will be a view
of the data if no unit conversion was necessary.
See also
--------
to : Get a new instance in a different unit.
"""
if unit is None or unit is self.unit:
value = self.view(np.ndarray)
else:
unit = Unit(unit)
# We want a view if the unit does not change. One could check
# with "==", but that calculates the scale that we need anyway.
# TODO: would be better for `unit.to` to have an in-place flag.
try:
> scale = self.unit._to(unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:747:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), other = Unit(dimensionless)
def _to(self, other):
"""
Returns the scale to the specified unit.
See `to`, except that a Unit object should be given (i.e., no
string), and that all defaults are used, i.e., no
equivalencies and value=1.
"""
# There are many cases where we just want to ensure a Quantity is
# of a particular unit, without checking whether it's already in
# a particular unit. If we're being asked to convert from a unit
# to itself, we can short-circuit all of this.
if self is other:
return 1.0
# Don't presume decomposition is possible; e.g.,
# conversion to function units is through equivalencies.
if isinstance(other, UnitBase):
self_decomposed = self.decompose()
other_decomposed = other.decompose()
# Check quickly whether equivalent. This is faster than
# `is_equivalent`, because it doesn't generate the entire
# physical type list of both units. In other words it "fails
# fast".
if(self_decomposed.powers == other_decomposed.powers and
all(self_base is other_base for (self_base, other_base)
in zip(self_decomposed.bases, other_decomposed.bases))):
return self_decomposed.scale / other_decomposed.scale
raise UnitConversionError(
> f"'{self!r}' is not a scaled version of '{other!r}'")
E astropy.units.core.UnitConversionError: 'Unit("1 / sec")' is not a scaled version of 'Unit(dimensionless)'
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1097: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_RD4.Test_RD4 object at 0x7fa5b3fd14d0>
vplanet_output = <vplanet.Output: solarsys>
param = 'log.final.Venus.DYoblDtDistRot', value = -1.766696e-13
unit = <Quantity 1. 1 / sec>, param_options = {}
def test_benchmark(self, vplanet_output, param, value, unit, param_options):
# The value returned by vplanet
output_value = recursive_getattr(vplanet_output, param)
# Are we comparing a specific index of an array?
index = param_options.pop("index", None)
if index is not None:
output_value = output_value[index]
# The expected value
benchmark_value = value * unit
# Check
> if np.allclose(output_value, benchmark_value, **param_options) == 0:
tests/benchmark.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<__array_function__ internals>:6: in allclose
???
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1525: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:544: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1356: in _to_own_unit
_value = value.to_value(self.unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:750: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:670: in _to_value
equivalencies=equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1134: in to
equivalencies=equivalencies)(value)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1064: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1050: in _get_converter
self, other, self._normalize_equivalencies(equivalencies))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), unit = Unit("1 / sec"), other = Unit(dimensionless)
equivalencies = []
def _apply_equivalencies(self, unit, other, equivalencies):
"""
Internal function (used from `_get_converter`) to apply
equivalence pairs.
"""
def make_converter(scale1, func, scale2):
def convert(v):
return func(_condition_arg(v) / scale1) * scale2
return convert
for funit, tunit, a, b in equivalencies:
if tunit is None:
try:
ratio_in_funit = (other.decompose() /
unit.decompose()).decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.)
except UnitsError:
pass
else:
try:
scale1 = funit._to(unit)
scale2 = tunit._to(other)
return make_converter(scale1, a, scale2)
except UnitsError:
pass
try:
scale1 = tunit._to(unit)
scale2 = funit._to(other)
return make_converter(scale1, b, scale2)
except UnitsError:
pass
def get_err_str(unit):
unit_str = unit.to_string('unscaled')
physical_type = unit.physical_type
if physical_type != 'unknown':
unit_str = f"'{unit_str}' ({physical_type})"
else:
unit_str = f"'{unit_str}'"
return unit_str
unit_str = get_err_str(unit)
other_str = get_err_str(other)
raise UnitConversionError(
> f"{unit_str} and {other_str} are not convertible")
E astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1026: UnitConversionError
Check warning on line 0 in tests.Distorb.RD4.test_RD4.Test_RD4
github-actions / Test Results
test_benchmark[log.final.Earth.DYoblDtDistRot-9.822112e-13-unit584-param_options584] (tests.Distorb.RD4.test_RD4.Test_RD4) failed
junit/test-results.xml [took 0s]
Raw output
astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
self = <Quantity 9.822112e-13 1 / sec>, unit = Unit(dimensionless)
equivalencies = []
def to_value(self, unit=None, equivalencies=[]):
"""
The numerical value, possibly in a different unit.
Parameters
----------
unit : unit-like, optional
The unit in which the value should be given. If not given or `None`,
use the current unit.
equivalencies : list of tuple, optional
A list of equivalence pairs to try if the units are not directly
convertible (see :ref:`unit_equivalencies`). If not provided or
``[]``, class default equivalencies will be used (none for
`~astropy.units.Quantity`, but may be set for subclasses).
If `None`, no equivalencies will be applied at all, not even any
set globally or within a context.
Returns
-------
value : ndarray or scalar
The value in the units specified. For arrays, this will be a view
of the data if no unit conversion was necessary.
See also
--------
to : Get a new instance in a different unit.
"""
if unit is None or unit is self.unit:
value = self.view(np.ndarray)
else:
unit = Unit(unit)
# We want a view if the unit does not change. One could check
# with "==", but that calculates the scale that we need anyway.
# TODO: would be better for `unit.to` to have an in-place flag.
try:
> scale = self.unit._to(unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:747:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), other = Unit(dimensionless)
def _to(self, other):
"""
Returns the scale to the specified unit.
See `to`, except that a Unit object should be given (i.e., no
string), and that all defaults are used, i.e., no
equivalencies and value=1.
"""
# There are many cases where we just want to ensure a Quantity is
# of a particular unit, without checking whether it's already in
# a particular unit. If we're being asked to convert from a unit
# to itself, we can short-circuit all of this.
if self is other:
return 1.0
# Don't presume decomposition is possible; e.g.,
# conversion to function units is through equivalencies.
if isinstance(other, UnitBase):
self_decomposed = self.decompose()
other_decomposed = other.decompose()
# Check quickly whether equivalent. This is faster than
# `is_equivalent`, because it doesn't generate the entire
# physical type list of both units. In other words it "fails
# fast".
if(self_decomposed.powers == other_decomposed.powers and
all(self_base is other_base for (self_base, other_base)
in zip(self_decomposed.bases, other_decomposed.bases))):
return self_decomposed.scale / other_decomposed.scale
raise UnitConversionError(
> f"'{self!r}' is not a scaled version of '{other!r}'")
E astropy.units.core.UnitConversionError: 'Unit("1 / sec")' is not a scaled version of 'Unit(dimensionless)'
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1097: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_RD4.Test_RD4 object at 0x7fa5b40014d0>
vplanet_output = <vplanet.Output: solarsys>
param = 'log.final.Earth.DYoblDtDistRot', value = 9.822112e-13
unit = <Quantity 1. 1 / sec>, param_options = {}
def test_benchmark(self, vplanet_output, param, value, unit, param_options):
# The value returned by vplanet
output_value = recursive_getattr(vplanet_output, param)
# Are we comparing a specific index of an array?
index = param_options.pop("index", None)
if index is not None:
output_value = output_value[index]
# The expected value
benchmark_value = value * unit
# Check
> if np.allclose(output_value, benchmark_value, **param_options) == 0:
tests/benchmark.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<__array_function__ internals>:6: in allclose
???
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1525: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:544: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1356: in _to_own_unit
_value = value.to_value(self.unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:750: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:670: in _to_value
equivalencies=equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1134: in to
equivalencies=equivalencies)(value)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1064: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1050: in _get_converter
self, other, self._normalize_equivalencies(equivalencies))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), unit = Unit("1 / sec"), other = Unit(dimensionless)
equivalencies = []
def _apply_equivalencies(self, unit, other, equivalencies):
"""
Internal function (used from `_get_converter`) to apply
equivalence pairs.
"""
def make_converter(scale1, func, scale2):
def convert(v):
return func(_condition_arg(v) / scale1) * scale2
return convert
for funit, tunit, a, b in equivalencies:
if tunit is None:
try:
ratio_in_funit = (other.decompose() /
unit.decompose()).decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.)
except UnitsError:
pass
else:
try:
scale1 = funit._to(unit)
scale2 = tunit._to(other)
return make_converter(scale1, a, scale2)
except UnitsError:
pass
try:
scale1 = tunit._to(unit)
scale2 = funit._to(other)
return make_converter(scale1, b, scale2)
except UnitsError:
pass
def get_err_str(unit):
unit_str = unit.to_string('unscaled')
physical_type = unit.physical_type
if physical_type != 'unknown':
unit_str = f"'{unit_str}' ({physical_type})"
else:
unit_str = f"'{unit_str}'"
return unit_str
unit_str = get_err_str(unit)
other_str = get_err_str(other)
raise UnitConversionError(
> f"{unit_str} and {other_str} are not convertible")
E astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1026: UnitConversionError
Check warning on line 0 in tests.Distorb.RD4.test_RD4.Test_RD4
github-actions / Test Results
test_benchmark[log.final.Mars.DYoblDtDistRot-5.548395e-13-unit647-param_options647] (tests.Distorb.RD4.test_RD4.Test_RD4) failed
junit/test-results.xml [took 0s]
Raw output
astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
self = <Quantity 5.548395e-13 1 / sec>, unit = Unit(dimensionless)
equivalencies = []
def to_value(self, unit=None, equivalencies=[]):
"""
The numerical value, possibly in a different unit.
Parameters
----------
unit : unit-like, optional
The unit in which the value should be given. If not given or `None`,
use the current unit.
equivalencies : list of tuple, optional
A list of equivalence pairs to try if the units are not directly
convertible (see :ref:`unit_equivalencies`). If not provided or
``[]``, class default equivalencies will be used (none for
`~astropy.units.Quantity`, but may be set for subclasses).
If `None`, no equivalencies will be applied at all, not even any
set globally or within a context.
Returns
-------
value : ndarray or scalar
The value in the units specified. For arrays, this will be a view
of the data if no unit conversion was necessary.
See also
--------
to : Get a new instance in a different unit.
"""
if unit is None or unit is self.unit:
value = self.view(np.ndarray)
else:
unit = Unit(unit)
# We want a view if the unit does not change. One could check
# with "==", but that calculates the scale that we need anyway.
# TODO: would be better for `unit.to` to have an in-place flag.
try:
> scale = self.unit._to(unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:747:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), other = Unit(dimensionless)
def _to(self, other):
"""
Returns the scale to the specified unit.
See `to`, except that a Unit object should be given (i.e., no
string), and that all defaults are used, i.e., no
equivalencies and value=1.
"""
# There are many cases where we just want to ensure a Quantity is
# of a particular unit, without checking whether it's already in
# a particular unit. If we're being asked to convert from a unit
# to itself, we can short-circuit all of this.
if self is other:
return 1.0
# Don't presume decomposition is possible; e.g.,
# conversion to function units is through equivalencies.
if isinstance(other, UnitBase):
self_decomposed = self.decompose()
other_decomposed = other.decompose()
# Check quickly whether equivalent. This is faster than
# `is_equivalent`, because it doesn't generate the entire
# physical type list of both units. In other words it "fails
# fast".
if(self_decomposed.powers == other_decomposed.powers and
all(self_base is other_base for (self_base, other_base)
in zip(self_decomposed.bases, other_decomposed.bases))):
return self_decomposed.scale / other_decomposed.scale
raise UnitConversionError(
> f"'{self!r}' is not a scaled version of '{other!r}'")
E astropy.units.core.UnitConversionError: 'Unit("1 / sec")' is not a scaled version of 'Unit(dimensionless)'
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1097: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_RD4.Test_RD4 object at 0x7fa5b3fb24d0>
vplanet_output = <vplanet.Output: solarsys>
param = 'log.final.Mars.DYoblDtDistRot', value = 5.548395e-13
unit = <Quantity 1. 1 / sec>, param_options = {}
def test_benchmark(self, vplanet_output, param, value, unit, param_options):
# The value returned by vplanet
output_value = recursive_getattr(vplanet_output, param)
# Are we comparing a specific index of an array?
index = param_options.pop("index", None)
if index is not None:
output_value = output_value[index]
# The expected value
benchmark_value = value * unit
# Check
> if np.allclose(output_value, benchmark_value, **param_options) == 0:
tests/benchmark.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<__array_function__ internals>:6: in allclose
???
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1525: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:544: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1356: in _to_own_unit
_value = value.to_value(self.unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:750: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:670: in _to_value
equivalencies=equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1134: in to
equivalencies=equivalencies)(value)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1064: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1050: in _get_converter
self, other, self._normalize_equivalencies(equivalencies))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), unit = Unit("1 / sec"), other = Unit(dimensionless)
equivalencies = []
def _apply_equivalencies(self, unit, other, equivalencies):
"""
Internal function (used from `_get_converter`) to apply
equivalence pairs.
"""
def make_converter(scale1, func, scale2):
def convert(v):
return func(_condition_arg(v) / scale1) * scale2
return convert
for funit, tunit, a, b in equivalencies:
if tunit is None:
try:
ratio_in_funit = (other.decompose() /
unit.decompose()).decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.)
except UnitsError:
pass
else:
try:
scale1 = funit._to(unit)
scale2 = tunit._to(other)
return make_converter(scale1, a, scale2)
except UnitsError:
pass
try:
scale1 = tunit._to(unit)
scale2 = funit._to(other)
return make_converter(scale1, b, scale2)
except UnitsError:
pass
def get_err_str(unit):
unit_str = unit.to_string('unscaled')
physical_type = unit.physical_type
if physical_type != 'unknown':
unit_str = f"'{unit_str}' ({physical_type})"
else:
unit_str = f"'{unit_str}'"
return unit_str
unit_str = get_err_str(unit)
other_str = get_err_str(other)
raise UnitConversionError(
> f"{unit_str} and {other_str} are not convertible")
E astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1026: UnitConversionError
github-actions / Test Results
test_benchmark[log.initial.Venus.DYoblDtDistRot--2.924774e-13-unit113-param_options113] (tests.DistorbDistrot.SSDistOrbDistRot.test_SSDistOrbDistRot.Test_SSDistOrbDistRot) failed
junit/test-results.xml [took 0s]
Raw output
astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
self = <Quantity -2.924774e-13 1 / sec>, unit = Unit(dimensionless)
equivalencies = []
def to_value(self, unit=None, equivalencies=[]):
"""
The numerical value, possibly in a different unit.
Parameters
----------
unit : unit-like, optional
The unit in which the value should be given. If not given or `None`,
use the current unit.
equivalencies : list of tuple, optional
A list of equivalence pairs to try if the units are not directly
convertible (see :ref:`unit_equivalencies`). If not provided or
``[]``, class default equivalencies will be used (none for
`~astropy.units.Quantity`, but may be set for subclasses).
If `None`, no equivalencies will be applied at all, not even any
set globally or within a context.
Returns
-------
value : ndarray or scalar
The value in the units specified. For arrays, this will be a view
of the data if no unit conversion was necessary.
See also
--------
to : Get a new instance in a different unit.
"""
if unit is None or unit is self.unit:
value = self.view(np.ndarray)
else:
unit = Unit(unit)
# We want a view if the unit does not change. One could check
# with "==", but that calculates the scale that we need anyway.
# TODO: would be better for `unit.to` to have an in-place flag.
try:
> scale = self.unit._to(unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:747:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), other = Unit(dimensionless)
def _to(self, other):
"""
Returns the scale to the specified unit.
See `to`, except that a Unit object should be given (i.e., no
string), and that all defaults are used, i.e., no
equivalencies and value=1.
"""
# There are many cases where we just want to ensure a Quantity is
# of a particular unit, without checking whether it's already in
# a particular unit. If we're being asked to convert from a unit
# to itself, we can short-circuit all of this.
if self is other:
return 1.0
# Don't presume decomposition is possible; e.g.,
# conversion to function units is through equivalencies.
if isinstance(other, UnitBase):
self_decomposed = self.decompose()
other_decomposed = other.decompose()
# Check quickly whether equivalent. This is faster than
# `is_equivalent`, because it doesn't generate the entire
# physical type list of both units. In other words it "fails
# fast".
if(self_decomposed.powers == other_decomposed.powers and
all(self_base is other_base for (self_base, other_base)
in zip(self_decomposed.bases, other_decomposed.bases))):
return self_decomposed.scale / other_decomposed.scale
raise UnitConversionError(
> f"'{self!r}' is not a scaled version of '{other!r}'")
E astropy.units.core.UnitConversionError: 'Unit("1 / sec")' is not a scaled version of 'Unit(dimensionless)'
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1097: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_SSDistOrbDistRot.Test_SSDistOrbDistRot object at 0x7fa5b3cdc790>
vplanet_output = <vplanet.Output: solarsys>
param = 'log.initial.Venus.DYoblDtDistRot', value = -2.924774e-13
unit = <Quantity 1. 1 / sec>, param_options = {}
def test_benchmark(self, vplanet_output, param, value, unit, param_options):
# The value returned by vplanet
output_value = recursive_getattr(vplanet_output, param)
# Are we comparing a specific index of an array?
index = param_options.pop("index", None)
if index is not None:
output_value = output_value[index]
# The expected value
benchmark_value = value * unit
# Check
> if np.allclose(output_value, benchmark_value, **param_options) == 0:
tests/benchmark.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<__array_function__ internals>:6: in allclose
???
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1525: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:544: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1356: in _to_own_unit
_value = value.to_value(self.unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:750: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:670: in _to_value
equivalencies=equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1134: in to
equivalencies=equivalencies)(value)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1064: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1050: in _get_converter
self, other, self._normalize_equivalencies(equivalencies))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), unit = Unit("1 / sec"), other = Unit(dimensionless)
equivalencies = []
def _apply_equivalencies(self, unit, other, equivalencies):
"""
Internal function (used from `_get_converter`) to apply
equivalence pairs.
"""
def make_converter(scale1, func, scale2):
def convert(v):
return func(_condition_arg(v) / scale1) * scale2
return convert
for funit, tunit, a, b in equivalencies:
if tunit is None:
try:
ratio_in_funit = (other.decompose() /
unit.decompose()).decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.)
except UnitsError:
pass
else:
try:
scale1 = funit._to(unit)
scale2 = tunit._to(other)
return make_converter(scale1, a, scale2)
except UnitsError:
pass
try:
scale1 = tunit._to(unit)
scale2 = funit._to(other)
return make_converter(scale1, b, scale2)
except UnitsError:
pass
def get_err_str(unit):
unit_str = unit.to_string('unscaled')
physical_type = unit.physical_type
if physical_type != 'unknown':
unit_str = f"'{unit_str}' ({physical_type})"
else:
unit_str = f"'{unit_str}'"
return unit_str
unit_str = get_err_str(unit)
other_str = get_err_str(other)
raise UnitConversionError(
> f"{unit_str} and {other_str} are not convertible")
E astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1026: UnitConversionError
github-actions / Test Results
test_benchmark[log.initial.Earth.DYoblDtDistRot-3.067482e-12-unit176-param_options176] (tests.DistorbDistrot.SSDistOrbDistRot.test_SSDistOrbDistRot.Test_SSDistOrbDistRot) failed
junit/test-results.xml [took 0s]
Raw output
astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
self = <Quantity 3.067482e-12 1 / sec>, unit = Unit(dimensionless)
equivalencies = []
def to_value(self, unit=None, equivalencies=[]):
"""
The numerical value, possibly in a different unit.
Parameters
----------
unit : unit-like, optional
The unit in which the value should be given. If not given or `None`,
use the current unit.
equivalencies : list of tuple, optional
A list of equivalence pairs to try if the units are not directly
convertible (see :ref:`unit_equivalencies`). If not provided or
``[]``, class default equivalencies will be used (none for
`~astropy.units.Quantity`, but may be set for subclasses).
If `None`, no equivalencies will be applied at all, not even any
set globally or within a context.
Returns
-------
value : ndarray or scalar
The value in the units specified. For arrays, this will be a view
of the data if no unit conversion was necessary.
See also
--------
to : Get a new instance in a different unit.
"""
if unit is None or unit is self.unit:
value = self.view(np.ndarray)
else:
unit = Unit(unit)
# We want a view if the unit does not change. One could check
# with "==", but that calculates the scale that we need anyway.
# TODO: would be better for `unit.to` to have an in-place flag.
try:
> scale = self.unit._to(unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:747:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), other = Unit(dimensionless)
def _to(self, other):
"""
Returns the scale to the specified unit.
See `to`, except that a Unit object should be given (i.e., no
string), and that all defaults are used, i.e., no
equivalencies and value=1.
"""
# There are many cases where we just want to ensure a Quantity is
# of a particular unit, without checking whether it's already in
# a particular unit. If we're being asked to convert from a unit
# to itself, we can short-circuit all of this.
if self is other:
return 1.0
# Don't presume decomposition is possible; e.g.,
# conversion to function units is through equivalencies.
if isinstance(other, UnitBase):
self_decomposed = self.decompose()
other_decomposed = other.decompose()
# Check quickly whether equivalent. This is faster than
# `is_equivalent`, because it doesn't generate the entire
# physical type list of both units. In other words it "fails
# fast".
if(self_decomposed.powers == other_decomposed.powers and
all(self_base is other_base for (self_base, other_base)
in zip(self_decomposed.bases, other_decomposed.bases))):
return self_decomposed.scale / other_decomposed.scale
raise UnitConversionError(
> f"'{self!r}' is not a scaled version of '{other!r}'")
E astropy.units.core.UnitConversionError: 'Unit("1 / sec")' is not a scaled version of 'Unit(dimensionless)'
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1097: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_SSDistOrbDistRot.Test_SSDistOrbDistRot object at 0x7fa5b3d05790>
vplanet_output = <vplanet.Output: solarsys>
param = 'log.initial.Earth.DYoblDtDistRot', value = 3.067482e-12
unit = <Quantity 1. 1 / sec>, param_options = {}
def test_benchmark(self, vplanet_output, param, value, unit, param_options):
# The value returned by vplanet
output_value = recursive_getattr(vplanet_output, param)
# Are we comparing a specific index of an array?
index = param_options.pop("index", None)
if index is not None:
output_value = output_value[index]
# The expected value
benchmark_value = value * unit
# Check
> if np.allclose(output_value, benchmark_value, **param_options) == 0:
tests/benchmark.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<__array_function__ internals>:6: in allclose
???
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1525: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:544: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1356: in _to_own_unit
_value = value.to_value(self.unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:750: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:670: in _to_value
equivalencies=equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1134: in to
equivalencies=equivalencies)(value)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1064: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1050: in _get_converter
self, other, self._normalize_equivalencies(equivalencies))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), unit = Unit("1 / sec"), other = Unit(dimensionless)
equivalencies = []
def _apply_equivalencies(self, unit, other, equivalencies):
"""
Internal function (used from `_get_converter`) to apply
equivalence pairs.
"""
def make_converter(scale1, func, scale2):
def convert(v):
return func(_condition_arg(v) / scale1) * scale2
return convert
for funit, tunit, a, b in equivalencies:
if tunit is None:
try:
ratio_in_funit = (other.decompose() /
unit.decompose()).decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.)
except UnitsError:
pass
else:
try:
scale1 = funit._to(unit)
scale2 = tunit._to(other)
return make_converter(scale1, a, scale2)
except UnitsError:
pass
try:
scale1 = tunit._to(unit)
scale2 = funit._to(other)
return make_converter(scale1, b, scale2)
except UnitsError:
pass
def get_err_str(unit):
unit_str = unit.to_string('unscaled')
physical_type = unit.physical_type
if physical_type != 'unknown':
unit_str = f"'{unit_str}' ({physical_type})"
else:
unit_str = f"'{unit_str}'"
return unit_str
unit_str = get_err_str(unit)
other_str = get_err_str(other)
raise UnitConversionError(
> f"{unit_str} and {other_str} are not convertible")
E astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1026: UnitConversionError
github-actions / Test Results
test_benchmark[log.initial.Mars.DYoblDtDistRot-5.583147e-13-unit239-param_options239] (tests.DistorbDistrot.SSDistOrbDistRot.test_SSDistOrbDistRot.Test_SSDistOrbDistRot) failed
junit/test-results.xml [took 0s]
Raw output
astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
self = <Quantity 5.583147e-13 1 / sec>, unit = Unit(dimensionless)
equivalencies = []
def to_value(self, unit=None, equivalencies=[]):
"""
The numerical value, possibly in a different unit.
Parameters
----------
unit : unit-like, optional
The unit in which the value should be given. If not given or `None`,
use the current unit.
equivalencies : list of tuple, optional
A list of equivalence pairs to try if the units are not directly
convertible (see :ref:`unit_equivalencies`). If not provided or
``[]``, class default equivalencies will be used (none for
`~astropy.units.Quantity`, but may be set for subclasses).
If `None`, no equivalencies will be applied at all, not even any
set globally or within a context.
Returns
-------
value : ndarray or scalar
The value in the units specified. For arrays, this will be a view
of the data if no unit conversion was necessary.
See also
--------
to : Get a new instance in a different unit.
"""
if unit is None or unit is self.unit:
value = self.view(np.ndarray)
else:
unit = Unit(unit)
# We want a view if the unit does not change. One could check
# with "==", but that calculates the scale that we need anyway.
# TODO: would be better for `unit.to` to have an in-place flag.
try:
> scale = self.unit._to(unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:747:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), other = Unit(dimensionless)
def _to(self, other):
"""
Returns the scale to the specified unit.
See `to`, except that a Unit object should be given (i.e., no
string), and that all defaults are used, i.e., no
equivalencies and value=1.
"""
# There are many cases where we just want to ensure a Quantity is
# of a particular unit, without checking whether it's already in
# a particular unit. If we're being asked to convert from a unit
# to itself, we can short-circuit all of this.
if self is other:
return 1.0
# Don't presume decomposition is possible; e.g.,
# conversion to function units is through equivalencies.
if isinstance(other, UnitBase):
self_decomposed = self.decompose()
other_decomposed = other.decompose()
# Check quickly whether equivalent. This is faster than
# `is_equivalent`, because it doesn't generate the entire
# physical type list of both units. In other words it "fails
# fast".
if(self_decomposed.powers == other_decomposed.powers and
all(self_base is other_base for (self_base, other_base)
in zip(self_decomposed.bases, other_decomposed.bases))):
return self_decomposed.scale / other_decomposed.scale
raise UnitConversionError(
> f"'{self!r}' is not a scaled version of '{other!r}'")
E astropy.units.core.UnitConversionError: 'Unit("1 / sec")' is not a scaled version of 'Unit(dimensionless)'
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1097: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_SSDistOrbDistRot.Test_SSDistOrbDistRot object at 0x7fa5b3cb6790>
vplanet_output = <vplanet.Output: solarsys>
param = 'log.initial.Mars.DYoblDtDistRot', value = 5.583147e-13
unit = <Quantity 1. 1 / sec>, param_options = {}
def test_benchmark(self, vplanet_output, param, value, unit, param_options):
# The value returned by vplanet
output_value = recursive_getattr(vplanet_output, param)
# Are we comparing a specific index of an array?
index = param_options.pop("index", None)
if index is not None:
output_value = output_value[index]
# The expected value
benchmark_value = value * unit
# Check
> if np.allclose(output_value, benchmark_value, **param_options) == 0:
tests/benchmark.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<__array_function__ internals>:6: in allclose
???
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1525: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:544: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1356: in _to_own_unit
_value = value.to_value(self.unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:750: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:670: in _to_value
equivalencies=equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1134: in to
equivalencies=equivalencies)(value)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1064: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1050: in _get_converter
self, other, self._normalize_equivalencies(equivalencies))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), unit = Unit("1 / sec"), other = Unit(dimensionless)
equivalencies = []
def _apply_equivalencies(self, unit, other, equivalencies):
"""
Internal function (used from `_get_converter`) to apply
equivalence pairs.
"""
def make_converter(scale1, func, scale2):
def convert(v):
return func(_condition_arg(v) / scale1) * scale2
return convert
for funit, tunit, a, b in equivalencies:
if tunit is None:
try:
ratio_in_funit = (other.decompose() /
unit.decompose()).decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.)
except UnitsError:
pass
else:
try:
scale1 = funit._to(unit)
scale2 = tunit._to(other)
return make_converter(scale1, a, scale2)
except UnitsError:
pass
try:
scale1 = tunit._to(unit)
scale2 = funit._to(other)
return make_converter(scale1, b, scale2)
except UnitsError:
pass
def get_err_str(unit):
unit_str = unit.to_string('unscaled')
physical_type = unit.physical_type
if physical_type != 'unknown':
unit_str = f"'{unit_str}' ({physical_type})"
else:
unit_str = f"'{unit_str}'"
return unit_str
unit_str = get_err_str(unit)
other_str = get_err_str(other)
raise UnitConversionError(
> f"{unit_str} and {other_str} are not convertible")
E astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1026: UnitConversionError
github-actions / Test Results
test_benchmark[log.final.Venus.DYoblDtDistRot-1.425669e-13-unit521-param_options521] (tests.DistorbDistrot.SSDistOrbDistRot.test_SSDistOrbDistRot.Test_SSDistOrbDistRot) failed
junit/test-results.xml [took 0s]
Raw output
astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
self = <Quantity 1.425669e-13 1 / sec>, unit = Unit(dimensionless)
equivalencies = []
def to_value(self, unit=None, equivalencies=[]):
"""
The numerical value, possibly in a different unit.
Parameters
----------
unit : unit-like, optional
The unit in which the value should be given. If not given or `None`,
use the current unit.
equivalencies : list of tuple, optional
A list of equivalence pairs to try if the units are not directly
convertible (see :ref:`unit_equivalencies`). If not provided or
``[]``, class default equivalencies will be used (none for
`~astropy.units.Quantity`, but may be set for subclasses).
If `None`, no equivalencies will be applied at all, not even any
set globally or within a context.
Returns
-------
value : ndarray or scalar
The value in the units specified. For arrays, this will be a view
of the data if no unit conversion was necessary.
See also
--------
to : Get a new instance in a different unit.
"""
if unit is None or unit is self.unit:
value = self.view(np.ndarray)
else:
unit = Unit(unit)
# We want a view if the unit does not change. One could check
# with "==", but that calculates the scale that we need anyway.
# TODO: would be better for `unit.to` to have an in-place flag.
try:
> scale = self.unit._to(unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:747:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), other = Unit(dimensionless)
def _to(self, other):
"""
Returns the scale to the specified unit.
See `to`, except that a Unit object should be given (i.e., no
string), and that all defaults are used, i.e., no
equivalencies and value=1.
"""
# There are many cases where we just want to ensure a Quantity is
# of a particular unit, without checking whether it's already in
# a particular unit. If we're being asked to convert from a unit
# to itself, we can short-circuit all of this.
if self is other:
return 1.0
# Don't presume decomposition is possible; e.g.,
# conversion to function units is through equivalencies.
if isinstance(other, UnitBase):
self_decomposed = self.decompose()
other_decomposed = other.decompose()
# Check quickly whether equivalent. This is faster than
# `is_equivalent`, because it doesn't generate the entire
# physical type list of both units. In other words it "fails
# fast".
if(self_decomposed.powers == other_decomposed.powers and
all(self_base is other_base for (self_base, other_base)
in zip(self_decomposed.bases, other_decomposed.bases))):
return self_decomposed.scale / other_decomposed.scale
raise UnitConversionError(
> f"'{self!r}' is not a scaled version of '{other!r}'")
E astropy.units.core.UnitConversionError: 'Unit("1 / sec")' is not a scaled version of 'Unit(dimensionless)'
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1097: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_SSDistOrbDistRot.Test_SSDistOrbDistRot object at 0x7fa5b3b89e50>
vplanet_output = <vplanet.Output: solarsys>
param = 'log.final.Venus.DYoblDtDistRot', value = 1.425669e-13
unit = <Quantity 1. 1 / sec>, param_options = {}
def test_benchmark(self, vplanet_output, param, value, unit, param_options):
# The value returned by vplanet
output_value = recursive_getattr(vplanet_output, param)
# Are we comparing a specific index of an array?
index = param_options.pop("index", None)
if index is not None:
output_value = output_value[index]
# The expected value
benchmark_value = value * unit
# Check
> if np.allclose(output_value, benchmark_value, **param_options) == 0:
tests/benchmark.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<__array_function__ internals>:6: in allclose
???
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1525: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:544: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1356: in _to_own_unit
_value = value.to_value(self.unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:750: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:670: in _to_value
equivalencies=equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1134: in to
equivalencies=equivalencies)(value)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1064: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1050: in _get_converter
self, other, self._normalize_equivalencies(equivalencies))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), unit = Unit("1 / sec"), other = Unit(dimensionless)
equivalencies = []
def _apply_equivalencies(self, unit, other, equivalencies):
"""
Internal function (used from `_get_converter`) to apply
equivalence pairs.
"""
def make_converter(scale1, func, scale2):
def convert(v):
return func(_condition_arg(v) / scale1) * scale2
return convert
for funit, tunit, a, b in equivalencies:
if tunit is None:
try:
ratio_in_funit = (other.decompose() /
unit.decompose()).decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.)
except UnitsError:
pass
else:
try:
scale1 = funit._to(unit)
scale2 = tunit._to(other)
return make_converter(scale1, a, scale2)
except UnitsError:
pass
try:
scale1 = tunit._to(unit)
scale2 = funit._to(other)
return make_converter(scale1, b, scale2)
except UnitsError:
pass
def get_err_str(unit):
unit_str = unit.to_string('unscaled')
physical_type = unit.physical_type
if physical_type != 'unknown':
unit_str = f"'{unit_str}' ({physical_type})"
else:
unit_str = f"'{unit_str}'"
return unit_str
unit_str = get_err_str(unit)
other_str = get_err_str(other)
raise UnitConversionError(
> f"{unit_str} and {other_str} are not convertible")
E astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1026: UnitConversionError
github-actions / Test Results
test_benchmark[log.final.Earth.DYoblDtDistRot--2.366691e-12-unit584-param_options584] (tests.DistorbDistrot.SSDistOrbDistRot.test_SSDistOrbDistRot.Test_SSDistOrbDistRot) failed
junit/test-results.xml [took 0s]
Raw output
astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
self = <Quantity -2.366691e-12 1 / sec>, unit = Unit(dimensionless)
equivalencies = []
def to_value(self, unit=None, equivalencies=[]):
"""
The numerical value, possibly in a different unit.
Parameters
----------
unit : unit-like, optional
The unit in which the value should be given. If not given or `None`,
use the current unit.
equivalencies : list of tuple, optional
A list of equivalence pairs to try if the units are not directly
convertible (see :ref:`unit_equivalencies`). If not provided or
``[]``, class default equivalencies will be used (none for
`~astropy.units.Quantity`, but may be set for subclasses).
If `None`, no equivalencies will be applied at all, not even any
set globally or within a context.
Returns
-------
value : ndarray or scalar
The value in the units specified. For arrays, this will be a view
of the data if no unit conversion was necessary.
See also
--------
to : Get a new instance in a different unit.
"""
if unit is None or unit is self.unit:
value = self.view(np.ndarray)
else:
unit = Unit(unit)
# We want a view if the unit does not change. One could check
# with "==", but that calculates the scale that we need anyway.
# TODO: would be better for `unit.to` to have an in-place flag.
try:
> scale = self.unit._to(unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:747:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), other = Unit(dimensionless)
def _to(self, other):
"""
Returns the scale to the specified unit.
See `to`, except that a Unit object should be given (i.e., no
string), and that all defaults are used, i.e., no
equivalencies and value=1.
"""
# There are many cases where we just want to ensure a Quantity is
# of a particular unit, without checking whether it's already in
# a particular unit. If we're being asked to convert from a unit
# to itself, we can short-circuit all of this.
if self is other:
return 1.0
# Don't presume decomposition is possible; e.g.,
# conversion to function units is through equivalencies.
if isinstance(other, UnitBase):
self_decomposed = self.decompose()
other_decomposed = other.decompose()
# Check quickly whether equivalent. This is faster than
# `is_equivalent`, because it doesn't generate the entire
# physical type list of both units. In other words it "fails
# fast".
if(self_decomposed.powers == other_decomposed.powers and
all(self_base is other_base for (self_base, other_base)
in zip(self_decomposed.bases, other_decomposed.bases))):
return self_decomposed.scale / other_decomposed.scale
raise UnitConversionError(
> f"'{self!r}' is not a scaled version of '{other!r}'")
E astropy.units.core.UnitConversionError: 'Unit("1 / sec")' is not a scaled version of 'Unit(dimensionless)'
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1097: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_SSDistOrbDistRot.Test_SSDistOrbDistRot object at 0x7fa5b3bbae50>
vplanet_output = <vplanet.Output: solarsys>
param = 'log.final.Earth.DYoblDtDistRot', value = -2.366691e-12
unit = <Quantity 1. 1 / sec>, param_options = {}
def test_benchmark(self, vplanet_output, param, value, unit, param_options):
# The value returned by vplanet
output_value = recursive_getattr(vplanet_output, param)
# Are we comparing a specific index of an array?
index = param_options.pop("index", None)
if index is not None:
output_value = output_value[index]
# The expected value
benchmark_value = value * unit
# Check
> if np.allclose(output_value, benchmark_value, **param_options) == 0:
tests/benchmark.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<__array_function__ internals>:6: in allclose
???
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1525: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:544: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1356: in _to_own_unit
_value = value.to_value(self.unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:750: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:670: in _to_value
equivalencies=equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1134: in to
equivalencies=equivalencies)(value)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1064: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1050: in _get_converter
self, other, self._normalize_equivalencies(equivalencies))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), unit = Unit("1 / sec"), other = Unit(dimensionless)
equivalencies = []
def _apply_equivalencies(self, unit, other, equivalencies):
"""
Internal function (used from `_get_converter`) to apply
equivalence pairs.
"""
def make_converter(scale1, func, scale2):
def convert(v):
return func(_condition_arg(v) / scale1) * scale2
return convert
for funit, tunit, a, b in equivalencies:
if tunit is None:
try:
ratio_in_funit = (other.decompose() /
unit.decompose()).decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.)
except UnitsError:
pass
else:
try:
scale1 = funit._to(unit)
scale2 = tunit._to(other)
return make_converter(scale1, a, scale2)
except UnitsError:
pass
try:
scale1 = tunit._to(unit)
scale2 = funit._to(other)
return make_converter(scale1, b, scale2)
except UnitsError:
pass
def get_err_str(unit):
unit_str = unit.to_string('unscaled')
physical_type = unit.physical_type
if physical_type != 'unknown':
unit_str = f"'{unit_str}' ({physical_type})"
else:
unit_str = f"'{unit_str}'"
return unit_str
unit_str = get_err_str(unit)
other_str = get_err_str(other)
raise UnitConversionError(
> f"{unit_str} and {other_str} are not convertible")
E astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1026: UnitConversionError
github-actions / Test Results
test_benchmark[log.final.Mars.DYoblDtDistRot-5.14628e-13-unit647-param_options647] (tests.DistorbDistrot.SSDistOrbDistRot.test_SSDistOrbDistRot.Test_SSDistOrbDistRot) failed
junit/test-results.xml [took 0s]
Raw output
astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
self = <Quantity 5.14628e-13 1 / sec>, unit = Unit(dimensionless)
equivalencies = []
def to_value(self, unit=None, equivalencies=[]):
"""
The numerical value, possibly in a different unit.
Parameters
----------
unit : unit-like, optional
The unit in which the value should be given. If not given or `None`,
use the current unit.
equivalencies : list of tuple, optional
A list of equivalence pairs to try if the units are not directly
convertible (see :ref:`unit_equivalencies`). If not provided or
``[]``, class default equivalencies will be used (none for
`~astropy.units.Quantity`, but may be set for subclasses).
If `None`, no equivalencies will be applied at all, not even any
set globally or within a context.
Returns
-------
value : ndarray or scalar
The value in the units specified. For arrays, this will be a view
of the data if no unit conversion was necessary.
See also
--------
to : Get a new instance in a different unit.
"""
if unit is None or unit is self.unit:
value = self.view(np.ndarray)
else:
unit = Unit(unit)
# We want a view if the unit does not change. One could check
# with "==", but that calculates the scale that we need anyway.
# TODO: would be better for `unit.to` to have an in-place flag.
try:
> scale = self.unit._to(unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:747:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), other = Unit(dimensionless)
def _to(self, other):
"""
Returns the scale to the specified unit.
See `to`, except that a Unit object should be given (i.e., no
string), and that all defaults are used, i.e., no
equivalencies and value=1.
"""
# There are many cases where we just want to ensure a Quantity is
# of a particular unit, without checking whether it's already in
# a particular unit. If we're being asked to convert from a unit
# to itself, we can short-circuit all of this.
if self is other:
return 1.0
# Don't presume decomposition is possible; e.g.,
# conversion to function units is through equivalencies.
if isinstance(other, UnitBase):
self_decomposed = self.decompose()
other_decomposed = other.decompose()
# Check quickly whether equivalent. This is faster than
# `is_equivalent`, because it doesn't generate the entire
# physical type list of both units. In other words it "fails
# fast".
if(self_decomposed.powers == other_decomposed.powers and
all(self_base is other_base for (self_base, other_base)
in zip(self_decomposed.bases, other_decomposed.bases))):
return self_decomposed.scale / other_decomposed.scale
raise UnitConversionError(
> f"'{self!r}' is not a scaled version of '{other!r}'")
E astropy.units.core.UnitConversionError: 'Unit("1 / sec")' is not a scaled version of 'Unit(dimensionless)'
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1097: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_SSDistOrbDistRot.Test_SSDistOrbDistRot object at 0x7fa5b3b68e50>
vplanet_output = <vplanet.Output: solarsys>
param = 'log.final.Mars.DYoblDtDistRot', value = 5.14628e-13
unit = <Quantity 1. 1 / sec>, param_options = {}
def test_benchmark(self, vplanet_output, param, value, unit, param_options):
# The value returned by vplanet
output_value = recursive_getattr(vplanet_output, param)
# Are we comparing a specific index of an array?
index = param_options.pop("index", None)
if index is not None:
output_value = output_value[index]
# The expected value
benchmark_value = value * unit
# Check
> if np.allclose(output_value, benchmark_value, **param_options) == 0:
tests/benchmark.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<__array_function__ internals>:6: in allclose
???
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1525: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:544: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1356: in _to_own_unit
_value = value.to_value(self.unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:750: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:670: in _to_value
equivalencies=equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1134: in to
equivalencies=equivalencies)(value)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1064: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1050: in _get_converter
self, other, self._normalize_equivalencies(equivalencies))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), unit = Unit("1 / sec"), other = Unit(dimensionless)
equivalencies = []
def _apply_equivalencies(self, unit, other, equivalencies):
"""
Internal function (used from `_get_converter`) to apply
equivalence pairs.
"""
def make_converter(scale1, func, scale2):
def convert(v):
return func(_condition_arg(v) / scale1) * scale2
return convert
for funit, tunit, a, b in equivalencies:
if tunit is None:
try:
ratio_in_funit = (other.decompose() /
unit.decompose()).decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.)
except UnitsError:
pass
else:
try:
scale1 = funit._to(unit)
scale2 = tunit._to(other)
return make_converter(scale1, a, scale2)
except UnitsError:
pass
try:
scale1 = tunit._to(unit)
scale2 = funit._to(other)
return make_converter(scale1, b, scale2)
except UnitsError:
pass
def get_err_str(unit):
unit_str = unit.to_string('unscaled')
physical_type = unit.physical_type
if physical_type != 'unknown':
unit_str = f"'{unit_str}' ({physical_type})"
else:
unit_str = f"'{unit_str}'"
return unit_str
unit_str = get_err_str(unit)
other_str = get_err_str(other)
raise UnitConversionError(
> f"{unit_str} and {other_str} are not convertible")
E astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1026: UnitConversionError
Check warning on line 0 in tests.DistorbDistrotEqtide.CTL_LL2.test_CTL_LL2.Test_CTL_LL2
github-actions / Test Results
test_benchmark[log.initial.TGb.DYoblDtDistRot-9.926721e-09-unit171-param_options171] (tests.DistorbDistrotEqtide.CTL_LL2.test_CTL_LL2.Test_CTL_LL2) failed
junit/test-results.xml [took 0s]
Raw output
astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
self = <Quantity 9.926721e-09 1 / sec>, unit = Unit(dimensionless)
equivalencies = []
def to_value(self, unit=None, equivalencies=[]):
"""
The numerical value, possibly in a different unit.
Parameters
----------
unit : unit-like, optional
The unit in which the value should be given. If not given or `None`,
use the current unit.
equivalencies : list of tuple, optional
A list of equivalence pairs to try if the units are not directly
convertible (see :ref:`unit_equivalencies`). If not provided or
``[]``, class default equivalencies will be used (none for
`~astropy.units.Quantity`, but may be set for subclasses).
If `None`, no equivalencies will be applied at all, not even any
set globally or within a context.
Returns
-------
value : ndarray or scalar
The value in the units specified. For arrays, this will be a view
of the data if no unit conversion was necessary.
See also
--------
to : Get a new instance in a different unit.
"""
if unit is None or unit is self.unit:
value = self.view(np.ndarray)
else:
unit = Unit(unit)
# We want a view if the unit does not change. One could check
# with "==", but that calculates the scale that we need anyway.
# TODO: would be better for `unit.to` to have an in-place flag.
try:
> scale = self.unit._to(unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:747:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), other = Unit(dimensionless)
def _to(self, other):
"""
Returns the scale to the specified unit.
See `to`, except that a Unit object should be given (i.e., no
string), and that all defaults are used, i.e., no
equivalencies and value=1.
"""
# There are many cases where we just want to ensure a Quantity is
# of a particular unit, without checking whether it's already in
# a particular unit. If we're being asked to convert from a unit
# to itself, we can short-circuit all of this.
if self is other:
return 1.0
# Don't presume decomposition is possible; e.g.,
# conversion to function units is through equivalencies.
if isinstance(other, UnitBase):
self_decomposed = self.decompose()
other_decomposed = other.decompose()
# Check quickly whether equivalent. This is faster than
# `is_equivalent`, because it doesn't generate the entire
# physical type list of both units. In other words it "fails
# fast".
if(self_decomposed.powers == other_decomposed.powers and
all(self_base is other_base for (self_base, other_base)
in zip(self_decomposed.bases, other_decomposed.bases))):
return self_decomposed.scale / other_decomposed.scale
raise UnitConversionError(
> f"'{self!r}' is not a scaled version of '{other!r}'")
E astropy.units.core.UnitConversionError: 'Unit("1 / sec")' is not a scaled version of 'Unit(dimensionless)'
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1097: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_CTL_LL2.Test_CTL_LL2 object at 0x7fa5b3937790>
vplanet_output = <vplanet.Output: TGard>
param = 'log.initial.TGb.DYoblDtDistRot', value = 9.926721e-09
unit = <Quantity 1. 1 / sec>, param_options = {}
def test_benchmark(self, vplanet_output, param, value, unit, param_options):
# The value returned by vplanet
output_value = recursive_getattr(vplanet_output, param)
# Are we comparing a specific index of an array?
index = param_options.pop("index", None)
if index is not None:
output_value = output_value[index]
# The expected value
benchmark_value = value * unit
# Check
> if np.allclose(output_value, benchmark_value, **param_options) == 0:
tests/benchmark.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<__array_function__ internals>:6: in allclose
???
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1525: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:544: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1356: in _to_own_unit
_value = value.to_value(self.unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:750: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:670: in _to_value
equivalencies=equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1134: in to
equivalencies=equivalencies)(value)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1064: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1050: in _get_converter
self, other, self._normalize_equivalencies(equivalencies))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), unit = Unit("1 / sec"), other = Unit(dimensionless)
equivalencies = []
def _apply_equivalencies(self, unit, other, equivalencies):
"""
Internal function (used from `_get_converter`) to apply
equivalence pairs.
"""
def make_converter(scale1, func, scale2):
def convert(v):
return func(_condition_arg(v) / scale1) * scale2
return convert
for funit, tunit, a, b in equivalencies:
if tunit is None:
try:
ratio_in_funit = (other.decompose() /
unit.decompose()).decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.)
except UnitsError:
pass
else:
try:
scale1 = funit._to(unit)
scale2 = tunit._to(other)
return make_converter(scale1, a, scale2)
except UnitsError:
pass
try:
scale1 = tunit._to(unit)
scale2 = funit._to(other)
return make_converter(scale1, b, scale2)
except UnitsError:
pass
def get_err_str(unit):
unit_str = unit.to_string('unscaled')
physical_type = unit.physical_type
if physical_type != 'unknown':
unit_str = f"'{unit_str}' ({physical_type})"
else:
unit_str = f"'{unit_str}'"
return unit_str
unit_str = get_err_str(unit)
other_str = get_err_str(other)
raise UnitConversionError(
> f"{unit_str} and {other_str} are not convertible")
E astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1026: UnitConversionError
Check warning on line 0 in tests.DistorbDistrotEqtide.CTL_LL2.test_CTL_LL2.Test_CTL_LL2
github-actions / Test Results
test_benchmark[log.initial.TGc.DYoblDtDistRot-7.380027e-12-unit278-param_options278] (tests.DistorbDistrotEqtide.CTL_LL2.test_CTL_LL2.Test_CTL_LL2) failed
junit/test-results.xml [took 0s]
Raw output
astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
self = <Quantity 7.380027e-12 1 / sec>, unit = Unit(dimensionless)
equivalencies = []
def to_value(self, unit=None, equivalencies=[]):
"""
The numerical value, possibly in a different unit.
Parameters
----------
unit : unit-like, optional
The unit in which the value should be given. If not given or `None`,
use the current unit.
equivalencies : list of tuple, optional
A list of equivalence pairs to try if the units are not directly
convertible (see :ref:`unit_equivalencies`). If not provided or
``[]``, class default equivalencies will be used (none for
`~astropy.units.Quantity`, but may be set for subclasses).
If `None`, no equivalencies will be applied at all, not even any
set globally or within a context.
Returns
-------
value : ndarray or scalar
The value in the units specified. For arrays, this will be a view
of the data if no unit conversion was necessary.
See also
--------
to : Get a new instance in a different unit.
"""
if unit is None or unit is self.unit:
value = self.view(np.ndarray)
else:
unit = Unit(unit)
# We want a view if the unit does not change. One could check
# with "==", but that calculates the scale that we need anyway.
# TODO: would be better for `unit.to` to have an in-place flag.
try:
> scale = self.unit._to(unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:747:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), other = Unit(dimensionless)
def _to(self, other):
"""
Returns the scale to the specified unit.
See `to`, except that a Unit object should be given (i.e., no
string), and that all defaults are used, i.e., no
equivalencies and value=1.
"""
# There are many cases where we just want to ensure a Quantity is
# of a particular unit, without checking whether it's already in
# a particular unit. If we're being asked to convert from a unit
# to itself, we can short-circuit all of this.
if self is other:
return 1.0
# Don't presume decomposition is possible; e.g.,
# conversion to function units is through equivalencies.
if isinstance(other, UnitBase):
self_decomposed = self.decompose()
other_decomposed = other.decompose()
# Check quickly whether equivalent. This is faster than
# `is_equivalent`, because it doesn't generate the entire
# physical type list of both units. In other words it "fails
# fast".
if(self_decomposed.powers == other_decomposed.powers and
all(self_base is other_base for (self_base, other_base)
in zip(self_decomposed.bases, other_decomposed.bases))):
return self_decomposed.scale / other_decomposed.scale
raise UnitConversionError(
> f"'{self!r}' is not a scaled version of '{other!r}'")
E astropy.units.core.UnitConversionError: 'Unit("1 / sec")' is not a scaled version of 'Unit(dimensionless)'
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1097: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_CTL_LL2.Test_CTL_LL2 object at 0x7fa5b3888910>
vplanet_output = <vplanet.Output: TGard>
param = 'log.initial.TGc.DYoblDtDistRot', value = 7.380027e-12
unit = <Quantity 1. 1 / sec>, param_options = {}
def test_benchmark(self, vplanet_output, param, value, unit, param_options):
# The value returned by vplanet
output_value = recursive_getattr(vplanet_output, param)
# Are we comparing a specific index of an array?
index = param_options.pop("index", None)
if index is not None:
output_value = output_value[index]
# The expected value
benchmark_value = value * unit
# Check
> if np.allclose(output_value, benchmark_value, **param_options) == 0:
tests/benchmark.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<__array_function__ internals>:6: in allclose
???
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1525: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:544: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1356: in _to_own_unit
_value = value.to_value(self.unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:750: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:670: in _to_value
equivalencies=equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1134: in to
equivalencies=equivalencies)(value)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1064: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1050: in _get_converter
self, other, self._normalize_equivalencies(equivalencies))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), unit = Unit("1 / sec"), other = Unit(dimensionless)
equivalencies = []
def _apply_equivalencies(self, unit, other, equivalencies):
"""
Internal function (used from `_get_converter`) to apply
equivalence pairs.
"""
def make_converter(scale1, func, scale2):
def convert(v):
return func(_condition_arg(v) / scale1) * scale2
return convert
for funit, tunit, a, b in equivalencies:
if tunit is None:
try:
ratio_in_funit = (other.decompose() /
unit.decompose()).decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.)
except UnitsError:
pass
else:
try:
scale1 = funit._to(unit)
scale2 = tunit._to(other)
return make_converter(scale1, a, scale2)
except UnitsError:
pass
try:
scale1 = tunit._to(unit)
scale2 = funit._to(other)
return make_converter(scale1, b, scale2)
except UnitsError:
pass
def get_err_str(unit):
unit_str = unit.to_string('unscaled')
physical_type = unit.physical_type
if physical_type != 'unknown':
unit_str = f"'{unit_str}' ({physical_type})"
else:
unit_str = f"'{unit_str}'"
return unit_str
unit_str = get_err_str(unit)
other_str = get_err_str(other)
raise UnitConversionError(
> f"{unit_str} and {other_str} are not convertible")
E astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1026: UnitConversionError
Check warning on line 0 in tests.DistorbDistrotEqtide.CTL_LL2.test_CTL_LL2.Test_CTL_LL2
github-actions / Test Results
test_benchmark[log.final.TGb.DYoblDtDistRot--8.70902e-09-unit455-param_options455] (tests.DistorbDistrotEqtide.CTL_LL2.test_CTL_LL2.Test_CTL_LL2) failed
junit/test-results.xml [took 0s]
Raw output
astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
self = <Quantity -8.70902e-09 1 / sec>, unit = Unit(dimensionless)
equivalencies = []
def to_value(self, unit=None, equivalencies=[]):
"""
The numerical value, possibly in a different unit.
Parameters
----------
unit : unit-like, optional
The unit in which the value should be given. If not given or `None`,
use the current unit.
equivalencies : list of tuple, optional
A list of equivalence pairs to try if the units are not directly
convertible (see :ref:`unit_equivalencies`). If not provided or
``[]``, class default equivalencies will be used (none for
`~astropy.units.Quantity`, but may be set for subclasses).
If `None`, no equivalencies will be applied at all, not even any
set globally or within a context.
Returns
-------
value : ndarray or scalar
The value in the units specified. For arrays, this will be a view
of the data if no unit conversion was necessary.
See also
--------
to : Get a new instance in a different unit.
"""
if unit is None or unit is self.unit:
value = self.view(np.ndarray)
else:
unit = Unit(unit)
# We want a view if the unit does not change. One could check
# with "==", but that calculates the scale that we need anyway.
# TODO: would be better for `unit.to` to have an in-place flag.
try:
> scale = self.unit._to(unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:747:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), other = Unit(dimensionless)
def _to(self, other):
"""
Returns the scale to the specified unit.
See `to`, except that a Unit object should be given (i.e., no
string), and that all defaults are used, i.e., no
equivalencies and value=1.
"""
# There are many cases where we just want to ensure a Quantity is
# of a particular unit, without checking whether it's already in
# a particular unit. If we're being asked to convert from a unit
# to itself, we can short-circuit all of this.
if self is other:
return 1.0
# Don't presume decomposition is possible; e.g.,
# conversion to function units is through equivalencies.
if isinstance(other, UnitBase):
self_decomposed = self.decompose()
other_decomposed = other.decompose()
# Check quickly whether equivalent. This is faster than
# `is_equivalent`, because it doesn't generate the entire
# physical type list of both units. In other words it "fails
# fast".
if(self_decomposed.powers == other_decomposed.powers and
all(self_base is other_base for (self_base, other_base)
in zip(self_decomposed.bases, other_decomposed.bases))):
return self_decomposed.scale / other_decomposed.scale
raise UnitConversionError(
> f"'{self!r}' is not a scaled version of '{other!r}'")
E astropy.units.core.UnitConversionError: 'Unit("1 / sec")' is not a scaled version of 'Unit(dimensionless)'
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1097: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_CTL_LL2.Test_CTL_LL2 object at 0x7fa5b3808fd0>
vplanet_output = <vplanet.Output: TGard>, param = 'log.final.TGb.DYoblDtDistRot'
value = -8.70902e-09, unit = <Quantity 1. 1 / sec>, param_options = {}
def test_benchmark(self, vplanet_output, param, value, unit, param_options):
# The value returned by vplanet
output_value = recursive_getattr(vplanet_output, param)
# Are we comparing a specific index of an array?
index = param_options.pop("index", None)
if index is not None:
output_value = output_value[index]
# The expected value
benchmark_value = value * unit
# Check
> if np.allclose(output_value, benchmark_value, **param_options) == 0:
tests/benchmark.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<__array_function__ internals>:6: in allclose
???
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1525: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:544: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1356: in _to_own_unit
_value = value.to_value(self.unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:750: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:670: in _to_value
equivalencies=equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1134: in to
equivalencies=equivalencies)(value)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1064: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1050: in _get_converter
self, other, self._normalize_equivalencies(equivalencies))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), unit = Unit("1 / sec"), other = Unit(dimensionless)
equivalencies = []
def _apply_equivalencies(self, unit, other, equivalencies):
"""
Internal function (used from `_get_converter`) to apply
equivalence pairs.
"""
def make_converter(scale1, func, scale2):
def convert(v):
return func(_condition_arg(v) / scale1) * scale2
return convert
for funit, tunit, a, b in equivalencies:
if tunit is None:
try:
ratio_in_funit = (other.decompose() /
unit.decompose()).decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.)
except UnitsError:
pass
else:
try:
scale1 = funit._to(unit)
scale2 = tunit._to(other)
return make_converter(scale1, a, scale2)
except UnitsError:
pass
try:
scale1 = tunit._to(unit)
scale2 = funit._to(other)
return make_converter(scale1, b, scale2)
except UnitsError:
pass
def get_err_str(unit):
unit_str = unit.to_string('unscaled')
physical_type = unit.physical_type
if physical_type != 'unknown':
unit_str = f"'{unit_str}' ({physical_type})"
else:
unit_str = f"'{unit_str}'"
return unit_str
unit_str = get_err_str(unit)
other_str = get_err_str(other)
raise UnitConversionError(
> f"{unit_str} and {other_str} are not convertible")
E astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1026: UnitConversionError
Check warning on line 0 in tests.DistorbDistrotEqtide.CTL_LL2.test_CTL_LL2.Test_CTL_LL2
github-actions / Test Results
test_benchmark[log.final.TGc.DYoblDtDistRot--6.748655e-12-unit562-param_options562] (tests.DistorbDistrotEqtide.CTL_LL2.test_CTL_LL2.Test_CTL_LL2) failed
junit/test-results.xml [took 0s]
Raw output
astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
self = <Quantity -6.748655e-12 1 / sec>, unit = Unit(dimensionless)
equivalencies = []
def to_value(self, unit=None, equivalencies=[]):
"""
The numerical value, possibly in a different unit.
Parameters
----------
unit : unit-like, optional
The unit in which the value should be given. If not given or `None`,
use the current unit.
equivalencies : list of tuple, optional
A list of equivalence pairs to try if the units are not directly
convertible (see :ref:`unit_equivalencies`). If not provided or
``[]``, class default equivalencies will be used (none for
`~astropy.units.Quantity`, but may be set for subclasses).
If `None`, no equivalencies will be applied at all, not even any
set globally or within a context.
Returns
-------
value : ndarray or scalar
The value in the units specified. For arrays, this will be a view
of the data if no unit conversion was necessary.
See also
--------
to : Get a new instance in a different unit.
"""
if unit is None or unit is self.unit:
value = self.view(np.ndarray)
else:
unit = Unit(unit)
# We want a view if the unit does not change. One could check
# with "==", but that calculates the scale that we need anyway.
# TODO: would be better for `unit.to` to have an in-place flag.
try:
> scale = self.unit._to(unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:747:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), other = Unit(dimensionless)
def _to(self, other):
"""
Returns the scale to the specified unit.
See `to`, except that a Unit object should be given (i.e., no
string), and that all defaults are used, i.e., no
equivalencies and value=1.
"""
# There are many cases where we just want to ensure a Quantity is
# of a particular unit, without checking whether it's already in
# a particular unit. If we're being asked to convert from a unit
# to itself, we can short-circuit all of this.
if self is other:
return 1.0
# Don't presume decomposition is possible; e.g.,
# conversion to function units is through equivalencies.
if isinstance(other, UnitBase):
self_decomposed = self.decompose()
other_decomposed = other.decompose()
# Check quickly whether equivalent. This is faster than
# `is_equivalent`, because it doesn't generate the entire
# physical type list of both units. In other words it "fails
# fast".
if(self_decomposed.powers == other_decomposed.powers and
all(self_base is other_base for (self_base, other_base)
in zip(self_decomposed.bases, other_decomposed.bases))):
return self_decomposed.scale / other_decomposed.scale
raise UnitConversionError(
> f"'{self!r}' is not a scaled version of '{other!r}'")
E astropy.units.core.UnitConversionError: 'Unit("1 / sec")' is not a scaled version of 'Unit(dimensionless)'
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1097: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_CTL_LL2.Test_CTL_LL2 object at 0x7fa5b37aa190>
vplanet_output = <vplanet.Output: TGard>, param = 'log.final.TGc.DYoblDtDistRot'
value = -6.748655e-12, unit = <Quantity 1. 1 / sec>, param_options = {}
def test_benchmark(self, vplanet_output, param, value, unit, param_options):
# The value returned by vplanet
output_value = recursive_getattr(vplanet_output, param)
# Are we comparing a specific index of an array?
index = param_options.pop("index", None)
if index is not None:
output_value = output_value[index]
# The expected value
benchmark_value = value * unit
# Check
> if np.allclose(output_value, benchmark_value, **param_options) == 0:
tests/benchmark.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<__array_function__ internals>:6: in allclose
???
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1525: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:544: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1356: in _to_own_unit
_value = value.to_value(self.unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:750: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:670: in _to_value
equivalencies=equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1134: in to
equivalencies=equivalencies)(value)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1064: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1050: in _get_converter
self, other, self._normalize_equivalencies(equivalencies))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), unit = Unit("1 / sec"), other = Unit(dimensionless)
equivalencies = []
def _apply_equivalencies(self, unit, other, equivalencies):
"""
Internal function (used from `_get_converter`) to apply
equivalence pairs.
"""
def make_converter(scale1, func, scale2):
def convert(v):
return func(_condition_arg(v) / scale1) * scale2
return convert
for funit, tunit, a, b in equivalencies:
if tunit is None:
try:
ratio_in_funit = (other.decompose() /
unit.decompose()).decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.)
except UnitsError:
pass
else:
try:
scale1 = funit._to(unit)
scale2 = tunit._to(other)
return make_converter(scale1, a, scale2)
except UnitsError:
pass
try:
scale1 = tunit._to(unit)
scale2 = funit._to(other)
return make_converter(scale1, b, scale2)
except UnitsError:
pass
def get_err_str(unit):
unit_str = unit.to_string('unscaled')
physical_type = unit.physical_type
if physical_type != 'unknown':
unit_str = f"'{unit_str}' ({physical_type})"
else:
unit_str = f"'{unit_str}'"
return unit_str
unit_str = get_err_str(unit)
other_str = get_err_str(other)
raise UnitConversionError(
> f"{unit_str} and {other_str} are not convertible")
E astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1026: UnitConversionError
Check warning on line 0 in tests.DistorbDistrotEqtide.CTL_RD4.test_CTL_RD4.Test_CTL_RD4
github-actions / Test Results
test_benchmark[log.initial.TGb.DYoblDtDistRot-9.980137e-09-unit171-param_options171] (tests.DistorbDistrotEqtide.CTL_RD4.test_CTL_RD4.Test_CTL_RD4) failed
junit/test-results.xml [took 0s]
Raw output
astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
self = <Quantity 9.980137e-09 1 / sec>, unit = Unit(dimensionless)
equivalencies = []
def to_value(self, unit=None, equivalencies=[]):
"""
The numerical value, possibly in a different unit.
Parameters
----------
unit : unit-like, optional
The unit in which the value should be given. If not given or `None`,
use the current unit.
equivalencies : list of tuple, optional
A list of equivalence pairs to try if the units are not directly
convertible (see :ref:`unit_equivalencies`). If not provided or
``[]``, class default equivalencies will be used (none for
`~astropy.units.Quantity`, but may be set for subclasses).
If `None`, no equivalencies will be applied at all, not even any
set globally or within a context.
Returns
-------
value : ndarray or scalar
The value in the units specified. For arrays, this will be a view
of the data if no unit conversion was necessary.
See also
--------
to : Get a new instance in a different unit.
"""
if unit is None or unit is self.unit:
value = self.view(np.ndarray)
else:
unit = Unit(unit)
# We want a view if the unit does not change. One could check
# with "==", but that calculates the scale that we need anyway.
# TODO: would be better for `unit.to` to have an in-place flag.
try:
> scale = self.unit._to(unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:747:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), other = Unit(dimensionless)
def _to(self, other):
"""
Returns the scale to the specified unit.
See `to`, except that a Unit object should be given (i.e., no
string), and that all defaults are used, i.e., no
equivalencies and value=1.
"""
# There are many cases where we just want to ensure a Quantity is
# of a particular unit, without checking whether it's already in
# a particular unit. If we're being asked to convert from a unit
# to itself, we can short-circuit all of this.
if self is other:
return 1.0
# Don't presume decomposition is possible; e.g.,
# conversion to function units is through equivalencies.
if isinstance(other, UnitBase):
self_decomposed = self.decompose()
other_decomposed = other.decompose()
# Check quickly whether equivalent. This is faster than
# `is_equivalent`, because it doesn't generate the entire
# physical type list of both units. In other words it "fails
# fast".
if(self_decomposed.powers == other_decomposed.powers and
all(self_base is other_base for (self_base, other_base)
in zip(self_decomposed.bases, other_decomposed.bases))):
return self_decomposed.scale / other_decomposed.scale
raise UnitConversionError(
> f"'{self!r}' is not a scaled version of '{other!r}'")
E astropy.units.core.UnitConversionError: 'Unit("1 / sec")' is not a scaled version of 'Unit(dimensionless)'
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1097: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_CTL_RD4.Test_CTL_RD4 object at 0x7fa5b35f5110>
vplanet_output = <vplanet.Output: TGard>
param = 'log.initial.TGb.DYoblDtDistRot', value = 9.980137e-09
unit = <Quantity 1. 1 / sec>, param_options = {}
def test_benchmark(self, vplanet_output, param, value, unit, param_options):
# The value returned by vplanet
output_value = recursive_getattr(vplanet_output, param)
# Are we comparing a specific index of an array?
index = param_options.pop("index", None)
if index is not None:
output_value = output_value[index]
# The expected value
benchmark_value = value * unit
# Check
> if np.allclose(output_value, benchmark_value, **param_options) == 0:
tests/benchmark.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<__array_function__ internals>:6: in allclose
???
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1525: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:544: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1356: in _to_own_unit
_value = value.to_value(self.unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:750: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:670: in _to_value
equivalencies=equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1134: in to
equivalencies=equivalencies)(value)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1064: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1050: in _get_converter
self, other, self._normalize_equivalencies(equivalencies))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), unit = Unit("1 / sec"), other = Unit(dimensionless)
equivalencies = []
def _apply_equivalencies(self, unit, other, equivalencies):
"""
Internal function (used from `_get_converter`) to apply
equivalence pairs.
"""
def make_converter(scale1, func, scale2):
def convert(v):
return func(_condition_arg(v) / scale1) * scale2
return convert
for funit, tunit, a, b in equivalencies:
if tunit is None:
try:
ratio_in_funit = (other.decompose() /
unit.decompose()).decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.)
except UnitsError:
pass
else:
try:
scale1 = funit._to(unit)
scale2 = tunit._to(other)
return make_converter(scale1, a, scale2)
except UnitsError:
pass
try:
scale1 = tunit._to(unit)
scale2 = funit._to(other)
return make_converter(scale1, b, scale2)
except UnitsError:
pass
def get_err_str(unit):
unit_str = unit.to_string('unscaled')
physical_type = unit.physical_type
if physical_type != 'unknown':
unit_str = f"'{unit_str}' ({physical_type})"
else:
unit_str = f"'{unit_str}'"
return unit_str
unit_str = get_err_str(unit)
other_str = get_err_str(other)
raise UnitConversionError(
> f"{unit_str} and {other_str} are not convertible")
E astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1026: UnitConversionError
Check warning on line 0 in tests.DistorbDistrotEqtide.CTL_RD4.test_CTL_RD4.Test_CTL_RD4
github-actions / Test Results
test_benchmark[log.initial.TGc.DYoblDtDistRot--3.532139e-11-unit278-param_options278] (tests.DistorbDistrotEqtide.CTL_RD4.test_CTL_RD4.Test_CTL_RD4) failed
junit/test-results.xml [took 0s]
Raw output
astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
self = <Quantity -3.532139e-11 1 / sec>, unit = Unit(dimensionless)
equivalencies = []
def to_value(self, unit=None, equivalencies=[]):
"""
The numerical value, possibly in a different unit.
Parameters
----------
unit : unit-like, optional
The unit in which the value should be given. If not given or `None`,
use the current unit.
equivalencies : list of tuple, optional
A list of equivalence pairs to try if the units are not directly
convertible (see :ref:`unit_equivalencies`). If not provided or
``[]``, class default equivalencies will be used (none for
`~astropy.units.Quantity`, but may be set for subclasses).
If `None`, no equivalencies will be applied at all, not even any
set globally or within a context.
Returns
-------
value : ndarray or scalar
The value in the units specified. For arrays, this will be a view
of the data if no unit conversion was necessary.
See also
--------
to : Get a new instance in a different unit.
"""
if unit is None or unit is self.unit:
value = self.view(np.ndarray)
else:
unit = Unit(unit)
# We want a view if the unit does not change. One could check
# with "==", but that calculates the scale that we need anyway.
# TODO: would be better for `unit.to` to have an in-place flag.
try:
> scale = self.unit._to(unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:747:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), other = Unit(dimensionless)
def _to(self, other):
"""
Returns the scale to the specified unit.
See `to`, except that a Unit object should be given (i.e., no
string), and that all defaults are used, i.e., no
equivalencies and value=1.
"""
# There are many cases where we just want to ensure a Quantity is
# of a particular unit, without checking whether it's already in
# a particular unit. If we're being asked to convert from a unit
# to itself, we can short-circuit all of this.
if self is other:
return 1.0
# Don't presume decomposition is possible; e.g.,
# conversion to function units is through equivalencies.
if isinstance(other, UnitBase):
self_decomposed = self.decompose()
other_decomposed = other.decompose()
# Check quickly whether equivalent. This is faster than
# `is_equivalent`, because it doesn't generate the entire
# physical type list of both units. In other words it "fails
# fast".
if(self_decomposed.powers == other_decomposed.powers and
all(self_base is other_base for (self_base, other_base)
in zip(self_decomposed.bases, other_decomposed.bases))):
return self_decomposed.scale / other_decomposed.scale
raise UnitConversionError(
> f"'{self!r}' is not a scaled version of '{other!r}'")
E astropy.units.core.UnitConversionError: 'Unit("1 / sec")' is not a scaled version of 'Unit(dimensionless)'
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1097: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_CTL_RD4.Test_CTL_RD4 object at 0x7fa5b35c6290>
vplanet_output = <vplanet.Output: TGard>
param = 'log.initial.TGc.DYoblDtDistRot', value = -3.532139e-11
unit = <Quantity 1. 1 / sec>, param_options = {}
def test_benchmark(self, vplanet_output, param, value, unit, param_options):
# The value returned by vplanet
output_value = recursive_getattr(vplanet_output, param)
# Are we comparing a specific index of an array?
index = param_options.pop("index", None)
if index is not None:
output_value = output_value[index]
# The expected value
benchmark_value = value * unit
# Check
> if np.allclose(output_value, benchmark_value, **param_options) == 0:
tests/benchmark.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<__array_function__ internals>:6: in allclose
???
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1525: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:544: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1356: in _to_own_unit
_value = value.to_value(self.unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:750: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:670: in _to_value
equivalencies=equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1134: in to
equivalencies=equivalencies)(value)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1064: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1050: in _get_converter
self, other, self._normalize_equivalencies(equivalencies))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), unit = Unit("1 / sec"), other = Unit(dimensionless)
equivalencies = []
def _apply_equivalencies(self, unit, other, equivalencies):
"""
Internal function (used from `_get_converter`) to apply
equivalence pairs.
"""
def make_converter(scale1, func, scale2):
def convert(v):
return func(_condition_arg(v) / scale1) * scale2
return convert
for funit, tunit, a, b in equivalencies:
if tunit is None:
try:
ratio_in_funit = (other.decompose() /
unit.decompose()).decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.)
except UnitsError:
pass
else:
try:
scale1 = funit._to(unit)
scale2 = tunit._to(other)
return make_converter(scale1, a, scale2)
except UnitsError:
pass
try:
scale1 = tunit._to(unit)
scale2 = funit._to(other)
return make_converter(scale1, b, scale2)
except UnitsError:
pass
def get_err_str(unit):
unit_str = unit.to_string('unscaled')
physical_type = unit.physical_type
if physical_type != 'unknown':
unit_str = f"'{unit_str}' ({physical_type})"
else:
unit_str = f"'{unit_str}'"
return unit_str
unit_str = get_err_str(unit)
other_str = get_err_str(other)
raise UnitConversionError(
> f"{unit_str} and {other_str} are not convertible")
E astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1026: UnitConversionError
Check warning on line 0 in tests.DistorbDistrotEqtide.CTL_RD4.test_CTL_RD4.Test_CTL_RD4
github-actions / Test Results
test_benchmark[log.final.TGb.DYoblDtDistRot--8.899329e-09-unit455-param_options455] (tests.DistorbDistrotEqtide.CTL_RD4.test_CTL_RD4.Test_CTL_RD4) failed
junit/test-results.xml [took 0s]
Raw output
astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
self = <Quantity -8.899329e-09 1 / sec>, unit = Unit(dimensionless)
equivalencies = []
def to_value(self, unit=None, equivalencies=[]):
"""
The numerical value, possibly in a different unit.
Parameters
----------
unit : unit-like, optional
The unit in which the value should be given. If not given or `None`,
use the current unit.
equivalencies : list of tuple, optional
A list of equivalence pairs to try if the units are not directly
convertible (see :ref:`unit_equivalencies`). If not provided or
``[]``, class default equivalencies will be used (none for
`~astropy.units.Quantity`, but may be set for subclasses).
If `None`, no equivalencies will be applied at all, not even any
set globally or within a context.
Returns
-------
value : ndarray or scalar
The value in the units specified. For arrays, this will be a view
of the data if no unit conversion was necessary.
See also
--------
to : Get a new instance in a different unit.
"""
if unit is None or unit is self.unit:
value = self.view(np.ndarray)
else:
unit = Unit(unit)
# We want a view if the unit does not change. One could check
# with "==", but that calculates the scale that we need anyway.
# TODO: would be better for `unit.to` to have an in-place flag.
try:
> scale = self.unit._to(unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:747:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), other = Unit(dimensionless)
def _to(self, other):
"""
Returns the scale to the specified unit.
See `to`, except that a Unit object should be given (i.e., no
string), and that all defaults are used, i.e., no
equivalencies and value=1.
"""
# There are many cases where we just want to ensure a Quantity is
# of a particular unit, without checking whether it's already in
# a particular unit. If we're being asked to convert from a unit
# to itself, we can short-circuit all of this.
if self is other:
return 1.0
# Don't presume decomposition is possible; e.g.,
# conversion to function units is through equivalencies.
if isinstance(other, UnitBase):
self_decomposed = self.decompose()
other_decomposed = other.decompose()
# Check quickly whether equivalent. This is faster than
# `is_equivalent`, because it doesn't generate the entire
# physical type list of both units. In other words it "fails
# fast".
if(self_decomposed.powers == other_decomposed.powers and
all(self_base is other_base for (self_base, other_base)
in zip(self_decomposed.bases, other_decomposed.bases))):
return self_decomposed.scale / other_decomposed.scale
raise UnitConversionError(
> f"'{self!r}' is not a scaled version of '{other!r}'")
E astropy.units.core.UnitConversionError: 'Unit("1 / sec")' is not a scaled version of 'Unit(dimensionless)'
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1097: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_CTL_RD4.Test_CTL_RD4 object at 0x7fa5b34c7950>
vplanet_output = <vplanet.Output: TGard>, param = 'log.final.TGb.DYoblDtDistRot'
value = -8.899329e-09, unit = <Quantity 1. 1 / sec>, param_options = {}
def test_benchmark(self, vplanet_output, param, value, unit, param_options):
# The value returned by vplanet
output_value = recursive_getattr(vplanet_output, param)
# Are we comparing a specific index of an array?
index = param_options.pop("index", None)
if index is not None:
output_value = output_value[index]
# The expected value
benchmark_value = value * unit
# Check
> if np.allclose(output_value, benchmark_value, **param_options) == 0:
tests/benchmark.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<__array_function__ internals>:6: in allclose
???
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1525: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:544: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py:345: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:1356: in _to_own_unit
_value = value.to_value(self.unit)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:750: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/quantity.py:670: in _to_value
equivalencies=equivalencies)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1134: in to
equivalencies=equivalencies)(value)
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1064: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1050: in _get_converter
self, other, self._normalize_equivalencies(equivalencies))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Unit("1 / sec"), unit = Unit("1 / sec"), other = Unit(dimensionless)
equivalencies = []
def _apply_equivalencies(self, unit, other, equivalencies):
"""
Internal function (used from `_get_converter`) to apply
equivalence pairs.
"""
def make_converter(scale1, func, scale2):
def convert(v):
return func(_condition_arg(v) / scale1) * scale2
return convert
for funit, tunit, a, b in equivalencies:
if tunit is None:
try:
ratio_in_funit = (other.decompose() /
unit.decompose()).decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.)
except UnitsError:
pass
else:
try:
scale1 = funit._to(unit)
scale2 = tunit._to(other)
return make_converter(scale1, a, scale2)
except UnitsError:
pass
try:
scale1 = tunit._to(unit)
scale2 = funit._to(other)
return make_converter(scale1, b, scale2)
except UnitsError:
pass
def get_err_str(unit):
unit_str = unit.to_string('unscaled')
physical_type = unit.physical_type
if physical_type != 'unknown':
unit_str = f"'{unit_str}' ({physical_type})"
else:
unit_str = f"'{unit_str}'"
return unit_str
unit_str = get_err_str(unit)
other_str = get_err_str(other)
raise UnitConversionError(
> f"{unit_str} and {other_str} are not convertible")
E astropy.units.core.UnitConversionError: '1 / sec' (frequency) and '' (dimensionless) are not convertible
/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/astropy/units/core.py:1026: UnitConversionError