tests.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:SoftwareTesting 作者: adrn 项目源码 文件源码
def test_integrate():
    subslice = slice(100,200)
    wvln = np.linspace(1000., 4000., 1024)

    flux = np.zeros_like(wvln)
    flux[subslice] = 1./np.ptp(wvln[subslice]) # so the integral is 1

    s = Spectrum(wvln*u.angstrom, flux*u.erg/u.cm**2/u.angstrom)

    # the integration grid is a sub-section of the full wavelength array
    wvln_grid = s.wavelength[subslice]
    i_flux = s.integrate(wvln_grid)
    assert np.allclose(i_flux.value, 1.) # "close" because this is float comparison
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号