File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 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):
330330
331331 return data_array
332332
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+
333361 def print_summary (self ):
334362 print ('Intent: ' , intent_codes .niistring [self .intent ])
335363 print ('DataType: ' , data_type_codes .niistring [self .datatype ])
Original file line number Diff line number Diff line change 44
55import numpy as np
66
7+ from nibabel .externals .six import string_types
78from nibabel .gifti import (GiftiImage , GiftiDataArray , GiftiLabel ,
89 GiftiLabelTable , GiftiMetaData , giftiio )
910from nibabel .gifti .gifti import data_tag
@@ -70,6 +71,17 @@ def test_dataarray():
7071 da = GiftiDataArray .from_array (bs_arr , 'triangle' )
7172 assert_equal (da .datatype , data_type_codes [arr .dtype ])
7273
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+
7385
7486def test_labeltable ():
7587 img = GiftiImage ()
You can’t perform that action at this time.
0 commit comments