hippke / tls

Transit Least Squares: An optimized transit-fitting algorithm to search for periodic transits of small planets
MIT License
48 stars 24 forks source link

Bug: expected dtype object, got 'numpy.dtype[float64]' with numpy 1.21 #95

Closed melissa-hobson closed 2 years ago

melissa-hobson commented 3 years ago

Describe the bug Attempting to run the tutorial, it crashes with the following error message: Traceback (most recent call last): File "/home/mhobson/anaconda3/lib/python3.7/multiprocessing/pool.py", line 121, in worker result = (True, func(*args, **kwds)) File "/home/mhobson/anaconda3/lib/python3.7/site-packages/transitleastsquares/core.py", line 119, in search_period phases = foldfast(t, period) TypeError: expected dtype object, got 'numpy.dtype[float64]' Prior to the crash, there is a numpy warning message: Creating model cache for 37 durations /home/mhobson/anaconda3/lib/python3.7/site-packages/transitleastsquares/transit.py:157: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray. lc_arr = numpy.array(lc_arr)

To Reproduce Steps to reproduce the behavior:

  1. Install the latest numpy version
  2. Install the latest TLS version
  3. Attempt to run the "Quick start with synthetic data" tutorial in python

Desktop (please complete the following information):

Additional context My numpy version is 1.21. Looking up the warning message, I found this deprecation has been in effect since 1.19.0. I tried downgrading my numpy to 1.18.4, but then batman doesn't work.

hippke commented 3 years ago

Can you please update to the latest TLS version 1.0.28 and test again? pip install transitleastsquares --upgrade

melissa-hobson commented 3 years ago

It still crashes, with a similar error:

Transit Least Squares TLS 1.0.28 (13 June 2021) Creating model cache for 47 durations Searching 4800 data points, 10870 periods from 0.602 to 50.0 days Using all 8 CPU threads 0%| | 0/10870 periods | 00:00<?multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/home/mhobson/anaconda3/lib/python3.7/multiprocessing/pool.py", line 121, in worker result = (True, func(*args, **kwds)) File "/home/mhobson/anaconda3/lib/python3.7/site-packages/transitleastsquares/core.py", line 119, in search_period phases = foldfast(t, period) TypeError: expected dtype object, got 'numpy.dtype[float64]' """

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "", line 1, in File "/home/mhobson/anaconda3/lib/python3.7/site-packages/transitleastsquares/main.py", line 150, in power for data in pool.imap_unordered(params, periods): File "/home/mhobson/anaconda3/lib/python3.7/multiprocessing/pool.py", line 748, in next raise value TypeError: expected dtype object, got 'numpy.dtype[float64]'

hippke commented 3 years ago

Sorry you're having trouble. We'll get this sorted out. I tried in in 3 different conda envs successsfully: Python 3.9.4 + numpy 1.21.0 + batman-package 2.4.8 + transitleastsquares 1.0.28 Python 3.7.2 + numpy 1.16.0 + batman-package 2.4.6 + transitleastsquares 1.0.28 Python 3.7.9 + numpy 1.21.0 + batman-package 2.4.8 + transitleastsquares 1.0.28 ==> This should be yours?

Can you give a list of all packages/versions using conda list?

Can you test in a new env to check whether there is something broken in your env? I made a new env like this and it works. Can you try the same?

conda deactivate
conda update --force --all
conda create --name melissa python=3.7.9
conda activate melissa
pip install transitleastsquares
conda install matplotlib
python synth.py
melissa-hobson commented 3 years ago

Indeed, it seems to be a problem with my environment! The "conda update all" command is still trying to run (output of that and of "conda list" attached), but creating a new environment and running there it works fine. Thank you so much for your help!

conda_env_issues.txt conda_list_output.txt