Added new test for O2 sinks. #281
30 fail, 18 042 pass in 3m 35s
18 072 tests 18 042 ✅ 3m 35s ⏱️
1 suites 0 💤
1 files 30 ❌
Results for commit 91c875f.
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:`astropy: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)
elif not self.dtype.names:
# For non-structured, we attempt a short-cut, where we just get
# the scale. If that is 1, we do not have to do anything.
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.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:959:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1129: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_LL2.Test_LL2 object at 0x7f6f29e4bdc0>
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>:200: in allclose
???
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1828: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:558: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1631: in _to_own_unit
_value = value.to_value(unit)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:962: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:868: in _to_value
return self.unit.to(
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1165: in to
return self._get_converter(Unit(other), equivalencies)(value)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1094: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1077: in _get_converter
return self._apply_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:
ratio = other.decompose() / unit.decompose()
try:
ratio_in_funit = ratio.decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.0)
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1054: 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:`astropy: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)
elif not self.dtype.names:
# For non-structured, we attempt a short-cut, where we just get
# the scale. If that is 1, we do not have to do anything.
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.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:959:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1129: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_LL2.Test_LL2 object at 0x7f6f29e69dc0>
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>:200: in allclose
???
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1828: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:558: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1631: in _to_own_unit
_value = value.to_value(unit)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:962: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:868: in _to_value
return self.unit.to(
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1165: in to
return self._get_converter(Unit(other), equivalencies)(value)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1094: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1077: in _get_converter
return self._apply_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:
ratio = other.decompose() / unit.decompose()
try:
ratio_in_funit = ratio.decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.0)
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1054: 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:`astropy: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)
elif not self.dtype.names:
# For non-structured, we attempt a short-cut, where we just get
# the scale. If that is 1, we do not have to do anything.
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.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:959:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1129: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_LL2.Test_LL2 object at 0x7f6f29e08dc0>
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>:200: in allclose
???
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1828: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:558: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1631: in _to_own_unit
_value = value.to_value(unit)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:962: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:868: in _to_value
return self.unit.to(
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1165: in to
return self._get_converter(Unit(other), equivalencies)(value)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1094: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1077: in _get_converter
return self._apply_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:
ratio = other.decompose() / unit.decompose()
try:
ratio_in_funit = ratio.decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.0)
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1054: 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:`astropy: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)
elif not self.dtype.names:
# For non-structured, we attempt a short-cut, where we just get
# the scale. If that is 1, we do not have to do anything.
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.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:959:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1129: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_LL2.Test_LL2 object at 0x7f6f29cd74c0>
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>:200: in allclose
???
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1828: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:558: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1631: in _to_own_unit
_value = value.to_value(unit)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:962: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:868: in _to_value
return self.unit.to(
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1165: in to
return self._get_converter(Unit(other), equivalencies)(value)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1094: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1077: in _get_converter
return self._apply_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:
ratio = other.decompose() / unit.decompose()
try:
ratio_in_funit = ratio.decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.0)
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1054: 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:`astropy: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)
elif not self.dtype.names:
# For non-structured, we attempt a short-cut, where we just get
# the scale. If that is 1, we do not have to do anything.
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.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:959:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1129: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_LL2.Test_LL2 object at 0x7f6f29bf64c0>
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>:200: in allclose
???
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1828: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:558: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1631: in _to_own_unit
_value = value.to_value(unit)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:962: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:868: in _to_value
return self.unit.to(
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1165: in to
return self._get_converter(Unit(other), equivalencies)(value)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1094: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1077: in _get_converter
return self._apply_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:
ratio = other.decompose() / unit.decompose()
try:
ratio_in_funit = ratio.decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.0)
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1054: 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:`astropy: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)
elif not self.dtype.names:
# For non-structured, we attempt a short-cut, where we just get
# the scale. If that is 1, we do not have to do anything.
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.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:959:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1129: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_LL2.Test_LL2 object at 0x7f6f29c144c0>
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>:200: in allclose
???
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1828: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:558: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1631: in _to_own_unit
_value = value.to_value(unit)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:962: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:868: in _to_value
return self.unit.to(
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1165: in to
return self._get_converter(Unit(other), equivalencies)(value)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1094: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1077: in _get_converter
return self._apply_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:
ratio = other.decompose() / unit.decompose()
try:
ratio_in_funit = ratio.decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.0)
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1054: 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:`astropy: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)
elif not self.dtype.names:
# For non-structured, we attempt a short-cut, where we just get
# the scale. If that is 1, we do not have to do anything.
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.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:959:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1129: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_RD4.Test_RD4 object at 0x7f6f29ae26a0>
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>:200: in allclose
???
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1828: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:558: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1631: in _to_own_unit
_value = value.to_value(unit)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:962: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:868: in _to_value
return self.unit.to(
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1165: in to
return self._get_converter(Unit(other), equivalencies)(value)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1094: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1077: in _get_converter
return self._apply_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:
ratio = other.decompose() / unit.decompose()
try:
ratio_in_funit = ratio.decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.0)
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1054: 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:`astropy: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)
elif not self.dtype.names:
# For non-structured, we attempt a short-cut, where we just get
# the scale. If that is 1, we do not have to do anything.
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.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:959:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1129: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_RD4.Test_RD4 object at 0x7f6f29a806a0>
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>:200: in allclose
???
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1828: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:558: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1631: in _to_own_unit
_value = value.to_value(unit)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:962: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:868: in _to_value
return self.unit.to(
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1165: in to
return self._get_converter(Unit(other), equivalencies)(value)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1094: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1077: in _get_converter
return self._apply_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:
ratio = other.decompose() / unit.decompose()
try:
ratio_in_funit = ratio.decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.0)
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1054: 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:`astropy: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)
elif not self.dtype.names:
# For non-structured, we attempt a short-cut, where we just get
# the scale. If that is 1, we do not have to do anything.
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.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:959:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1129: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_RD4.Test_RD4 object at 0x7f6f29c4d490>
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>:200: in allclose
???
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1828: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:558: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1631: in _to_own_unit
_value = value.to_value(unit)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:962: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:868: in _to_value
return self.unit.to(
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1165: in to
return self._get_converter(Unit(other), equivalencies)(value)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1094: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1077: in _get_converter
return self._apply_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:
ratio = other.decompose() / unit.decompose()
try:
ratio_in_funit = ratio.decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.0)
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1054: 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:`astropy: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)
elif not self.dtype.names:
# For non-structured, we attempt a short-cut, where we just get
# the scale. If that is 1, we do not have to do anything.
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.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:959:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1129: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_RD4.Test_RD4 object at 0x7f6f29994b50>
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>:200: in allclose
???
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1828: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:558: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1631: in _to_own_unit
_value = value.to_value(unit)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:962: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:868: in _to_value
return self.unit.to(
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1165: in to
return self._get_converter(Unit(other), equivalencies)(value)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1094: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1077: in _get_converter
return self._apply_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:
ratio = other.decompose() / unit.decompose()
try:
ratio_in_funit = ratio.decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.0)
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1054: 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:`astropy: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)
elif not self.dtype.names:
# For non-structured, we attempt a short-cut, where we just get
# the scale. If that is 1, we do not have to do anything.
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.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:959:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1129: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_RD4.Test_RD4 object at 0x7f6f298f2b50>
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>:200: in allclose
???
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1828: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:558: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1631: in _to_own_unit
_value = value.to_value(unit)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:962: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:868: in _to_value
return self.unit.to(
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1165: in to
return self._get_converter(Unit(other), equivalencies)(value)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1094: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1077: in _get_converter
return self._apply_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:
ratio = other.decompose() / unit.decompose()
try:
ratio_in_funit = ratio.decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.0)
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1054: 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:`astropy: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)
elif not self.dtype.names:
# For non-structured, we attempt a short-cut, where we just get
# the scale. If that is 1, we do not have to do anything.
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.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:959:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1129: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_RD4.Test_RD4 object at 0x7f6f29910b50>
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>:200: in allclose
???
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1828: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:558: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1631: in _to_own_unit
_value = value.to_value(unit)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:962: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:868: in _to_value
return self.unit.to(
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1165: in to
return self._get_converter(Unit(other), equivalencies)(value)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1094: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1077: in _get_converter
return self._apply_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:
ratio = other.decompose() / unit.decompose()
try:
ratio_in_funit = ratio.decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.0)
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1054: 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:`astropy: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)
elif not self.dtype.names:
# For non-structured, we attempt a short-cut, where we just get
# the scale. If that is 1, we do not have to do anything.
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.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:959:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1129: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_SSDistOrbDistRot.Test_SSDistOrbDistRot object at 0x7f6f297b0eb0>
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>:200: in allclose
???
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1828: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:558: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1631: in _to_own_unit
_value = value.to_value(unit)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:962: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:868: in _to_value
return self.unit.to(
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1165: in to
return self._get_converter(Unit(other), equivalencies)(value)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1094: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1077: in _get_converter
return self._apply_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:
ratio = other.decompose() / unit.decompose()
try:
ratio_in_funit = ratio.decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.0)
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1054: 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:`astropy: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)
elif not self.dtype.names:
# For non-structured, we attempt a short-cut, where we just get
# the scale. If that is 1, we do not have to do anything.
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.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:959:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1129: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_SSDistOrbDistRot.Test_SSDistOrbDistRot object at 0x7f6f297d0eb0>
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>:200: in allclose
???
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1828: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:558: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1631: in _to_own_unit
_value = value.to_value(unit)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:962: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:868: in _to_value
return self.unit.to(
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1165: in to
return self._get_converter(Unit(other), equivalencies)(value)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1094: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1077: in _get_converter
return self._apply_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:
ratio = other.decompose() / unit.decompose()
try:
ratio_in_funit = ratio.decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.0)
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1054: 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:`astropy: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)
elif not self.dtype.names:
# For non-structured, we attempt a short-cut, where we just get
# the scale. If that is 1, we do not have to do anything.
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.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:959:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1129: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_SSDistOrbDistRot.Test_SSDistOrbDistRot object at 0x7f6f2976feb0>
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>:200: in allclose
???
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1828: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:558: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1631: in _to_own_unit
_value = value.to_value(unit)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:962: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:868: in _to_value
return self.unit.to(
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1165: in to
return self._get_converter(Unit(other), equivalencies)(value)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1094: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1077: in _get_converter
return self._apply_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:
ratio = other.decompose() / unit.decompose()
try:
ratio_in_funit = ratio.decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.0)
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1054: 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:`astropy: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)
elif not self.dtype.names:
# For non-structured, we attempt a short-cut, where we just get
# the scale. If that is 1, we do not have to do anything.
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.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:959:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1129: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_SSDistOrbDistRot.Test_SSDistOrbDistRot object at 0x7f6f296835b0>
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>:200: in allclose
???
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1828: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:558: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1631: in _to_own_unit
_value = value.to_value(unit)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:962: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:868: in _to_value
return self.unit.to(
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1165: in to
return self._get_converter(Unit(other), equivalencies)(value)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1094: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1077: in _get_converter
return self._apply_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:
ratio = other.decompose() / unit.decompose()
try:
ratio_in_funit = ratio.decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.0)
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1054: 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:`astropy: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)
elif not self.dtype.names:
# For non-structured, we attempt a short-cut, where we just get
# the scale. If that is 1, we do not have to do anything.
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.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:959:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1129: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_SSDistOrbDistRot.Test_SSDistOrbDistRot object at 0x7f6f296a25b0>
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>:200: in allclose
???
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1828: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:558: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1631: in _to_own_unit
_value = value.to_value(unit)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:962: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:868: in _to_value
return self.unit.to(
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1165: in to
return self._get_converter(Unit(other), equivalencies)(value)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1094: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1077: in _get_converter
return self._apply_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:
ratio = other.decompose() / unit.decompose()
try:
ratio_in_funit = ratio.decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.0)
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1054: 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:`astropy: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)
elif not self.dtype.names:
# For non-structured, we attempt a short-cut, where we just get
# the scale. If that is 1, we do not have to do anything.
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.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:959:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1129: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_SSDistOrbDistRot.Test_SSDistOrbDistRot object at 0x7f6f295c15b0>
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>:200: in allclose
???
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1828: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:558: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1631: in _to_own_unit
_value = value.to_value(unit)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:962: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:868: in _to_value
return self.unit.to(
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1165: in to
return self._get_converter(Unit(other), equivalencies)(value)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1094: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1077: in _get_converter
return self._apply_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:
ratio = other.decompose() / unit.decompose()
try:
ratio_in_funit = ratio.decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.0)
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1054: 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:`astropy: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)
elif not self.dtype.names:
# For non-structured, we attempt a short-cut, where we just get
# the scale. If that is 1, we do not have to do anything.
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.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:959:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1129: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_CTL_LL2.Test_CTL_LL2 object at 0x7f6f2953c130>
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>:200: in allclose
???
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1828: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:558: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1631: in _to_own_unit
_value = value.to_value(unit)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:962: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:868: in _to_value
return self.unit.to(
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1165: in to
return self._get_converter(Unit(other), equivalencies)(value)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1094: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1077: in _get_converter
return self._apply_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:
ratio = other.decompose() / unit.decompose()
try:
ratio_in_funit = ratio.decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.0)
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1054: 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:`astropy: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)
elif not self.dtype.names:
# For non-structured, we attempt a short-cut, where we just get
# the scale. If that is 1, we do not have to do anything.
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.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:959:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1129: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_CTL_LL2.Test_CTL_LL2 object at 0x7f6f294b02b0>
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>:200: in allclose
???
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1828: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:558: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1631: in _to_own_unit
_value = value.to_value(unit)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:962: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:868: in _to_value
return self.unit.to(
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1165: in to
return self._get_converter(Unit(other), equivalencies)(value)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1094: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1077: in _get_converter
return self._apply_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:
ratio = other.decompose() / unit.decompose()
try:
ratio_in_funit = ratio.decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.0)
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1054: 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:`astropy: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)
elif not self.dtype.names:
# For non-structured, we attempt a short-cut, where we just get
# the scale. If that is 1, we do not have to do anything.
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.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:959:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1129: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_CTL_LL2.Test_CTL_LL2 object at 0x7f6f293bf970>
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>:200: in allclose
???
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1828: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:558: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1631: in _to_own_unit
_value = value.to_value(unit)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:962: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:868: in _to_value
return self.unit.to(
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1165: in to
return self._get_converter(Unit(other), equivalencies)(value)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1094: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1077: in _get_converter
return self._apply_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:
ratio = other.decompose() / unit.decompose()
try:
ratio_in_funit = ratio.decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.0)
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1054: 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:`astropy: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)
elif not self.dtype.names:
# For non-structured, we attempt a short-cut, where we just get
# the scale. If that is 1, we do not have to do anything.
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.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:959:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1129: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_CTL_LL2.Test_CTL_LL2 object at 0x7f6f29376af0>
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>:200: in allclose
???
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1828: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:558: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1631: in _to_own_unit
_value = value.to_value(unit)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:962: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:868: in _to_value
return self.unit.to(
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1165: in to
return self._get_converter(Unit(other), equivalencies)(value)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1094: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1077: in _get_converter
return self._apply_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:
ratio = other.decompose() / unit.decompose()
try:
ratio_in_funit = ratio.decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.0)
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1054: 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:`astropy: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)
elif not self.dtype.names:
# For non-structured, we attempt a short-cut, where we just get
# the scale. If that is 1, we do not have to do anything.
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.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:959:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1129: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_CTL_RD4.Test_CTL_RD4 object at 0x7f6f2931ca60>
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>:200: in allclose
???
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1828: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:558: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1631: in _to_own_unit
_value = value.to_value(unit)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:962: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:868: in _to_value
return self.unit.to(
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1165: in to
return self._get_converter(Unit(other), equivalencies)(value)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1094: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1077: in _get_converter
return self._apply_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:
ratio = other.decompose() / unit.decompose()
try:
ratio_in_funit = ratio.decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.0)
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1054: 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:`astropy: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)
elif not self.dtype.names:
# For non-structured, we attempt a short-cut, where we just get
# the scale. If that is 1, we do not have to do anything.
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.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:959:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1129: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_CTL_RD4.Test_CTL_RD4 object at 0x7f6f29290be0>
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>:200: in allclose
???
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1828: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:558: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1631: in _to_own_unit
_value = value.to_value(unit)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:962: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:868: in _to_value
return self.unit.to(
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1165: in to
return self._get_converter(Unit(other), equivalencies)(value)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1094: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1077: in _get_converter
return self._apply_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:
ratio = other.decompose() / unit.decompose()
try:
ratio_in_funit = ratio.decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.0)
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1054: 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:`astropy: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)
elif not self.dtype.names:
# For non-structured, we attempt a short-cut, where we just get
# the scale. If that is 1, we do not have to do anything.
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.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:959:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1129: UnitConversionError
During handling of the above exception, another exception occurred:
self = <test_CTL_RD4.Test_CTL_RD4 object at 0x7f6f2912d2e0>
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>:200: in allclose
???
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1828: in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:558: in close
(a, b), unit = _quantities2arrays(a, b, unit_from_first=True)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in _quantities2arrays
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity_helper/function_helpers.py:352: in <genexpr>
arrays = tuple((q._to_own_unit(arg)) for arg in args)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:1631: in _to_own_unit
_value = value.to_value(unit)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:962: in to_value
value = self._to_value(unit, equivalencies)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/quantity.py:868: in _to_value
return self.unit.to(
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1165: in to
return self._get_converter(Unit(other), equivalencies)(value)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1094: in _get_converter
raise exc
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1077: in _get_converter
return self._apply_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:
ratio = other.decompose() / unit.decompose()
try:
ratio_in_funit = ratio.decompose([funit])
return make_converter(ratio_in_funit.scale, a, 1.0)
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.8.18/x64/lib/python3.8/site-packages/astropy/units/core.py:1054: UnitConversionError