I'm using that code
```
periods = np.linspace(0.5, 20, 10)
durations = np.linspace(0.05, 0.2, 10)
from astropy.stats import BoxLeastSquares
bls = BoxLeastSquares(t=time, y=flux, dy=flux_err)
bls.power(periods, durations)
```
But it returns me a error
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-6-d582b87a594f> in <module>()
2 durations = np.linspace(0.05, 0.2, 10)
3
----> 4 from astropy.stats import BoxLeastSquares
5 bls = BoxLeastSquares(t=time, y=flux, dy=flux_err)
6 bls.power(periods, durations)
ImportError: cannot import name 'BoxLeastSquares'
---------------------------------------------------------------------------
I have no idea how correct this, it happened before the new update of lightkurve module I'm using the version 3.0.5
What version of Astropy are you using? According to these docs
This class has been deprecated and will be removed in a future version. Use
astropy.timeseries.BoxLeastSquares
instead.
This works for me in the latest version:
>>> import astropy
>>> astropy.__version__
'3.2.3'
>>> from astropy.timeseries import BoxLeastSquares
In general if you get an ImportError
for a function or class in a library like Astropy that you think should be there, it simply means that it doesn't exist, and so you should carefully check your version by looking at astropy.__version__
, and compare it to the API documentation for that version to make sure that the thing you're trying to import should actually exist.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.