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

int object is not callable error for python == 3.8.5 #36

Closed
gmbrandt opened this issue Feb 6, 2021 · 3 comments
Closed

int object is not callable error for python == 3.8.5 #36

gmbrandt opened this issue Feb 6, 2021 · 3 comments

Comments

@gmbrandt
Copy link
Contributor

gmbrandt commented Feb 6, 2021

using get_BC_vel in python 3.8 with up to date packages (e.g. astropy etc.) raises a int object is not callable error. The stack trace follows

~/envs/nres/lib/python3.8/site-packages/barycorrpy/barycorrpy.py in get_BC_vel(JDUTC, starname, hip_id, ra, dec, epoch, pmra, pmdec, px, rv, obsname, lat, longi, alt, zmeas, ephemeris, leap_dir, leap_update, predictive, SolSystemTarget, HorizonsID_type)
    215         vel = []
    216 
--> 217         for jdutc,zm in zip(JDUTC,np.repeat(zmeas,np.size(JDUTC)/np.size(zmeas))):
    218             a = BCPy(JDUTC=jdutc,
    219                      zmeas=zm,

<__array_function__ internals> in size(*args, **kwargs)

~/envs/nres/lib/python3.8/site-packages/astropy/utils/shapes.py in __array_function__(self, function, types, args, kwargs)
    245             method = getattr(self, name, None)
    246             if method is not None:
--> 247                 return method(*args[1:], **kwargs)
    248 
    249         # Fall-back, just pass the arguments on since perhaps the function

TypeError: 'int' object is not callable

Minimal working example to reproduce the above issue (package versions follow at the end of this issue)

from astropy.time import Time
from barycorrpy import get_BC_vel
import numpy as np

mid_obstime = Time(1991, format='decimalyear')

bc_vel, warnings, status = get_BC_vel(JDUTC=Time(np.array([mid_obstime.jd]), format='jd'), 
                                      obsname='Cerro Tololo',
                                      ra=215.8146, dec=1.2394,
                                      epoch=Time(2016, format='decimalyear').jd,
                                      pmra=223.5314, pmdec=-478.2748, px=57.27057,
                                      ephemeris='de430',
                                      leap_update=False, rv=1000)

Calling the above in e.g. Ipython will cause the aforementioned error. This seems like an issue with np.size() crashing on a length 1 astropy.time.Time object.One gets the same error with
JDUTC=mid_obstime,
i.e. using the actual Time value results in the same error.

This was not an issue in python 3.5

My environment to reproduce the error:
python == 3.8.5
astropy==4.2
numpy==1.20.0 (also fails with numpy==1.19.5)

@shbhuk
Copy link
Owner

shbhuk commented Feb 6, 2021

Hi @gmbrandt , thank you for pointing this out, the traceback and the MWE. I'll try to reproduce it, and get back to you!

@shbhuk
Copy link
Owner

shbhuk commented Feb 6, 2021

Hi @gmbrandt,

I'm unable to replicate the error using your MWE with my current environment, here are my versions -
python == 3.8.1
numpy == 1.19.4
barycorrpy == 0.3.4
astropy == 4.1

I'll update them and check.

@shbhuk
Copy link
Owner

shbhuk commented Feb 6, 2021

I do reproduce the error using numpy==1.20.0 and astropy==4.2. Closing it with #37

Thanks!

@shbhuk shbhuk closed this as completed Feb 6, 2021
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