File tree 2 files changed +40
-0
lines changed 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -330,6 +330,34 @@ def _to_xml_element(self):
330
330
331
331
return data_array
332
332
333
+ @np .deprecate_with_doc ("Use the to_xml() function instead." )
334
+ def to_xml_open (self ):
335
+ out = """<DataArray Intent="%s"
336
+ \t DataType="%s"
337
+ \t ArrayIndexingOrder="%s"
338
+ \t Dimensionality="%s"
339
+ %s\t Encoding="%s"
340
+ \t Endian="%s"
341
+ \t ExternalFileName="%s"
342
+ \t ExternalFileOffset="%s">\n """
343
+ di = ""
344
+ for i , n in enumerate (self .dims ):
345
+ di = di + '\t Dim%s=\" %s\" \n ' % (str (i ), str (n ))
346
+ return out % (intent_codes .niistring [self .intent ],
347
+ data_type_codes .niistring [self .datatype ],
348
+ array_index_order_codes .label [self .ind_ord ],
349
+ str (self .num_dim ),
350
+ str (di ),
351
+ gifti_encoding_codes .specs [self .encoding ],
352
+ gifti_endian_codes .specs [self .endian ],
353
+ self .ext_fname ,
354
+ self .ext_offset ,
355
+ )
356
+
357
+ @np .deprecate_with_doc ("Use the to_xml() function instead." )
358
+ def to_xml_close (self ):
359
+ return "</DataArray>\n "
360
+
333
361
def print_summary (self ):
334
362
print ('Intent: ' , intent_codes .niistring [self .intent ])
335
363
print ('DataType: ' , data_type_codes .niistring [self .datatype ])
Original file line number Diff line number Diff line change 4
4
5
5
import numpy as np
6
6
7
+ from nibabel .externals .six import string_types
7
8
from nibabel .gifti import (GiftiImage , GiftiDataArray , GiftiLabel ,
8
9
GiftiLabelTable , GiftiMetaData , giftiio )
9
10
from nibabel .gifti .gifti import data_tag
@@ -70,6 +71,17 @@ def test_dataarray():
70
71
da = GiftiDataArray .from_array (bs_arr , 'triangle' )
71
72
assert_equal (da .datatype , data_type_codes [arr .dtype ])
72
73
74
+ # Smoke test on deprecated functions
75
+ da = GiftiDataArray .from_array (np .ones ((1 ,)), 'triangle' )
76
+ with clear_and_catch_warnings () as w :
77
+ warnings .filterwarnings ('always' , category = DeprecationWarning )
78
+ assert_true (isinstance (da .to_xml_open (), string_types ))
79
+ assert_equal (len (w ), 1 )
80
+ with clear_and_catch_warnings () as w :
81
+ warnings .filterwarnings ('once' , category = DeprecationWarning )
82
+ assert_true (isinstance (da .to_xml_close (), string_types ))
83
+ assert_equal (len (w ), 1 )
84
+
73
85
74
86
def test_labeltable ():
75
87
img = GiftiImage ()
You can’t perform that action at this time.
0 commit comments