Skip to content

Commit

Permalink
str function for mapbase
Browse files Browse the repository at this point in the history
  • Loading branch information
sidhu1012 committed Sep 11, 2020
1 parent 532e5ab commit 1b3b911
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion sunpy/map/mapbase.py
Expand Up @@ -254,8 +254,11 @@ def _text_summary(self):
self._reference_latitude)),
tmf=TIME_FORMAT)

def __str__(self):
return object.__str__(self) + "\n" + self._text_summary() + "\n" + self.data.__str__()

def __repr__(self):
return object.__repr__(self) + "\n" + self._text_summary() + "\n" + self.data.__repr__()
return f"{object.__repr__(self)}\n{self}"

def _repr_html_(self):
"""
Expand Down
6 changes: 5 additions & 1 deletion sunpy/map/tests/test_mapbase.py
Expand Up @@ -890,7 +890,7 @@ def test_bad_coordframe_repr(generic_map):
generic_map.meta['CTYPE2'] = "STUART2"
with pytest.warns(UserWarning,
match="Could not determine coordinate frame from map metadata"):
assert 'Unknown' in generic_map.__repr__()
assert 'Unknown' in generic_map.__str__()


def test_bad_header_final_fallback():
Expand Down Expand Up @@ -1101,3 +1101,7 @@ def test_contour(simple_map):
assert contour.obstime == simple_map.date
assert u.allclose(contour.Tx, [0, -1, 0, 1, 0] * u.arcsec, atol=1e-10 * u.arcsec)
assert u.allclose(contour.Ty, [0.5, 0, -0.5, 0, 0.5] * u.arcsec, atol=1e-10 * u.arcsec)

def print_map(generic_map):
out = generic_map.__repr__()
assert isinstance(out, str)

0 comments on commit 1b3b911

Please sign in to comment.