Skip to content

Commit

Permalink
Add fields to __repr__
Browse files Browse the repository at this point in the history
  • Loading branch information
robjmcgibbon committed Nov 18, 2024
1 parent 2b5ea76 commit ae9d889
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions swiftsimio/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,17 @@ def generate_empty_properties(self):

return

def __str__(self):
"""
Prints out some more useful information, rather than just
the memory location.
"""
field_names = ", ".join(self.group_metadata.field_names)
return f"SWIFT dataset at {self.filename}. \nAvailable fields: {field_names}"

def __repr__(self):
return self.__str__()


class __SWIFTNamedColumnDataset(object):
"""
Expand Down Expand Up @@ -572,8 +583,8 @@ def __str__(self):
Prints out some more useful information, rather than just
the memory location.
"""

return f"SWIFT dataset at {self.filename}."
group_names = ", ".join(self.metadata.present_group_names)
return f"SWIFT dataset at {self.filename}. \nAvailable groups: {group_names}"

def __repr__(self):
return self.__str__()
Expand Down

0 comments on commit ae9d889

Please sign in to comment.