File tree Expand file tree Collapse file tree 2 files changed +47
-9
lines changed
Expand file tree Collapse file tree 2 files changed +47
-9
lines changed Original file line number Diff line number Diff line change 1010# Stephan Gerhard, Oktober 2010
1111##############
1212
13- import os
14- import codecs
13+ import warnings
1514
16- from . parse_gifti_fast import parse_gifti_file
15+ import numpy as np
1716
1817
18+ warnings .warn ('Please use nibabel.load/save.' , DeprecationWarning )
19+
20+
21+ @np .deprecate_with_doc ("Use nibabel.load() instead." )
1922def read (filename ):
2023 """ Load a Gifti image from a file
2124
@@ -29,11 +32,11 @@ def read(filename):
2932 img : GiftiImage
3033 Returns a GiftiImage
3134 """
32- if not os .path .isfile (filename ):
33- raise IOError ("No such file or directory: '%s'" % filename )
34- return parse_gifti_file (filename )
35+ from ..loadsave import load
36+ return load (filename )
3537
3638
39+ @np .deprecate_with_doc ("Use nibabel.save() instead." )
3740def write (image , filename ):
3841 """ Save the current image to a new file
3942
@@ -79,6 +82,6 @@ def write(image, filename):
7982
8083 The Gifti file is stored in endian convention of the current machine.
8184 """
82- # Our giftis are always utf-8 encoded - see GiftiImage.to_xml
83- with open ( filename , 'wb' ) as f :
84- f . write ( image . to_xml ())
85+ from .. loadsave import save
86+ return save ( image , filename )
87+
Original file line number Diff line number Diff line change 1+ # emacs: -*- mode: python-mode; py-indent-offset: 4; indent-tabs-mode: nil -*-
2+ # vi: set ft=python sts=4 ts=4 sw=4 et:
3+ ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
4+ #
5+ # See COPYING file distributed along with the NiBabel package for the
6+ # copyright and license terms.
7+ #
8+ ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
9+
10+ import warnings
11+
12+ from nose .tools import (assert_true , assert_false , assert_equal ,
13+ assert_raises )
14+ from ...testing import clear_and_catch_warnings
15+
16+
17+ from .test_parse_gifti_fast import (DATA_FILE1 , DATA_FILE2 , DATA_FILE3 ,
18+ DATA_FILE4 , DATA_FILE5 , DATA_FILE6 )
19+
20+
21+ class TestGiftiIO (object ):
22+ def setUp (self ):
23+ with clear_and_catch_warnings () as w :
24+ warnings .simplefilter ('always' , DeprecationWarning )
25+ import nibabel .gifti .giftiio
26+ assert_equal (len (w ), 1 )
27+
28+
29+ def test_read_deprecated ():
30+ with clear_and_catch_warnings () as w :
31+ warnings .simplefilter ('always' , DeprecationWarning )
32+ from nibabel .gifti .giftiio import read
33+
34+ img = read (DATA_FILE1 )
35+ assert_equal (len (w ), 1 )
You can’t perform that action at this time.
0 commit comments