test_polcart.py 文件源码

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

项目:nxviz 作者: ericmjl 项目源码 文件源码
def test_convert_xy(x, y):
    assume(x != 0 and y != 0)
    assume(np.isfinite(x) and np.isfinite(y))
    assume(abs(x) < 1E6 and abs(y) < 1E6)
    assume(abs(x) > 0.01 and abs(y) > 0.01)

    # Test radians
    r, theta = to_polar(x, y)
    x_new, y_new = to_cartesian(r, theta)
    assert np.allclose(x, x_new)
    assert np.allclose(y, y_new)

    # Test degrees
    r, theta = to_polar(x, y, theta_units="degrees")
    x_new, y_new = to_cartesian(r, theta, theta_units="degrees")
    assert np.allclose(x, x_new)
    assert np.allclose(y, y_new)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号