Skip to content

Commit

Permalink
WIP: extend ExtraCoord str with physical type info, line breaks
Browse files Browse the repository at this point in the history
  • Loading branch information
dhomeier committed Aug 4, 2021
1 parent 196daeb commit 977ff06
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ndcube/extra_coords/extra_coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,16 @@ def dropped_world_dimensions(self):
return dict()

def __str__(self):
elements = [f"{', '.join(table.names)} ({axes}): {table}" for axes, table in self._lookup_tables]
return f"ExtraCoords({', '.join(elements)})"
classname = self.__class__.__name__
elements = [f"{', '.join(table.names)} ({axes}) {table.physical_types}: {table}"
for axes, table in self._lookup_tables]
length = len(classname) + 2 * len(elements) + sum(len(e) for e in elements)
if length > np.get_printoptions()['linewidth']:
joiner = ',\n ' + len(classname) * ' '
else:
joiner = ', '

return f"{classname}({joiner.join(elements)})"

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

0 comments on commit 977ff06

Please sign in to comment.