Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions doc/source/devel/register_me.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from os.path import join as pjoin, expanduser, abspath, dirname
import sys
# Python 3 compatibility
try:
import configparser as cfp
except ImportError:
import ConfigParser as cfp
import configparser as cfp


if sys.platform == 'win32':
HOME_INI = pjoin(expanduser('~'), '_dpkg', 'local.dsource')
Expand All @@ -15,6 +12,7 @@
OUR_META = pjoin(OUR_PATH, 'meta.ini')
DISCOVER_INIS = {'user': HOME_INI, 'system': SYS_INI}


def main():
# Get ini file to which to write
try:
Expand All @@ -23,7 +21,7 @@ def main():
reg_to = 'user'
if reg_to in ('user', 'system'):
ini_fname = DISCOVER_INIS[reg_to]
else: # it is an ini file name
else: # it is an ini file name
ini_fname = reg_to

# Read parameters for our distribution
Expand All @@ -42,7 +40,7 @@ def main():
dsource.set(name, version, OUR_PATH)
dsource.write(file(ini_fname, 'wt'))

print 'Registered package %s, %s to %s' % (name, version, ini_fname)
print('Registered package %s, %s to %s' % (name, version, ini_fname))


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion nibabel/arrayproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class ArrayProxy(object):
* get_slope_inter

A header should also have a 'copy' method. This requirement will go away
when the deprecated 'header' propoerty goes away.
when the deprecated 'header' property goes away.

This implementation allows us to deal with Analyze and its variants,
including Nifti1, and with the MGH format.
Expand Down
2 changes: 1 addition & 1 deletion nibabel/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def __init__(self, base_path, config_filename=None):
Datasource.__init__(self, base_path)
if config_filename is None:
config_filename = 'config.ini'
self.config = configparser.SafeConfigParser()
self.config = configparser.ConfigParser()
cfg_file = self.get_filename(config_filename)
readfiles = self.config.read(cfg_file)
if not readfiles:
Expand Down
2 changes: 1 addition & 1 deletion nibabel/ecat.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ def get_shape(self, frame=0):
x = subhdr['x_dimension'].item()
y = subhdr['y_dimension'].item()
z = subhdr['z_dimension'].item()
return (x, y, z)
return x, y, z

def get_nframes(self):
"""returns number of frames"""
Expand Down
18 changes: 9 additions & 9 deletions nibabel/tests/test_round_trip.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def check_arr(test_id, V_in, in_type, out_type, scaling_type):
rel_err = np.abs(top / arr)
abs_err = np.abs(top)
if slope == 1: # integers output, offset only scaling
if set((in_type, out_type)) == set((np.int64, np.uint64)):
if {in_type, out_type} == {np.int64, np.uint64}:
# Scaling to or from 64 bit ints can go outside range of continuous
# integers for float64 and thus lose precision; take this into
# account
Expand Down Expand Up @@ -181,14 +181,14 @@ def check_arr(test_id, V_in, in_type, out_type, scaling_type):
rel_mx_e = rel_err[abs_fails].max()
else:
rel_mx_e = None
print (test_id,
np.dtype(in_type).str,
np.dtype(out_type).str,
exp_abs_mx_e,
abs_mx_e,
rel_thresh,
rel_mx_e,
slope, inter)
print(test_id,
np.dtype(in_type).str,
np.dtype(out_type).str,
exp_abs_mx_e,
abs_mx_e,
rel_thresh,
rel_mx_e,
slope, inter)
# To help debugging failures with --pdb-failure
np.nonzero(all_fails)
assert this_test
17 changes: 5 additions & 12 deletions nisext/sexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,16 @@

import os
from os.path import join as pjoin, split as psplit, splitext
import sys
PY3 = sys.version_info[0] >= 3
if PY3:
string_types = str,
else:
string_types = basestring,
try:
from ConfigParser import ConfigParser
except ImportError:
from configparser import ConfigParser

from configparser import ConfigParser

from distutils.version import LooseVersion
from distutils.command.build_py import build_py
from distutils.command.install_scripts import install_scripts

from distutils import log


def get_comrec_build(pkg_dir, build_cmd=build_py):
""" Return extended build command class for recording commit

Expand Down Expand Up @@ -82,7 +75,7 @@ def _add_append_key(in_dict, key, value):
# Append value to in_dict[key] list
if key not in in_dict:
in_dict[key] = []
elif isinstance(in_dict[key], string_types):
elif isinstance(in_dict[key], str):
in_dict[key] = [in_dict[key]]
in_dict[key].append(value)

Expand Down Expand Up @@ -179,7 +172,7 @@ def version_getter(pkg_name):
+ msgs['opt suffix'])
return
# setuptools mode
if optional_tf and not isinstance(optional, string_types):
if optional_tf and not isinstance(optional, str):
raise RuntimeError('Not-False optional arg should be string')
dependency = pkg_name
if version:
Expand Down
7 changes: 4 additions & 3 deletions tools/bisect_nose.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
GOOD = 0
BAD = 1


def call_or_untestable(cmd):
try:
caller(cmd)
Expand All @@ -77,16 +78,16 @@ def main():
args = parser.parse_args()
path = os.path.abspath(args.test_path)
if args.clean:
print "Cleaning"
print("Cleaning")
call_or_untestable('git clean -fxd')
if args.build:
print "Building"
print("Building")
call_or_untestable('python setup.py build_ext -i')
cwd = os.getcwd()
tmpdir = tempfile.mkdtemp()
try:
os.chdir(tmpdir)
print "Testing"
print("Testing")
proc = popener('nosetests ' + path)
stdout, stderr = proc.communicate()
finally:
Expand Down
2 changes: 1 addition & 1 deletion tools/gitwash_dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def copy_replace(replace_pairs,
for rep_glob in rep_globs:
fnames += fnmatch.filter(out_fnames, rep_glob)
if verbose:
print '\n'.join(fnames)
print('\n'.join(fnames))
for fname in fnames:
filename_search_replace(replace_pairs, fname, False)
for in_exp, out_exp in renames:
Expand Down
10 changes: 3 additions & 7 deletions versioneer.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,7 @@

"""

from __future__ import print_function
try:
import configparser
except ImportError:
import ConfigParser as configparser
import configparser
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While these are valid updates, I'm disinclined to change versioneer except for functional fixes, to keep any diffs focused.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, what about the changes after the imports? They are deprecated in py3.6

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. Let's go ahead with these changes, then.

import errno
import json
import os
Expand Down Expand Up @@ -340,9 +336,9 @@ def get_config_from_root(root):
# configparser.NoOptionError (if it lacks "VCS="). See the docstring at
# the top of versioneer.py for instructions on writing your setup.cfg .
setup_cfg = os.path.join(root, "setup.cfg")
parser = configparser.SafeConfigParser()
parser = configparser.ConfigParser()
with open(setup_cfg, "r") as f:
parser.readfp(f)
parser.read_file(f)
VCS = parser.get("versioneer", "VCS") # mandatory

def get(parser, name):
Expand Down