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)
评论列表
文章目录