Repository: poliastro/poliastro

Issue:
ZeroDivisionError when propagating with time zero
Actually if NUMBA_DISABLE_JIT is exported this appears as a maximum number of iterations error. Why does it change is a matter of study, but still the easiest way to fix it is to contemplate the special case of time = 0.0 at the very beginning of the `_kepler` function.

Discussion:

Patch:
diff --git a/README b/README
index f6d8cd9c..f238398c 100644
--- a/README
+++ b/README
@@ -20,10 +20,6 @@
 .. image:: https://ci.appveyor.com/api/projects/status/ajg5j8byv8isslso/branch/master?svg=true
    :target: https://ci.appveyor.com/project/poliastro/poliastro/branch/master
 
-.. image:: https://badge.waffle.io/poliastro/poliastro.png?label=Ready
-   :target: https://waffle.io/poliastro/poliastro 
-   :alt: 'Stories in Ready'
-
 .. image:: https://img.shields.io/badge/license-MIT-blue.svg
    :target: https://raw.githubusercontent.com/poliastro/poliastro/master/COPYING
 
diff --git a/poliastro/twobody/propagation.py b/poliastro/twobody/propagation.py
index 70a91f4f..567fd624 100644
--- a/poliastro/twobody/propagation.py
+++ b/poliastro/twobody/propagation.py
@@ -85,7 +85,7 @@ def _kepler(k, r0, v0, tof, numiter, rtol):
         norm_r = xi * xi * c2_psi + dot_r0v0 / sqrt_mu * xi * (1 - psi * c3_psi) + norm_r0 * (1 - psi * c2_psi)
         xi_new = xi + (sqrt_mu * tof - xi * xi * xi * c3_psi - dot_r0v0 / sqrt_mu * xi * xi * c2_psi -
                        norm_r0 * xi * (1 - psi * c3_psi)) / norm_r
-        if abs((xi_new - xi) / xi_new) < rtol:
+        if abs(np.divide(xi_new - xi, xi_new)) < rtol or abs(xi_new - xi) < rtol:
             break
         else:
             count += 1


Test patch:
diff --git a/poliastro/tests/test_twobody.py b/poliastro/tests/test_twobody.py
index ac0b0e97..5da1ac2d 100644
--- a/poliastro/tests/test_twobody.py
+++ b/poliastro/tests/test_twobody.py
@@ -228,8 +228,23 @@ def test_propagate():
     ss0 = State.from_vectors(Earth, r0, v0)
     tof = 40 * u.min
     ss1 = ss0.propagate(tof)
-    r, v = ss1.r, ss1.v
+    r, v = ss1.rv()
     assert_array_almost_equal(r.value, [-4219.7527, 4363.0292, -3958.7666],
                               decimal=1)
     assert_array_almost_equal(v.value, [3.689866, -1.916735, -6.112511],
                               decimal=4)
+
+
+def test_propagation_zero_time_returns_same_state():
+    # Bug #50
+    r0 = [1131.340, -2282.343, 6672.423] * u.km
+    v0 = [-5.64305, 4.30333, 2.42879] * u.km / u.s
+    ss0 = State.from_vectors(Earth, r0, v0)
+    tof = 0 * u.s
+
+    ss1 = ss0.propagate(tof)
+
+    r, v = ss1.rv()
+
+    assert_array_almost_equal(r.value, r0.value)
+    assert_array_almost_equal(v.value, v0.value)