Skip to content
This repository has been archived by the owner on Oct 14, 2023. It is now read-only.

0.13.0: Test failure due to a unit problem #761

Closed
olebole opened this issue Aug 17, 2019 · 2 comments
Closed

0.13.0: Test failure due to a unit problem #761

olebole opened this issue Aug 17, 2019 · 2 comments
Assignees

Comments

@olebole
Copy link
Contributor

olebole commented Aug 17, 2019

馃悶 Problem

When running the tests during build time, I get the following error:

_____________________ [doctest] poliastro.core.util.cross ______________________
143     b : ndarray
144         3 Dimension vector.
145 
146     Examples
147     --------
148     >>> from poliastro.core.util import cross
149     >>> from astropy import units as u
150     >>> i = [1, 0, 0] * u.m
151     >>> j = [0, 1, 0] * u.m
152     >>> cross(i, j)
UNEXPECTED EXCEPTION: TypeError('only dimensionless scalar quantities can be converted to Python scalars')
Traceback (most recent call last):

  File "/usr/lib/python3/dist-packages/astropy/units/quantity.py", line 715, in to_value
    scale = self.unit._to(unit)

  File "/usr/lib/python3/dist-packages/astropy/units/core.py", line 953, in _to
    "'{0!r}' is not a scaled version of '{1!r}'".format(self, other))

astropy.units.core.UnitConversionError: 'Unit("m2")' is not a scaled version of 'Unit(dimensionless)'

and similarly

/build/poliastro-0.13.0/.pybuild/cpython3_3.7/build/poliastro/core/util.py:152: UnexpectedException
______________________ [doctest] poliastro.core.util.norm ______________________
103     vec: ndarray
104         Dimension 3 vector.
105 
106 
107     Examples
108     --------
109     >>> from poliastro.core.util import norm
110     >>> from astropy import units as u
111     >>> vec = [1, 1, 1] * u.m
112     >>> norm(vec)
Expected:
    1.7320508075688772
Got:
    <Quantity 1.73205081 m>

/build/poliastro-0.13.0/.pybuild/cpython3_3.7/build/poliastro/core/util.py:112: DocTestFailure

Any idea here? Astropy version is 3.2.1.

@astrojuanlu
Copy link
Member

Interestingly, these are bugs in our doctests and we never noticed them, perhaps because we only run them with numba. The poliastro.core functions are not meant to be used with units.

@astrojuanlu
Copy link
Member

Thanks @olebole!

astrojuanlu added a commit to olebole/poliastro that referenced this issue Aug 19, 2019
@astrojuanlu astrojuanlu self-assigned this Aug 19, 2019
@olebole olebole mentioned this issue Nov 4, 2019
34 tasks
astrojuanlu added a commit to astrojuanlu/poliastro that referenced this issue Dec 19, 2019
astrojuanlu added a commit to astrojuanlu/poliastro that referenced this issue Dec 19, 2019
astrojuanlu added a commit to astrojuanlu/poliastro that referenced this issue Dec 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants