mirror of
https://github.com/cosinekitty/astronomy.git
synced 2026-05-19 06:17:03 -04:00
Make demo tests less sensitive to tiny floating point errors.
More work getting MacOS build process to work. Avoid excessive number of floating point digits of output in the demo tests, so that insignificant floating point variations don't cause unit test failures.
This commit is contained in:
@@ -829,6 +829,11 @@ The vector also includes a time stamp.
|
||||
|
||||
Returns the length of the vector in AU.
|
||||
|
||||
<a name="Vector.format"></a>
|
||||
### Vector.format(self, coord_format)
|
||||
|
||||
Returns a custom format string representation of the vector.
|
||||
|
||||
---
|
||||
|
||||
<a name="enumerations"></a>
|
||||
|
||||
@@ -170,6 +170,11 @@ class Vector:
|
||||
def __sub__(self, other):
|
||||
return Vector(self.x - other.x, self.y - other.y, self.z - other.z, self.t)
|
||||
|
||||
def format(self, coord_format):
|
||||
"""Returns a custom format string representation of the vector."""
|
||||
layout = '({:' + coord_format + '}, {:' + coord_format + '}, {:' + coord_format + '}, {})'
|
||||
return layout.format(self.x, self.y, self.z, str(self.t))
|
||||
|
||||
class StateVector:
|
||||
"""A combination of a position vector, a velocity vector, and a time.
|
||||
|
||||
@@ -758,10 +763,10 @@ class Observer:
|
||||
def __str__(self):
|
||||
text = '('
|
||||
text += 'S' if (self.latitude < 0) else 'N'
|
||||
text += '{}, '.format(abs(self.latitude))
|
||||
text += '{:0.8f}, '.format(abs(self.latitude))
|
||||
text += 'W' if (self.longitude < 0) else 'E'
|
||||
text += '{}, '.format(abs(self.longitude))
|
||||
text += '{}m'.format(self.height)
|
||||
text += '{:0.8f}, '.format(abs(self.longitude))
|
||||
text += '{:0.3f}m'.format(self.height)
|
||||
text += ')'
|
||||
return text
|
||||
|
||||
|
||||
Reference in New Issue
Block a user