Skip to content

Commit 48d7bdc

Browse files
author
Ben Cipollini
committed
TST: add gifti string and MetaData tests.
1 parent af1bbca commit 48d7bdc

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

nibabel/gifti/tests/test_gifti.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import nibabel as nib
88
from nibabel.externals.six import string_types
99
from nibabel.gifti import (GiftiImage, GiftiDataArray, GiftiLabel,
10-
GiftiLabelTable, GiftiMetaData)
10+
GiftiLabelTable, GiftiMetaData, GiftiNVPairs)
1111
from nibabel.gifti.gifti import data_tag
1212
from nibabel.nifti1 import data_type_codes
1313

@@ -34,15 +34,24 @@ def test_gifti_image():
3434
gi = GiftiImage()
3535
assert_equal(gi.numDA, 0)
3636

37+
# Test from numpy numeric array
3738
data = np.random.random((5,))
3839
da = GiftiDataArray.from_array(data)
3940
gi.add_gifti_data_array(da)
4041
assert_equal(gi.numDA, 1)
4142
assert_array_equal(gi.darrays[0].data, data)
4243

44+
# Test removing
4345
gi.remove_gifti_data_array(0)
4446
assert_equal(gi.numDA, 0)
4547

48+
# Test from string
49+
da = GiftiDataArray.from_array('zzzzz')
50+
gi.add_gifti_data_array(da)
51+
assert_equal(gi.numDA, 1)
52+
assert_array_equal(gi.darrays[0].data, data)
53+
54+
4655
# Remove from empty
4756
gi = GiftiImage()
4857
gi.remove_gifti_data_array_by_intent(0)
@@ -108,6 +117,13 @@ def test_metadata():
108117
assert_equal(len(w), 1)
109118

110119

120+
def test_metadata():
121+
nvpair = GiftiNVPairs('key', 'value')
122+
da = GiftiMetaData(nvpair=nvpair)
123+
assert_equal(da.data[0].name, 'key')
124+
assert_equal(da.data[0].value, 'value')
125+
126+
111127
def test_gifti_label_rgba():
112128
rgba = np.random.rand(4)
113129
kwargs = dict(zip(['red', 'green', 'blue', 'alpha'], rgba))

0 commit comments

Comments
 (0)