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

Prevent Orbit creation with non scalar quantities #716

Closed
dragonlost opened this issue Jun 26, 2019 · 9 comments · Fixed by #903
Closed

Prevent Orbit creation with non scalar quantities #716

dragonlost opened this issue Jun 26, 2019 · 9 comments · Fixed by #903

Comments

@dragonlost
Copy link

Hello.
I recently use poliastro but i have a bug.
when i use propagate fonction :

    xyz_c.append(ss.r)
  File "/home/sdurand/miniconda3/lib/python3.7/site-packages/poliastro/twobody/orbit.py", line 99, in r
    return self._state.to_vectors().r
  File "/home/sdurand/miniconda3/lib/python3.7/site-packages/poliastro/twobody/_states.py", line 113, in to_vectors
    self.nu.to(u.rad).value,
  File "/home/sdurand/miniconda3/lib/python3.7/site-packages/numba/dispatcher.py", line 350, in _compile_for_args
    error_rewrite(e, 'typing')
  File "/home/sdurand/miniconda3/lib/python3.7/site-packages/numba/dispatcher.py", line 317, in error_rewrite
    reraise(type(e), e, None)
  File "/home/sdurand/miniconda3/lib/python3.7/site-packages/numba/six.py", line 658, in reraise
    raise value.with_traceback(tb)
numba.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Failed in nopython mode pipeline (step: nopython frontend)
Type of variable 'v_pqw' cannot be determined, operation: $0.45, location: /home/sdurand/miniconda3/lib/python3.7/site-packages/poliastro/core/elements.py (76)

File "../../../../../miniconda3/lib/python3.7/site-packages/poliastro/core/elements.py", line 76:
def rv_pqw(k, p, ecc, nu):
    <source elided>
    r_pqw = (np.array([cos(nu), sin(nu), 0 * nu]) * p / (1 + ecc * cos(nu))).T
    v_pqw = (np.array([-sin(nu), (ecc + cos(nu)), 0]) * sqrt(k / p)).T
    ^

[1] During: resolving callee type: type(CPUDispatcher(<function rv_pqw at 0x7f1c6406b0d0>))
[2] During: typing of call at /home/sdurand/miniconda3/lib/python3.7/site-packages/poliastro/core/elements.py (102)


File "../../../../../miniconda3/lib/python3.7/site-packages/poliastro/core/elements.py", line 102:
def coe2rv(k, p, ecc, inc, raan, argp, nu):
    <source elided>
    """
    r_pqw, v_pqw = rv_pqw(k, p, ecc, nu)
    ^

This is not usually a problem with Numba itself but instead often caused by
the use of unsupported features or an issue in resolving types.

To see Python/NumPy features supported by the latest release of Numba visit:
http://numba.pydata.org/numba-doc/dev/reference/pysupported.html
and
http://numba.pydata.org/numba-doc/dev/reference/numpysupported.html

For more information about typing errors and how to debug them visit:
http://numba.pydata.org/numba-doc/latest/user/troubleshoot.html#my-code-doesn-t-compile

If you think your code should work with Numba, please report the error message
and traceback, along with a minimal reproducer at:
https://github.com/numba/numba/issues/new

@astrojuanlu
Copy link
Member

Hi @dragonlost! Can you display ss.classical()?

@astrojuanlu
Copy link
Member

This is probably a bug, I'm sure we can prevent the user from doing this.

@astrojuanlu
Copy link
Member

Also, we will need your poliastro version, Python version, and operative system.

@dragonlost
Copy link
Author

dragonlost commented Jun 26, 2019

for ss.classical() : (<Quantity [6878.14] km>, <Quantity [0.]>, <Quantity 20. deg>, <Quantity 0. deg>, <Quantity 0. deg>, <Quantity 0. deg>)

My operative system : Ubuntu Mate 18.04.2
My python version : Python 3.7.2 with Anaconda 3 (gcc 7.3.0)
My poliastro version : 0.12.0 (build : py_0, conda-forge)

and conda 4.7.5 and numba 0.43.1
`

@astrojuanlu
Copy link
Member

I see that the first two are arrays with one element, did you notice the brackets?

@dragonlost
Copy link
Author

ok is my fault. I had a bad upstream conversion that would create me "a" and "e" as a list

@dragonlost
Copy link
Author

Thank for very very fast support !!

@astrojuanlu
Copy link
Member

😄 You're welcome! We'll try to find a way to prevent this in the future, that numba error is impossible to understand :)

@astrojuanlu astrojuanlu changed the title numba error Prevent Orbit creation with non scalar quantities Jul 1, 2019
@astrojuanlu astrojuanlu added this to the 0.14 milestone Jul 21, 2019
@astrojuanlu astrojuanlu modified the milestones: 0.14, 0.15 Apr 5, 2020
@astrojuanlu
Copy link
Member

I just got bitten by a slightly different version of this

@astrojuanlu astrojuanlu self-assigned this Apr 11, 2020
astrojuanlu added a commit to astrojuanlu/poliastro that referenced this issue Apr 11, 2020
astrojuanlu added a commit to astrojuanlu/poliastro that referenced this issue Apr 12, 2020
astrojuanlu added a commit to astrojuanlu/poliastro that referenced this issue Apr 12, 2020
astrojuanlu added a commit to astrojuanlu/poliastro that referenced this issue Apr 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants