Skip to content

Commit

Permalink
python 3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
rutgerfick committed Feb 19, 2018
1 parent d2f8465 commit 523ca4e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 5 additions & 2 deletions dmipy/data/saved_acquisition_schemes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
from os.path import join
import os
import pkg_resources
from urllib import urlopen
from ..core.acquisition_scheme import (
acquisition_scheme_from_bvalues,
acquisition_scheme_from_gradient_strengths,
acquisition_scheme_from_schemefile)
try:
from urllib2 import urlopen
except ImportError:
from urllib.request import urlopen

_GRADIENT_TABLES_PATH = pkg_resources.resource_filename(
'dmipy', 'data/gradient_tables'
Expand Down Expand Up @@ -83,7 +86,7 @@ def isbi2015_white_matter_challenge_scheme():

response = urlopen(path_schemefile)
data = response.read()
file_ = open(join(isbi_data_path, filename), 'w')
file_ = open(join(isbi_data_path, filename), 'wb')
file_.write(data)
file_.close()

Expand Down
9 changes: 7 additions & 2 deletions dmipy/data/saved_data.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
from os.path import join
import os
from urllib import urlopen
import pkg_resources
import nibabel as nib
import numpy as np
from scipy.stats import pearsonr
import matplotlib.pyplot as plt
from . import saved_acquisition_schemes

try:
from urllib2 import urlopen
except ImportError:
from urllib.request import urlopen

DATA_PATH = pkg_resources.resource_filename(
'dmipy', 'data'
)
Expand Down Expand Up @@ -167,7 +172,7 @@ def isbi2015_white_matter_challenge():
for filename, path in zip(filenames, paths):
response = urlopen(path)
data = response.read()
file_ = open(join(isbi_data_path, filename), 'w')
file_ = open(join(isbi_data_path, filename), 'wb')
file_.write(data)
file_.close()

Expand Down

0 comments on commit 523ca4e

Please sign in to comment.