Browse Source

added Label.__repr__()

Fabian Peter Hammerle 5 years ago
parent
commit
34358715d0
2 changed files with 14 additions and 0 deletions
  1. 3 0
      freesurfer_surface/__init__.py
  2. 11 0
      tests/test_label.py

+ 3 - 0
freesurfer_surface/__init__.py

@@ -113,6 +113,9 @@ class Label:
         return 'Label(name={}, index={}, color={})'.format(
             self.name, self.index, self.hex_color_code)
 
+    def __repr__(self) -> str:
+        return str(self)
+
 
 class Annotation:
 

+ 11 - 0
tests/test_label.py

@@ -59,3 +59,14 @@ def test_str():
     label.blue = 220
     label.transparency = 0
     assert str(label) == 'Label(name=precentral, index=24, color=#3c14dc)'
+
+
+def test_repr():
+    label = Label()
+    label.index = 24
+    label.name = 'precentral'
+    label.red = 60
+    label.green = 20
+    label.blue = 220
+    label.transparency = 0
+    assert repr(label) == 'Label(name=precentral, index=24, color=#3c14dc)'