Repository: poliastro/poliastro

Issue:
Fix velocity units in ephem
See discussion at https://github.com/brandon-rhodes/python-jplephem/issues/11

Discussion:

Patch:
diff --git a/.travis.yml b/.travis.yml
index 82f85935..6d65bda5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -20,6 +20,7 @@ install:
   - conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION
   - source activate test-environment
   - conda install numpy "numba>=0.18" "astropy>=1.0" matplotlib pytest pip coverage requests pyyaml scipy
+  - conda install jplephem -c poliastro
   - pip install coveralls pytest-cov
 script:
   - py.test -vv
diff --git a/appveyor.yml b/appveyor.yml
index bef87b9e..a0d4b621 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -36,6 +36,7 @@ install:
 
   # Install dependencies
   - "conda install -q numpy numba>=0.18 astropy>=1.0 matplotlib pytest scipy"
+  - "conda install jplephem -c poliastro"
   
 build: off
 
diff --git a/poliastro/ephem.py b/poliastro/ephem.py
index cba4b1d8..3aabcc7f 100644
--- a/poliastro/ephem.py
+++ b/poliastro/ephem.py
@@ -129,5 +129,5 @@ def planet_ephem(body, epoch, kernel=default_kernel):
     """
     r, v = kernel[0, body].compute_and_differentiate(epoch.jd1, epoch.jd2)
     r *= u.km
-    v *= u.km / u.s
+    v *= u.km / u.day
     return r, v


Test patch:
diff --git a/poliastro/tests/test_ephem.py b/poliastro/tests/test_ephem.py
new file mode 100644
index 00000000..ecda97fc
--- /dev/null
+++ b/poliastro/tests/test_ephem.py
@@ -0,0 +1,29 @@
+# coding: utf-8
+import numpy as np
+
+from astropy import time
+from astropy import units as u
+
+from poliastro import ephem
+
+
+class FakeKernel(object):
+    def __getitem__(self, index):
+        return FakeSegment()
+
+
+class FakeSegment(object):
+    def compute_and_differentiate(self, jd1, jd2=None):
+        r = np.array([1, 1, 1])
+        v = np.array([1, 1, 1])
+        return r, v
+
+
+def test_proper_velocity_units():
+    # Bug #49
+    _body = 0
+    _epoch = time.Time("2000-01-01 00:00")
+
+    r, v = ephem.planet_ephem(_body, _epoch, FakeKernel())
+
+    assert v.unit == u.km / u.day