From 9b2d3b1fe2aaa0566a041bd480e5c3d2f03329bb Mon Sep 17 00:00:00 2001
From: Michiel Cottaar <MichielCottaar@gmail.com>
Date: Tue, 14 May 2019 16:08:40 +0100
Subject: [PATCH] ENH: create string representations

makes the output
---
 fsl/data/atlases.py   | 17 ++++++++++++++++-
 tests/test_atlases.py |  2 ++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/fsl/data/atlases.py b/fsl/data/atlases.py
index 6ec39a897..e2b89d06b 100644
--- a/fsl/data/atlases.py
+++ b/fsl/data/atlases.py
@@ -366,6 +366,15 @@ class AtlasLabel(object):
         """
         return self.index < other.index
 
+    def __repr__(self):
+        """
+        Represents AtlasLabel as string
+        """
+        return '{}({}, index={}, value={})'.format(
+                self.__class__.__name__, self.name,
+                self.index, self.value,
+        )
+
 
 class AtlasDescription(object):
     """An ``AtlasDescription`` instance parses and stores the information
@@ -574,7 +583,7 @@ class AtlasDescription(object):
         self.labels = list(sorted(self.labels))
 
 
-    def find(self, index=None, value=None):
+    def find(self, index=None, value=None, name=None):
         """Find an :class:`.AtlasLabel` either by ``index``, or by ``value``.
 
         Exactly one of ``index`` or ``value`` may be specified - a
@@ -612,6 +621,12 @@ class AtlasDescription(object):
         """
         return self.name.lower() < other.name.lower()
 
+    def __repr__(self, ):
+        """
+        String representation of AtlasDescription
+        """
+        return '{}({})'.format(self.__class__.__name__, self.atlasID)
+
 
 class Atlas(fslimage.Image):
     """This is the base class for the :class:`LabelAtlas` and
diff --git a/tests/test_atlases.py b/tests/test_atlases.py
index c2d257f60..a30cb0919 100644
--- a/tests/test_atlases.py
+++ b/tests/test_atlases.py
@@ -99,6 +99,8 @@ def test_AtlasDescription():
     tal  = registry.getAtlasDescription('talairach')
     cort = registry.getAtlasDescription('harvardoxford-cortical')
 
+    assert str(tal) == 'AtlasDescription(talairach)'
+    assert str(cort) == 'AtlasDescription(harvardoxford-cortical)'
 
     assert tal.atlasID == 'talairach'
     assert tal.name    == 'Talairach Daemon Labels'
-- 
GitLab