Skip to content

Commit d6e09de

Browse files
author
Ben Cipollini
committed
ValueError=>TypeError
1 parent 307a328 commit d6e09de

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

nibabel/gifti/gifti.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ def rgba(self, rgba):
155155
raise ValueError('rgba must be length 4.')
156156
self.red, self.green, self.blue, self.alpha = rgba
157157

158+
158159
def _arr2txt(arr, elem_fmt):
159160
arr = np.asarray(arr)
160161
assert arr.dtype.names is None
@@ -404,7 +405,7 @@ def labeltable(self, labeltable):
404405
405406
"""
406407
if not isinstance(labeltable, GiftiLabelTable):
407-
raise ValueError("Not a valid GiftiLabelTable instance")
408+
raise TypeError("Not a valid GiftiLabelTable instance")
408409
self._labeltable = labeltable
409410

410411
@np.deprecate_with_doc("Use the gifti_img.labeltable property instead.")
@@ -432,7 +433,7 @@ def meta(self, meta):
432433
None
433434
"""
434435
if not isinstance(meta, GiftiMetaData):
435-
raise ValueError("Not a valid GiftiMetaData instance")
436+
raise TypeError("Not a valid GiftiMetaData instance")
436437
self._meta = meta
437438

438439
@np.deprecate_with_doc("Use the gifti_img.labeltable property instead.")
@@ -450,10 +451,9 @@ def add_gifti_data_array(self, dataarr):
450451
----------
451452
dataarr : GiftiDataArray
452453
"""
453-
if isinstance(dataarr, GiftiDataArray):
454-
self.darrays.append(dataarr)
455-
else:
456-
raise ValueError("dataarr paramater must be of type GiftiDataArray")
454+
if not isinstance(dataarr, GiftiDataArray):
455+
raise TypeError("dataarr paramater must be of type GiftiDataArray")
456+
self.darrays.append(dataarr)
457457

458458
def remove_gifti_data_array(self, ith):
459459
""" Removes the ith data array element from the GiftiImage """

nibabel/gifti/tests/test_gifti.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def test_labeltable():
8383
# Try to set to non-table
8484
def assign_labeltable(val):
8585
img.labeltable = val
86-
assert_raises(ValueError, assign_labeltable, 'not-a-table')
86+
assert_raises(TypeError, assign_labeltable, 'not-a-table')
8787

8888

8989
def test_metadata():
@@ -156,4 +156,4 @@ def test_gifti_image():
156156
assert_true(img.meta is not None)
157157
assert_true(img.labeltable is not None)
158158

159-
assert_raises(ValueError, img.add_gifti_data_array, 'not-a-data-array')
159+
assert_raises(TypeError, img.add_gifti_data_array, 'not-a-data-array')

0 commit comments

Comments
 (0)