Skip to content

Commit c381801

Browse files
committed
Import BytesIO from io where possible
1 parent 6f58e02 commit c381801

20 files changed

+23
-23
lines changed

nibabel/cifti2/parse_cifti2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from distutils.version import LooseVersion
1212

1313
import numpy as np
14+
from io import BytesIO
1415

1516
from .cifti2 import (Cifti2MetaData, Cifti2Header, Cifti2Label,
1617
Cifti2LabelTable, Cifti2VertexIndices,
@@ -21,7 +22,6 @@
2122
CIFTI_MODEL_TYPES, _underscore, Cifti2HeaderError)
2223
from .. import xmlutils as xml
2324
from ..spatialimages import HeaderDataError
24-
from ..externals.six import BytesIO
2525
from ..batteryrunners import Report
2626
from ..nifti1 import Nifti1Extension, extension_codes, intent_codes
2727
from ..nifti2 import Nifti2Header, Nifti2Image

nibabel/dft.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import numpy
2424

25-
from six import BytesIO
25+
from io import BytesIO
2626

2727
from .nifti1 import Nifti1Header
2828

nibabel/freesurfer/tests/test_mghformat.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
import numpy as np
1515

16-
from six import BytesIO
1716
from .. import load, save
1817
from ...openers import ImageOpener
1918
from ..mghformat import MGHHeader, MGHError, MGHImage
@@ -171,7 +170,7 @@ def test_header_updating():
171170
mgz = load(MGZ_FNAME)
172171
hdr = mgz.header
173172
# Test against mri_info output
174-
exp_aff = np.loadtxt(BytesIO(b"""
173+
exp_aff = np.loadtxt(io.BytesIO(b"""
175174
1.0000 2.0000 3.0000 -13.0000
176175
2.0000 3.0000 1.0000 -11.5000
177176
3.0000 1.0000 2.0000 -11.5000
@@ -182,7 +181,7 @@ def test_header_updating():
182181
assert_equal(hdr['delta'], 1)
183182
assert_almost_equal(hdr['Mdc'], exp_aff[:3, :3].T)
184183
# Save, reload, same thing
185-
img_fobj = BytesIO()
184+
img_fobj = io.BytesIO()
186185
mgz2 = _mgh_rt(mgz, img_fobj)
187186
hdr2 = mgz2.header
188187
assert_almost_equal(hdr2.get_affine(), exp_aff, 6)
@@ -206,7 +205,7 @@ def test_cosine_order():
206205
aff[0] = [2, 1, 0, 10]
207206
img = MGHImage(data, aff)
208207
assert_almost_equal(img.affine, aff, 6)
209-
img_fobj = BytesIO()
208+
img_fobj = io.BytesIO()
210209
img2 = _mgh_rt(img, img_fobj)
211210
hdr2 = img2.header
212211
RZS = aff[:3, :3]

nibabel/spm99analyze.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import warnings
1111
import numpy as np
1212

13-
from six import BytesIO
13+
from io import BytesIO
1414

1515
from .spatialimages import HeaderDataError, HeaderTypeError
1616

nibabel/streamlines/tests/test_streamlines.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from os.path import join as pjoin
77

88
import nibabel as nib
9-
from six import BytesIO
9+
from io import BytesIO
1010
from nibabel.tmpdirs import InTemporaryDirectory
1111

1212
from nibabel.testing import data_path

nibabel/streamlines/tests/test_trk.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import numpy as np
66
from os.path import join as pjoin
77

8-
from six import BytesIO
8+
from io import BytesIO
99

1010
from nibabel.testing import data_path
1111
from nibabel.testing import clear_and_catch_warnings, assert_arr_dict_equal

nibabel/tests/test_arrayproxy.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import warnings
1414

15-
from six import BytesIO
15+
from io import BytesIO
1616
from ..tmpdirs import InTemporaryDirectory
1717

1818
import numpy as np

nibabel/tests/test_arraywriters.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import itertools
1111
import numpy as np
1212

13-
from six import BytesIO
13+
from io import BytesIO
1414
from ..arraywriters import (SlopeInterArrayWriter, SlopeArrayWriter,
1515
WriterError, ScalingError, ArrayWriter,
1616
make_array_writer, get_slope_inter)

nibabel/tests/test_dft.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import os
55
from os.path import join as pjoin, dirname
6-
from six import BytesIO
6+
from io import BytesIO
77
from ..testing import suppress_warnings
88

99
import numpy as np

nibabel/tests/test_fileholders.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
""" Testing fileholders
22
"""
33

4-
from six import BytesIO
4+
from io import BytesIO
55

66

77
from ..fileholders import FileHolder

nibabel/tests/test_files_interface.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import numpy as np
1414

1515
from .. import Nifti1Image, Nifti1Pair, MGHImage, all_image_classes
16-
from six import BytesIO
16+
from io import BytesIO
1717
from ..fileholders import FileHolderError
1818
from ..spatialimages import SpatialImage
1919

nibabel/tests/test_image_load_save.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
99
''' Tests for loader function '''
1010
from __future__ import division, print_function, absolute_import
11-
from six import BytesIO
11+
from io import BytesIO
1212

1313
import shutil
1414
from os.path import dirname, join as pjoin

nibabel/tests/test_nifti1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from nibabel.affines import from_matvec
1919
from nibabel.casting import type_info, have_binary128
2020
from nibabel.eulerangles import euler2mat
21-
from six import BytesIO
21+
from io import BytesIO
2222
from nibabel.nifti1 import (load, Nifti1Header, Nifti1PairHeader, Nifti1Image,
2323
Nifti1Pair, Nifti1Extension, Nifti1DicomExtension,
2424
Nifti1Extensions, data_type_codes, extension_codes,

nibabel/tests/test_round_trip.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import numpy as np
77

8-
from six import BytesIO
8+
from io import BytesIO
99
from .. import Nifti1Image, Nifti1Header
1010
from ..spatialimages import HeaderDataError, supported_np_types
1111
from ..arraywriters import ScalingError

nibabel/tests/test_scaling.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import numpy as np
1313

14-
from six import BytesIO
14+
from io import BytesIO
1515
from ..volumeutils import (calculate_scale, scale_min_max, finite_range,
1616
apply_read_scaling, array_to_file, array_from_file)
1717
from ..casting import type_info

nibabel/tests/test_spatialimages.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import numpy as np
1616

17-
from six import BytesIO
17+
from io import BytesIO
1818
from ..spatialimages import (SpatialHeader, SpatialImage, HeaderDataError,
1919
Header, ImageDataError)
2020

nibabel/tests/test_spm99analyze.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import numpy as np
1111
import itertools
1212

13-
from six import BytesIO
13+
from io import BytesIO
1414

1515
from numpy.testing import assert_array_equal, assert_array_almost_equal, dec
1616

nibabel/tests/test_trackvis.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import numpy as np
77

8-
from six import BytesIO
8+
from io import BytesIO
99
from .. import trackvis as tv
1010
from ..orientations import aff2axcodes
1111
from ..volumeutils import native_code, swapped_code

nibabel/tests/test_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import os
1313
from os.path import exists
1414

15-
from six import BytesIO
15+
from io import BytesIO
1616
import tempfile
1717
import warnings
1818
import functools

nibabel/tests/test_wrapstruct.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
import logging
2727
import numpy as np
2828

29-
from six import BytesIO, StringIO
29+
from io import BytesIO
30+
from six import StringIO
3031
from ..wrapstruct import WrapStructError, WrapStruct, LabeledWrapStruct
3132
from ..batteryrunners import Report
3233

0 commit comments

Comments
 (0)