Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

working with python 2 but not with python 3 #207

Closed
gyth opened this issue Sep 20, 2018 · 5 comments
Closed

working with python 2 but not with python 3 #207

gyth opened this issue Sep 20, 2018 · 5 comments
Assignees

Comments

@gyth
Copy link

gyth commented Sep 20, 2018

skyfield 1.8

#!/usr/bin/env python2
from skyfield.api import load
ts = load.timescale()
eph = load('de421.bsp')
sun = eph['sun']
earth = eph['earth']
t = ts.utc(2000, range(12 ))
lat, lon, distance = earth.at(t).observe(sun).ecliptic_latlon()
print('ok')

it work fine

but by changing the first line by this

#!/usr/bin/env python3

it throw this error

Traceback (most recent call last):
  File "/home/********/testforbug.py", line 8, in <module>
    lat, lon, distance = earth.at(t).observe(sun).ecliptic_latlon()
  File "/usr/local/lib/python3.5/dist-packages/skyfield/positionlib.py", line 248, in ecliptic_latlon
    d, lat, lon = to_polar(vector.au)
  File "/usr/local/lib/python3.5/dist-packages/skyfield/functions.py", line 59, in to_polar
    x, y, z = xyz
ValueError: too many values to unpack (expected 3)

am I missing something ?
I believe this script was doing ok before...

@gyth
Copy link
Author

gyth commented Sep 22, 2018

#207 and #208 have high chance to be the same issue.

test cases with skyfield 1.8 and numpy 1.15.1

from skyfield.api import load
ts = load.timescale()
eph = load('de421.bsp')
earth = eph['earth']
t = ts.utc(2000, range(12))

python 3

 lat, lon, distance = earth.at(t).ecliptic_latlon('date')
 lat, lon, distance = earth.at(t).ecliptic_latlon(t)

those two line of code work fine.

but

 lat, lon, distance = earth.at(t).ecliptic_latlon()

keep rising the same error message as before.


python 2

it is the revers:

lat, lon, distance = earth.at(t).ecliptic_latlon()

work.
but

lat, lon, distance = earth.at(t).ecliptic_latlon(t)
lat, lon, distance = earth.at(t).ecliptic_latlon('date')

rise this error
TypeError: ecliptic_latlon() takes exactly 1 argument (2 given)

Does anyone can reproduce my result ?
or did I do something wrong ?

@brandon-rhodes brandon-rhodes self-assigned this Sep 23, 2018
brandon-rhodes added a commit that referenced this issue Sep 23, 2018
Until this is fixed, the build should be broken.
@brandon-rhodes
Copy link
Member

My guess is that you might have a different version of Skyfield installed under each version of Python, since that method didn't used to take an optional second argument; that would explain why you're not seeing the same error (which is a real one that needs to be fixed!) under Python 2, which isn't even accepting the new 2nd argument.

Could you try printing skyfield.VERSION in both Pythons?

@brandon-rhodes
Copy link
Member

I've just released Skyfield 1.9 with this fix. Thanks for the report!

@gyth
Copy link
Author

gyth commented Sep 23, 2018

yes indeed ... my mistake: 2 different version off skyfield on my system:
pip == pip3 != pip2

thank for skyfield.VERSION, I'll use it in future bug report

@brandon-rhodes
Copy link
Member

Hopefully you can now upgrade both Pythons and get working Skyfields :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants