def test_true_anomaly(ma, ecc): ma = np.asarray(ma) assume(np.all(np.abs(ma) > 0.0001)) ta = RV.true_anomaly(ma, ecc) E = np.arccos((ecc + np.cos(ta)) / (1 + ecc * np.cos(ta))) assert np.allclose(ma, E - ecc * np.sin(E), rtol=0.05) assert len(ta) == len(ma)
def test_true_anomaly_with_scalar(ma, ecc): assume(abs(ma) > 0.001) ta = RV.true_anomaly(ma, ecc) E = np.arccos((ecc + np.cos(ta)) / (1 + ecc * np.cos(ta))) assert np.allclose(ma, E - ecc * np.sin(E)) assert len(ta) == 1
def test_true_anomaly_errors(ecc): with pytest.raises(TypeError): RV.true_anomaly([], ecc) with pytest.raises(ValueError): RV.true_anomaly(np.array([]), ecc)
def test_anomaly_gives_runtime_error(): with pytest.raises(RuntimeError): RV.true_anomaly(0.0000001, 0.9999999, niterationmax=5)