Skip to content

Commit f70961a

Browse files
committed
Merge pull request #352 from bcipolli/gifti_fix
MRG: getArraysFromIntent => get_arrays_from_intent GIFTI has a function in CamelCase, not snake_case. Deprecate that.
2 parents ec7926a + e6590b3 commit f70961a

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

nibabel/gifti/gifti.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,14 +444,18 @@ def remove_gifti_data_array_by_intent(self, intent):
444444
self.darrays.remove(dele)
445445
self.numDA -= 1
446446

447-
def getArraysFromIntent(self, intent):
447+
def get_arrays_from_intent(self, intent):
448448
""" Returns a a list of GiftiDataArray elements matching
449449
the given intent """
450450

451451
it = intent_codes.code[intent]
452452

453453
return [x for x in self.darrays if x.intent == it]
454454

455+
@np.deprecate_with_doc("Use get_arrays_from_intent instead.")
456+
def getArraysFromIntent(self, intent):
457+
return self.get_arrays_from_intent(intent)
458+
455459
def print_summary(self):
456460
print('----start----')
457461
print('Source filename: ', self.filename)

nibabel/gifti/tests/test_giftiio.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from os.path import join as pjoin, dirname
1212
import sys
13+
import warnings
1314

1415
import numpy as np
1516

@@ -23,6 +24,7 @@
2324

2425
from nose.tools import (assert_true, assert_false, assert_equal,
2526
assert_raises)
27+
from ...testing import clear_and_catch_warnings
2628

2729

2830
IO_DATA_PATH = pjoin(dirname(__file__), 'data')
@@ -227,11 +229,21 @@ def test_newmetadata():
227229

228230
def test_getbyintent():
229231
img = gi.read(DATA_FILE1)
230-
da = img.getArraysFromIntent("NIFTI_INTENT_POINTSET")
232+
233+
da = img.get_arrays_from_intent("NIFTI_INTENT_POINTSET")
231234
assert_equal(len(da), 1)
232-
da = img.getArraysFromIntent("NIFTI_INTENT_TRIANGLE")
235+
236+
with clear_and_catch_warnings() as w:
237+
warnings.filterwarnings('once', category=DeprecationWarning)
238+
da = img.getArraysFromIntent("NIFTI_INTENT_POINTSET")
239+
assert_equal(len(da), 1)
240+
assert_equal(len(w), 1)
241+
assert_equal(w[0].category, DeprecationWarning)
242+
243+
da = img.get_arrays_from_intent("NIFTI_INTENT_TRIANGLE")
233244
assert_equal(len(da), 1)
234-
da = img.getArraysFromIntent("NIFTI_INTENT_CORREL")
245+
246+
da = img.get_arrays_from_intent("NIFTI_INTENT_CORREL")
235247
assert_equal(len(da), 0)
236248
assert_equal(da, [])
237249

0 commit comments

Comments
 (0)