Skip to content

Commit

Permalink
Fix #161 by reordering names in vector subtraction
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon-rhodes committed Mar 3, 2018
1 parent 98edd53 commit a6f73b7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Changelog

.. currentmodule:: skyfield.positionlib

* Issues fixed:
`#161 <https://github.com/skyfielders/python-skyfield/issues/161>`_

1.1 — 2018 January 14
---------------------

Expand Down
2 changes: 2 additions & 0 deletions skyfield/jpllib.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ def __init__(self, ephemeris, spk_segment):
self.ephemeris = ephemeris
self.center = spk_segment.center
self.target = spk_segment.target
# self.center_name = _format_code_and_name(self.center)
# self.target_name = _format_code_and_name(self.target)
self.spk_segment = spk_segment

def __str__(self):
Expand Down
7 changes: 6 additions & 1 deletion skyfield/tests/test_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def test_vectors():

planets = load('de421.bsp')
earth = planets['earth']
moon = planets['moon']
mars = planets['mars']

v = earth
Expand All @@ -33,6 +32,9 @@ def test_vectors():
+ Segment 'de421.bsp' 0 SOLAR SYSTEM BARYCENTER -> 3 EARTH BARYCENTER
+ Segment 'de421.bsp' 3 EARTH BARYCENTER -> 399 EARTH"""

assert repr(v) == "\
<VectorSum of 2 vectors 0 SOLAR SYSTEM BARYCENTER -> 399 EARTH>"

assert str(v.at(t)) == "\
<Barycentric position and velocity at date t center=0 target=399>"

Expand All @@ -45,5 +47,8 @@ def test_vectors():
+ Segment 'de421.bsp' 0 SOLAR SYSTEM BARYCENTER -> 3 EARTH BARYCENTER
+ Segment 'de421.bsp' 3 EARTH BARYCENTER -> 399 EARTH"""

assert repr(v) == "\
<VectorSum of 4 vectors 499 MARS -> 399 EARTH>"

assert str(v.at(t)) == "\
<Geometric position and velocity at date t center=499 target=399>"
2 changes: 1 addition & 1 deletion skyfield/vectorlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __sub__(self, other):
othern = getattr(other, 'negatives', ())

return VectorSum(other.target, self.target,
self.target_name, other.target_name,
other.target_name, self.target_name,
selfp + othern, selfn + otherp)

@raise_error_for_deprecated_time_arguments
Expand Down

0 comments on commit a6f73b7

Please sign in to comment.