在lightkurve中使用方框最小二乘时出错

问题描述 投票:0回答:1

我正在使用该代码

```
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)
```

但是它给我返回一个错误

---------------------------------------------------------------------------
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'

---------------------------------------------------------------------------

我不知道这有多正确,它发生在lightkurve模块的新更新之前我正在使用版本3.0.5

python python-3.x astropy
1个回答
0
投票

您正在使用什么版本的Astropy?根据these docs

此类已被弃用,并将在以后的版本中删除。请改用astropy.timeseries.BoxLeastSquares

这对我来说是最新版本:

astropy.timeseries.BoxLeastSquares

[通常,如果您认为应该在Astropy之类的库中获得函数或类的>>> import astropy >>> astropy.__version__ '3.2.3' >>> from astropy.timeseries import BoxLeastSquares ,它只是意味着它不存在,因此,您应通过查看[ C0],并将其与该版本的API文档进行比较,以确保您要导入的内容确实存在。

© www.soinside.com 2019 - 2024. All rights reserved.