From 831061de61e8bcdcb6901606afef049ab5ad99e2 Mon Sep 17 00:00:00 2001 From: Dorota Jarecka Date: Sun, 11 Dec 2016 17:47:37 -0500 Subject: [PATCH] removing trailing spaces --- nipype/algorithms/confounds.py | 2 +- nipype/algorithms/tests/test_compcor.py | 2 +- nipype/algorithms/tests/test_mesh_ops.py | 18 ++++++++--------- nipype/algorithms/tests/test_modelgen.py | 4 ++-- nipype/algorithms/tests/test_overlap.py | 2 +- .../freesurfer/tests/test_preprocess.py | 2 +- nipype/interfaces/fsl/tests/test_base.py | 16 +++++++-------- nipype/interfaces/fsl/tests/test_dti.py | 16 +++++++-------- nipype/interfaces/fsl/tests/test_epi.py | 2 +- nipype/interfaces/fsl/tests/test_maths.py | 18 ++++++++--------- .../interfaces/fsl/tests/test_preprocess.py | 20 +++++++++---------- nipype/interfaces/fsl/tests/test_utils.py | 18 ++++++++--------- nipype/interfaces/spm/tests/test_base.py | 2 +- .../interfaces/spm/tests/test_preprocess.py | 10 +++++----- nipype/interfaces/tests/test_base.py | 14 ++++++------- nipype/interfaces/tests/test_io.py | 8 ++++---- nipype/interfaces/tests/test_nilearn.py | 2 +- nipype/interfaces/tests/test_utility.py | 14 ++++++------- nipype/pipeline/engine/tests/test_engine.py | 12 +++++------ nipype/pipeline/engine/tests/test_join.py | 4 ++-- nipype/pipeline/engine/tests/test_utils.py | 2 +- nipype/pipeline/plugins/tests/test_base.py | 2 +- .../pipeline/plugins/tests/test_callback.py | 6 +++--- .../pipeline/plugins/tests/test_multiproc.py | 2 +- nipype/utils/tests/test_cmd.py | 6 +++--- nipype/utils/tests/test_filemanip.py | 8 ++++---- 26 files changed, 106 insertions(+), 106 deletions(-) diff --git a/nipype/algorithms/confounds.py b/nipype/algorithms/confounds.py index 51a226d4c8..2905da0fd9 100644 --- a/nipype/algorithms/confounds.py +++ b/nipype/algorithms/confounds.py @@ -668,7 +668,7 @@ def compute_dvars(in_file, in_mask, remove_zerovariance=False): warnings.filterwarnings('error') # voxelwise standardization - diff_vx_stdz = func_diff / np.array([diff_sdhat] * func_diff.shape[-1]).T + diff_vx_stdz = func_diff / np.array([diff_sdhat] * func_diff.shape[-1]).T dvars_vx_stdz = diff_vx_stdz.std(axis=0, ddof=1) return (dvars_stdz, dvars_nstd, dvars_vx_stdz) diff --git a/nipype/algorithms/tests/test_compcor.py b/nipype/algorithms/tests/test_compcor.py index 1d582b7404..54efe0f8b8 100644 --- a/nipype/algorithms/tests/test_compcor.py +++ b/nipype/algorithms/tests/test_compcor.py @@ -16,7 +16,7 @@ class TestCompCor(): filenames = {'functionalnii': 'compcorfunc.nii', 'masknii': 'compcormask.nii', 'components_file': None} - + @pytest.fixture(autouse=True) def setup_class(self, tmpdir): # setup diff --git a/nipype/algorithms/tests/test_mesh_ops.py b/nipype/algorithms/tests/test_mesh_ops.py index 32f59e8f04..9762b900b2 100644 --- a/nipype/algorithms/tests/test_mesh_ops.py +++ b/nipype/algorithms/tests/test_mesh_ops.py @@ -25,7 +25,7 @@ def test_ident_distances(tmpdir): dist_ident.inputs.out_file = os.path.join(tempdir, 'distance.npy') res = dist_ident.run() assert res.outputs.distance == 0.0 - + dist_ident.inputs.weighting = 'area' res = dist_ident.run() assert res.outputs.distance == 0.0 @@ -35,23 +35,23 @@ def test_ident_distances(tmpdir): def test_trans_distances(tmpdir): tempdir = str(tmpdir) os.chdir(tempdir) - + from ...interfaces.vtkbase import tvtk - + in_surf = example_data('surf01.vtk') warped_surf = os.path.join(tempdir, 'warped.vtk') - + inc = np.array([0.7, 0.3, -0.2]) - + r1 = tvtk.PolyDataReader(file_name=in_surf) vtk1 = VTKInfo.vtk_output(r1) r1.update() vtk1.points = np.array(vtk1.points) + inc - + writer = tvtk.PolyDataWriter(file_name=warped_surf) VTKInfo.configure_input_data(writer, vtk1) writer.write() - + dist = m.ComputeMeshWarp() dist.inputs.surface1 = in_surf dist.inputs.surface2 = warped_surf @@ -79,10 +79,10 @@ def test_meshwarpmaths(tmpdir): @pytest.mark.skipif(not VTKInfo.no_tvtk(), reason="tvtk is installed") def test_importerror(): - with pytest.raises(ImportError): + with pytest.raises(ImportError): m.ComputeMeshWarp() - with pytest.raises(ImportError): + with pytest.raises(ImportError): m.WarpPoints() with pytest.raises(ImportError): diff --git a/nipype/algorithms/tests/test_modelgen.py b/nipype/algorithms/tests/test_modelgen.py index 9359c6e665..cb10304fea 100644 --- a/nipype/algorithms/tests/test_modelgen.py +++ b/nipype/algorithms/tests/test_modelgen.py @@ -152,8 +152,8 @@ def test_modelgen_sparse(tmpdir): assert len(res.outputs.session_info[0]['regress']) == 1 s.inputs.use_temporal_deriv = True res = s.run() - + assert len(res.outputs.session_info[0]['regress']) == 2 npt.assert_almost_equal(res.outputs.session_info[0]['regress'][0]['val'][0], 0.016675298129743384) npt.assert_almost_equal(res.outputs.session_info[1]['regress'][1]['val'][5], 0.007671459162258378) - + diff --git a/nipype/algorithms/tests/test_overlap.py b/nipype/algorithms/tests/test_overlap.py index d4b32ef38d..ab0f564b1a 100644 --- a/nipype/algorithms/tests/test_overlap.py +++ b/nipype/algorithms/tests/test_overlap.py @@ -26,7 +26,7 @@ def check_close(val1, val2): overlap.inputs.volume2 = in1 res = overlap.run() check_close(res.outputs.jaccard, 1.0) - + overlap = Overlap() overlap.inputs.volume1 = in1 overlap.inputs.volume2 = in2 diff --git a/nipype/interfaces/freesurfer/tests/test_preprocess.py b/nipype/interfaces/freesurfer/tests/test_preprocess.py index 5bd2186d28..4707d6068c 100644 --- a/nipype/interfaces/freesurfer/tests/test_preprocess.py +++ b/nipype/interfaces/freesurfer/tests/test_preprocess.py @@ -58,7 +58,7 @@ def test_robustregister(create_files_in_directory): assert reg2.cmdline == ('mri_robust_register --halfdst %s_halfway.nii --lta foo.lta ' '--sat 3.0000 --mov %s --dst %s' % (os.path.join(outdir, filelist[1][:-4]), filelist[0], filelist[1])) - + @pytest.mark.skipif(freesurfer.no_freesurfer(), reason="freesurfer is not installed") def test_fitmsparams(create_files_in_directory): diff --git a/nipype/interfaces/fsl/tests/test_base.py b/nipype/interfaces/fsl/tests/test_base.py index b35c28d13e..030306e929 100644 --- a/nipype/interfaces/fsl/tests/test_base.py +++ b/nipype/interfaces/fsl/tests/test_base.py @@ -9,7 +9,7 @@ import pytest -@pytest.mark.skipif(no_fsl(), reason="fsl is not installed") +@pytest.mark.skipif(no_fsl(), reason="fsl is not installed") def test_fslversion(): ver = fsl.Info.version() ver = ver.split('.') @@ -27,8 +27,8 @@ def test_outputtype_to_ext(): for ftype, ext in fsl.Info.ftypes.items(): res = fsl.Info.output_type_to_ext(ftype) assert res == ext - - with pytest.raises(KeyError): + + with pytest.raises(KeyError): fsl.Info.output_type_to_ext('JUNK') @@ -60,11 +60,11 @@ def test_FSLCommand2(): @pytest.mark.skipif(no_fsl(), reason="fsl is not installed") -@pytest.mark.parametrize("args, desired_name", - [({}, {"file": 'foo.nii.gz'}), # just the filename - ({"suffix": '_brain'}, {"file": 'foo_brain.nii.gz'}), # filename with suffix - ({"suffix": '_brain', "cwd": '/data'}, - {"dir": '/data', "file": 'foo_brain.nii.gz'}), # filename with suffix and working directory +@pytest.mark.parametrize("args, desired_name", + [({}, {"file": 'foo.nii.gz'}), # just the filename + ({"suffix": '_brain'}, {"file": 'foo_brain.nii.gz'}), # filename with suffix + ({"suffix": '_brain', "cwd": '/data'}, + {"dir": '/data', "file": 'foo_brain.nii.gz'}), # filename with suffix and working directory ({"suffix": '_brain.mat', "change_ext": False}, {"file": 'foo_brain.mat'}) # filename with suffix and no file extension change ]) def test_gen_fname(args, desired_name): diff --git a/nipype/interfaces/fsl/tests/test_dti.py b/nipype/interfaces/fsl/tests/test_dti.py index fc35aeb790..78fa253a3d 100644 --- a/nipype/interfaces/fsl/tests/test_dti.py +++ b/nipype/interfaces/fsl/tests/test_dti.py @@ -70,7 +70,7 @@ def test_dtifit2(create_files_in_directory): filelist[1]) -@pytest.mark.xfail(reason="These tests are skipped until we clean up some of this code") +@pytest.mark.xfail(reason="These tests are skipped until we clean up some of this code") def test_randomise2(): rand = fsl.Randomise() @@ -79,7 +79,7 @@ def test_randomise2(): assert rand.cmd == 'randomise' # test raising error with mandatory args absent - with pytest.raises(ValueError): + with pytest.raises(ValueError): rand.run() # .inputs based parameters setting @@ -155,7 +155,7 @@ def test_Randomise_parallel(): assert rand.cmd == 'randomise_parallel' # test raising error with mandatory args absent - with pytest.raises(ValueError): + with pytest.raises(ValueError): rand.run() # .inputs based parameters setting @@ -269,7 +269,7 @@ def test_Vec_reg(): assert vrg.cmd == 'vecreg' # test raising error with mandatory args absent - with pytest.raises(ValueError): + with pytest.raises(ValueError): vrg.run() # .inputs based parameters setting @@ -330,7 +330,7 @@ def test_Find_the_biggest(): assert fbg.cmd == 'find_the_biggest' # test raising error with mandatory args absent - with pytest.raises(ValueError): + with pytest.raises(ValueError): fbg.run() # .inputs based parameters setting @@ -355,12 +355,12 @@ def test_tbss_skeleton(create_files_in_directory): skeletor = fsl.TractSkeleton() files, newdir = create_files_in_directory - + # Test the underlying command assert skeletor.cmd == "tbss_skeleton" # It shouldn't run yet - with pytest.raises(ValueError): + with pytest.raises(ValueError): skeletor.run() # Test the most basic way to use it @@ -379,7 +379,7 @@ def test_tbss_skeleton(create_files_in_directory): bones = fsl.TractSkeleton(in_file="a.nii", project_data=True) # This should error - with pytest.raises(ValueError): + with pytest.raises(ValueError): bones.run() # But we can set what we need diff --git a/nipype/interfaces/fsl/tests/test_epi.py b/nipype/interfaces/fsl/tests/test_epi.py index 7a7082e281..038543e634 100644 --- a/nipype/interfaces/fsl/tests/test_epi.py +++ b/nipype/interfaces/fsl/tests/test_epi.py @@ -47,7 +47,7 @@ def test_eddy_correct2(create_files_in_directory): assert eddy.cmd == 'eddy_correct' # test raising error with mandatory args absent - with pytest.raises(ValueError): + with pytest.raises(ValueError): eddy.run() # .inputs based parameters setting diff --git a/nipype/interfaces/fsl/tests/test_maths.py b/nipype/interfaces/fsl/tests/test_maths.py index 3996830ad0..a94098df2c 100644 --- a/nipype/interfaces/fsl/tests/test_maths.py +++ b/nipype/interfaces/fsl/tests/test_maths.py @@ -49,7 +49,7 @@ def create_files_in_directory(request): nb.save(nb.Nifti1Image(img, np.eye(4), hdr), os.path.join(testdir, f)) - out_ext = Info.output_type_to_ext(Info.output_type()) + out_ext = Info.output_type_to_ext(Info.output_type()) def fin(): if os.path.exists(testdir): @@ -186,7 +186,7 @@ def test_meanimage(create_files_in_directory): meaner = fsl.MeanImage(in_file="a.nii") assert meaner.cmdline == "fslmaths a.nii -Tmean %s" % os.path.join(testdir, "a_mean%s" % out_ext) - + @pytest.mark.skipif(no_fsl(), reason="fsl is not installed") def test_stdimage(create_files_in_directory): files, testdir, out_ext = create_files_in_directory @@ -209,7 +209,7 @@ def test_stdimage(create_files_in_directory): # Test the auto naming stder = fsl.StdImage(in_file="a.nii") #NOTE_dj, FAIL: this is failing (even the original version of the test with pytest) - #NOTE_dj: not sure if this should pass, it uses cmdline from interface.base.CommandLine + #NOTE_dj: not sure if this should pass, it uses cmdline from interface.base.CommandLine #assert stder.cmdline == "fslmaths a.nii -Tstd %s"%os.path.join(testdir, "a_std.nii") @@ -248,7 +248,7 @@ def test_smooth(create_files_in_directory): assert smoother.cmd == "fslmaths" # Test that smoothing kernel is mandatory - with pytest.raises(ValueError): + with pytest.raises(ValueError): smoother.run() # Test smoothing kernels @@ -276,7 +276,7 @@ def test_mask(create_files_in_directory): assert masker.cmd == "fslmaths" # Test that the mask image is mandatory - with pytest.raises(ValueError): + with pytest.raises(ValueError): masker.run() # Test setting the mask image @@ -299,7 +299,7 @@ def test_dilation(create_files_in_directory): assert diller.cmd == "fslmaths" # Test that the dilation operation is mandatory - with pytest.raises(ValueError): + with pytest.raises(ValueError): diller.run() # Test the different dilation operations @@ -361,7 +361,7 @@ def test_spatial_filter(create_files_in_directory): assert filter.cmd == "fslmaths" # Test that it fails without an operation - with pytest.raises(ValueError): + with pytest.raises(ValueError): filter.run() # Test the different operations @@ -385,7 +385,7 @@ def test_unarymaths(create_files_in_directory): assert maths.cmd == "fslmaths" # Test that it fails without an operation - with pytest.raises(ValueError): + with pytest.raises(ValueError): maths.run() # Test the different operations @@ -488,4 +488,4 @@ def test_tempfilt(create_files_in_directory): "fslmaths a.nii -bptf 64.000000 -1.000000 %s" % os.path.join(testdir, "a_filt%s" % out_ext) - + diff --git a/nipype/interfaces/fsl/tests/test_preprocess.py b/nipype/interfaces/fsl/tests/test_preprocess.py index 3904703e2d..f702842aeb 100644 --- a/nipype/interfaces/fsl/tests/test_preprocess.py +++ b/nipype/interfaces/fsl/tests/test_preprocess.py @@ -30,7 +30,7 @@ def setup_infile(request): tmp_dir = tempfile.mkdtemp() tmp_infile = os.path.join(tmp_dir, 'foo' + ext) open(tmp_infile, 'w') - + def fin(): shutil.rmtree(tmp_dir) @@ -50,7 +50,7 @@ def test_bet(setup_infile): assert better.cmd == 'bet' # Test raising error with mandatory args absent - with pytest.raises(ValueError): + with pytest.raises(ValueError): better.run() # Test generated outfile name @@ -68,7 +68,7 @@ def test_bet(setup_infile): # infile foo.nii doesn't exist def func(): better.run(in_file='foo2.nii', out_file='bar.nii') - with pytest.raises(TraitError): + with pytest.raises(TraitError): func() # Our options and some test values for them @@ -100,7 +100,7 @@ def func(): better.inputs.in_file = tmp_infile realcmd = ' '.join([better.cmd, tmp_infile, outpath, settings[0]]) assert better.cmdline == realcmd - + # test fast @@ -196,7 +196,7 @@ def setup_flirt(request): tmpdir = tempfile.mkdtemp() _, infile = tempfile.mkstemp(suffix=ext, dir=tmpdir) _, reffile = tempfile.mkstemp(suffix=ext, dir=tmpdir) - + def teardown_flirt(): shutil.rmtree(tmpdir) @@ -234,11 +234,11 @@ def test_flirt(setup_flirt): flirter = fsl.FLIRT() # infile not specified - with pytest.raises(ValueError): + with pytest.raises(ValueError): flirter.run() flirter.inputs.in_file = infile # reference not specified - with pytest.raises(ValueError): + with pytest.raises(ValueError): flirter.run() flirter.inputs.reference = reffile # Generate outfile and outmatrix @@ -415,7 +415,7 @@ def test_fnirt(setup_flirt): # Test ValueError is raised when missing mandatory args fnirt = fsl.FNIRT() - with pytest.raises(ValueError): + with pytest.raises(ValueError): fnirt.run() fnirt.inputs.in_file = infile fnirt.inputs.ref_file = reffile @@ -507,7 +507,7 @@ def test_applywarp(setup_flirt): settings[0]) assert awarp.cmdline == realcmd - + @pytest.fixture(scope="module") def setup_fugue(request): import nibabel as nb @@ -528,7 +528,7 @@ def teardown_fugue(): @pytest.mark.skipif(no_fsl(), reason="fsl is not installed") @pytest.mark.parametrize("attr, out_file", [ - ({"save_unmasked_fmap":True, "fmap_in_file":"infile", "mask_file":"infile", "output_type":"NIFTI_GZ"}, + ({"save_unmasked_fmap":True, "fmap_in_file":"infile", "mask_file":"infile", "output_type":"NIFTI_GZ"}, 'fmap_out_file'), ({"save_unmasked_shift":True, "fmap_in_file":"infile", "dwell_time":1.e-3, "mask_file":"infile", "output_type": "NIFTI_GZ"}, "shift_out_file"), diff --git a/nipype/interfaces/fsl/tests/test_utils.py b/nipype/interfaces/fsl/tests/test_utils.py index 5bf734c759..9d7a525b31 100644 --- a/nipype/interfaces/fsl/tests/test_utils.py +++ b/nipype/interfaces/fsl/tests/test_utils.py @@ -60,7 +60,7 @@ def test_fslmerge(create_files_in_directory): assert merger.cmd == 'fslmerge' # test raising error with mandatory args absent - with pytest.raises(ValueError): + with pytest.raises(ValueError): merger.run() # .inputs based parameters setting @@ -99,7 +99,7 @@ def test_fslmaths(create_files_in_directory): assert math.cmd == 'fslmaths' # test raising error with mandatory args absent - with pytest.raises(ValueError): + with pytest.raises(ValueError): math.run() # .inputs based parameters setting @@ -116,7 +116,7 @@ def test_fslmaths(create_files_in_directory): # test arguments for opt_map # Fslmath class doesn't have opt_map{} - + # test overlay @@ -129,7 +129,7 @@ def test_overlay(create_files_in_directory): assert overlay.cmd == 'overlay' # test raising error with mandatory args absent - with pytest.raises(ValueError): + with pytest.raises(ValueError): overlay.run() # .inputs based parameters setting @@ -163,7 +163,7 @@ def test_slicer(create_files_in_directory): assert slicer.cmd == 'slicer' # test raising error with mandatory args absent - with pytest.raises(ValueError): + with pytest.raises(ValueError): slicer.run() # .inputs based parameters setting @@ -202,7 +202,7 @@ def test_plottimeseries(create_files_in_directory): assert plotter.cmd == 'fsl_tsplot' # test raising error with mandatory args absent - with pytest.raises(ValueError): + with pytest.raises(ValueError): plotter.run() # .inputs based parameters setting @@ -234,7 +234,7 @@ def test_plotmotionparams(create_files_in_directory): assert plotter.cmd == 'fsl_tsplot' # test raising error with mandatory args absent - with pytest.raises(ValueError): + with pytest.raises(ValueError): plotter.run() # .inputs based parameters setting @@ -264,7 +264,7 @@ def test_convertxfm(create_files_in_directory): assert cvt.cmd == "convert_xfm" # test raising error with mandatory args absent - with pytest.raises(ValueError): + with pytest.raises(ValueError): cvt.run() # .inputs based parameters setting @@ -293,7 +293,7 @@ def test_swapdims(create_files_in_directory): args = [dict(in_file=files[0]), dict(new_dims=("x", "y", "z"))] for arg in args: wontrun = fsl.SwapDimensions(**arg) - with pytest.raises(ValueError): + with pytest.raises(ValueError): wontrun.run() # Now test a basic command line diff --git a/nipype/interfaces/spm/tests/test_base.py b/nipype/interfaces/spm/tests/test_base.py index 6887766ad3..d8b809cf6e 100644 --- a/nipype/interfaces/spm/tests/test_base.py +++ b/nipype/interfaces/spm/tests/test_base.py @@ -53,7 +53,7 @@ def test_scan_for_fnames(create_files_in_directory): names = spm.scans_for_fnames(filelist, keep4d=True) assert names[0] == filelist[0] assert names[1] == filelist[1] - + save_time = False if not save_time: diff --git a/nipype/interfaces/spm/tests/test_preprocess.py b/nipype/interfaces/spm/tests/test_preprocess.py index 0a2535cba5..e7fc166eac 100644 --- a/nipype/interfaces/spm/tests/test_preprocess.py +++ b/nipype/interfaces/spm/tests/test_preprocess.py @@ -52,7 +52,7 @@ def test_slicetiming_list_outputs(create_files_in_directory): filelist, outdir, cwd = create_files_in_directory st = spm.SliceTiming(in_files=filelist[0]) assert st._list_outputs()['timecorrected_files'][0][0] == 'a' - + def test_realign(): assert spm.Realign._jobtype == 'spatial' @@ -66,7 +66,7 @@ def test_realign_list_outputs(create_files_in_directory): assert rlgn._list_outputs()['realignment_parameters'][0].startswith('rp_') assert rlgn._list_outputs()['realigned_files'][0].startswith('r') assert rlgn._list_outputs()['mean_image'].startswith('mean') - + def test_coregister(): assert spm.Coregister._jobtype == 'spatial' @@ -80,7 +80,7 @@ def test_coregister_list_outputs(create_files_in_directory): assert coreg._list_outputs()['coregistered_source'][0].startswith('r') coreg = spm.Coregister(source=filelist[0], apply_to_files=filelist[1]) assert coreg._list_outputs()['coregistered_files'][0].startswith('r') - + def test_normalize(): assert spm.Normalize._jobtype == 'spatial' @@ -94,7 +94,7 @@ def test_normalize_list_outputs(create_files_in_directory): assert norm._list_outputs()['normalized_source'][0].startswith('w') norm = spm.Normalize(source=filelist[0], apply_to_files=filelist[1]) assert norm._list_outputs()['normalized_files'][0].startswith('w') - + def test_normalize12(): assert spm.Normalize12._jobtype == 'spatial' @@ -109,7 +109,7 @@ def test_normalize12_list_outputs(create_files_in_directory): norm12 = spm.Normalize12(image_to_align=filelist[0], apply_to_files=filelist[1]) assert norm12._list_outputs()['normalized_files'][0].startswith('w') - + @pytest.mark.skipif(no_spm(), reason="spm is not installed") def test_segment(): diff --git a/nipype/interfaces/tests/test_base.py b/nipype/interfaces/tests/test_base.py index 2e2fa5f432..81c6ab1368 100644 --- a/nipype/interfaces/tests/test_base.py +++ b/nipype/interfaces/tests/test_base.py @@ -134,7 +134,7 @@ class MyInterface(nib.BaseInterface): myif = MyInterface() # NOTE_dj, FAIL: I don't get a TypeError, only a UserWarning - #with pytest.raises(TypeError): + #with pytest.raises(TypeError): # setattr(myif.inputs, 'kung', 10.0) myif.inputs.foo = 1 assert myif.inputs.foo == 1 @@ -155,7 +155,7 @@ class DeprecationSpec1(nib.TraitedSpec): set_foo = lambda: setattr(spec_instance, 'foo', 1) with pytest.raises(nib.TraitError): set_foo() assert len(w) == 0, 'no warnings, just errors' - + with warnings.catch_warnings(record=True) as w: warnings.filterwarnings('always', '', UserWarning) @@ -324,7 +324,7 @@ class spec2(nib.TraitedSpec): infields = spec2(moo=tmp_infile, doo=[tmp_infile]) hashval = infields.get_hashval(hash_method='content') assert hashval[1] == 'a00e9ee24f5bfa9545a515b7a759886b' - + def test_TraitedSpec_withNoFileHashing(setup_file): tmp_infile = setup_file @@ -413,10 +413,10 @@ def _run_interface(self, runtime): assert DerivedInterface2()._outputs().foo == Undefined with pytest.raises(NotImplementedError): DerivedInterface2(goo=1).run() - default_inpu_spec = nib.BaseInterface.input_spec + default_inpu_spec = nib.BaseInterface.input_spec nib.BaseInterface.input_spec = None with pytest.raises(Exception): nib.BaseInterface() - nib.BaseInterface.input_spec = default_inpu_spec + nib.BaseInterface.input_spec = default_inpu_spec def test_BaseInterface_load_save_inputs(tmpdir): @@ -485,7 +485,7 @@ class DerivedInterface1(nib.BaseInterface): obj._check_version_requirements(obj.inputs) config.set('execution', 'stop_on_unknown_version', True) - + with pytest.raises(Exception): obj._check_version_requirements(obj.inputs) config.set_default_config() @@ -682,7 +682,7 @@ def test_CommandLine_output(setup_file): ci = nib.CommandLine(command='ls -l') res = ci.run() assert 'stdout.nipype' in res.runtime.stdout - + def test_global_CommandLine_output(setup_file): tmp_infile = setup_file diff --git a/nipype/interfaces/tests/test_io.py b/nipype/interfaces/tests/test_io.py index 3eded239d7..dbc1fe6ac7 100644 --- a/nipype/interfaces/tests/test_io.py +++ b/nipype/interfaces/tests/test_io.py @@ -79,7 +79,7 @@ def test_s3datagrabber(): def test_selectfiles(SF_args, inputs_att, expected): base_dir = op.dirname(nipype.__file__) dg = nio.SelectFiles(base_directory=base_dir, **SF_args) - for key, val in inputs_att.items(): + for key, val in inputs_att.items(): setattr(dg.inputs, key, val) assert dg._infields == expected["infields"] @@ -202,7 +202,7 @@ def test_datasink_to_s3(dummy_input, tmpdir): output_dir = 's3://' + bucket_name # Local temporary filepaths for testing fakes3_dir = str(tmpdir) - input_path = dummy_input + input_path = dummy_input # Start up fake-S3 server proc = Popen(['fakes3', '-r', fakes3_dir, '-p', '4567'], stdout=open(os.devnull, 'wb')) @@ -424,11 +424,11 @@ def test_jsonsink(tmpdir, inputs_attributes): for key, val in inputs_attributes.items(): setattr(js.inputs, key, val) expected_data[key] = val - + res = js.run() with open(res.outputs.out_file, 'r') as f: data = simplejson.load(f) - + assert data == expected_data diff --git a/nipype/interfaces/tests/test_nilearn.py b/nipype/interfaces/tests/test_nilearn.py index 7558b9d0bf..4e8299aa74 100644 --- a/nipype/interfaces/tests/test_nilearn.py +++ b/nipype/interfaces/tests/test_nilearn.py @@ -156,7 +156,7 @@ def teardown_class(self): os.chdir(self.orig_dir) shutil.rmtree(self.temp_dir) - + fake_fmri_data = np.array([[[[2, -1, 4, -2, 3], [4, -2, -5, -1, 0]], diff --git a/nipype/interfaces/tests/test_utility.py b/nipype/interfaces/tests/test_utility.py index b08f7da768..77fa276e1c 100644 --- a/nipype/interfaces/tests/test_utility.py +++ b/nipype/interfaces/tests/test_utility.py @@ -1,9 +1,9 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- from __future__ import print_function, unicode_literals -# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- -# vi: set ft=python sts=4 ts=4 sw=4 et: +# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- +# vi: set ft=python sts=4 ts=4 sw=4 et: import os -import pytest +import pytest from nipype.interfaces import utility import nipype.pipeline.engine as pe @@ -18,7 +18,7 @@ def test_rename(tmpdir): res = rn.run() outfile = str(tmpdir.join("test_file1.txt")) assert res.outputs.out_file == outfile - assert os.path.exists(outfile) + assert os.path.exists(outfile) # Now a string-formatting version rn = utility.Rename(in_file="file.txt", format_string="%(field1)s_file%(field2)d", keep_ext=True) @@ -70,7 +70,7 @@ def should_fail(tmpdir): node.inputs.size = 10 node.run() - + def test_should_fail(tmpdir): with pytest.raises(NameError): should_fail(str(tmpdir)) @@ -129,7 +129,7 @@ def test_csvReader(tmpdir): assert out.outputs.column_0 == ['foo', 'bar', 'baz'] assert out.outputs.column_1 == ['hello', 'world', 'goodbye'] assert out.outputs.column_2 == ['300.1', '5', '0.3'] - + def test_aux_connect_function(tmpdir): """ This tests excution nodes with multiple inputs and auxiliary diff --git a/nipype/pipeline/engine/tests/test_engine.py b/nipype/pipeline/engine/tests/test_engine.py index e5a8f58baa..b7a17cd6d6 100644 --- a/nipype/pipeline/engine/tests/test_engine.py +++ b/nipype/pipeline/engine/tests/test_engine.py @@ -74,7 +74,7 @@ def test_add_nodes(): # ensure that all connections are tested later @pytest.mark.parametrize("iterables, expected", [ - ({"1": None}, (1,0)), #test1 + ({"1": None}, (1,0)), #test1 ({"1": dict(input1=lambda: [1, 2], input2=lambda: [1, 2])}, (4,0)) #test2 ]) def test_1mod(iterables, expected): @@ -89,8 +89,8 @@ def test_1mod(iterables, expected): @pytest.mark.parametrize("iterables, expected", [ - ({"1": {}, "2": dict(input1=lambda: [1, 2])}, (3,2)), #test3 - ({"1": dict(input1=lambda: [1, 2]), "2": {}}, (4,2)), #test4 + ({"1": {}, "2": dict(input1=lambda: [1, 2])}, (3,2)), #test3 + ({"1": dict(input1=lambda: [1, 2]), "2": {}}, (4,2)), #test4 ({"1": dict(input1=lambda: [1, 2]), "2": dict(input1=lambda: [1, 2])}, (6,4)) #test5 ]) def test_2mods(iterables, expected): @@ -109,7 +109,7 @@ def test_2mods(iterables, expected): @pytest.mark.parametrize("iterables, expected, connect", [ ({"1": {}, "2": dict(input1=lambda: [1, 2]), "3": {}}, (5,4), ("1-2","2-3")), #test6 ({"1": dict(input1=lambda: [1, 2]), "2": {}, "3": {}}, (5,4), ("1-3","2-3")), #test7 - ({"1": dict(input1=lambda: [1, 2]), "2": dict(input1=lambda: [1, 2]), "3": {}}, + ({"1": dict(input1=lambda: [1, 2]), "2": dict(input1=lambda: [1, 2]), "3": {}}, (8,8), ("1-3","2-3")), #test8 ]) def test_3mods(iterables, expected, connect): @@ -582,7 +582,7 @@ def func2(a): logger.info('Exception: %s' % str(e)) error_raised = True assert not error_raised - + def test_mapnode_json(tmpdir): """Tests that mapnodes don't generate excess jsons @@ -678,7 +678,7 @@ def func1(in1): error_raised = True assert not error_raised - + def test_write_graph_runs(tmpdir): os.chdir(str(tmpdir)) diff --git a/nipype/pipeline/engine/tests/test_join.py b/nipype/pipeline/engine/tests/test_join.py index dc4c74361d..87dafeee0f 100644 --- a/nipype/pipeline/engine/tests/test_join.py +++ b/nipype/pipeline/engine/tests/test_join.py @@ -576,9 +576,9 @@ def nested_wf(i, name='smallwf'): meta_wf.add_nodes([mini_wf]) result = meta_wf.run() - + # there should be six nodes in total assert len(result.nodes()) == 6, \ "The number of expanded nodes is incorrect." - + diff --git a/nipype/pipeline/engine/tests/test_utils.py b/nipype/pipeline/engine/tests/test_utils.py index f14fe25916..d697829c35 100644 --- a/nipype/pipeline/engine/tests/test_utils.py +++ b/nipype/pipeline/engine/tests/test_utils.py @@ -336,4 +336,4 @@ def test_provenance(tmpdir): psg = write_workflow_prov(eg, prov_base, format='all') assert len(psg.bundles) == 2 assert len(psg.get_records()) == 7 - + diff --git a/nipype/pipeline/plugins/tests/test_base.py b/nipype/pipeline/plugins/tests/test_base.py index 5974f93c49..8661c06519 100644 --- a/nipype/pipeline/plugins/tests/test_base.py +++ b/nipype/pipeline/plugins/tests/test_base.py @@ -33,7 +33,7 @@ def test_report_crash(): actual_crashfile = pb.report_crash(mock_node) expected_crashfile = re.compile('.*/crash-.*-an_id-[0-9a-f\-]*.pklz') - + assert expected_crashfile.match(actual_crashfile).group() == actual_crashfile assert mock_pickle_dump.call_count == 1 diff --git a/nipype/pipeline/plugins/tests/test_callback.py b/nipype/pipeline/plugins/tests/test_callback.py index 7f165d1f2c..fde12a599b 100644 --- a/nipype/pipeline/plugins/tests/test_callback.py +++ b/nipype/pipeline/plugins/tests/test_callback.py @@ -63,7 +63,7 @@ def test_callback_exception(tmpdir): assert n.name == 'f_node' assert so.statuses[0][1] == 'start' assert so.statuses[1][1] == 'exception' - + @pytest.mark.skipif(sys.version_info < (3, 0), reason="Disabled until https://github.com/nipy/nipype/issues/1692 is resolved") @@ -82,7 +82,7 @@ def test_callback_multiproc_normal(tmpdir): assert n.name == 'f_node' assert so.statuses[0][1] == 'start' assert so.statuses[1][1] == 'end' - + @pytest.mark.skipif(sys.version_info < (3, 0), reason="Disabled until https://github.com/nipy/nipype/issues/1692 is resolved") @@ -104,4 +104,4 @@ def test_callback_multiproc_exception(tmpdir): assert n.name == 'f_node' assert so.statuses[0][1] == 'start' assert so.statuses[1][1] == 'exception' - + diff --git a/nipype/pipeline/plugins/tests/test_multiproc.py b/nipype/pipeline/plugins/tests/test_multiproc.py index ba98f5adf7..59c478e09b 100644 --- a/nipype/pipeline/plugins/tests/test_multiproc.py +++ b/nipype/pipeline/plugins/tests/test_multiproc.py @@ -225,7 +225,7 @@ def test_no_more_threads_than_specified(): break assert result, "using more threads than specified" - + max_memory = get_system_total_memory_gb() result = True for m in memory: diff --git a/nipype/utils/tests/test_cmd.py b/nipype/utils/tests/test_cmd.py index b1b87cc8a7..e6aad61b28 100644 --- a/nipype/utils/tests/test_cmd.py +++ b/nipype/utils/tests/test_cmd.py @@ -29,10 +29,10 @@ class TestNipypeCMD(): maxDiff = None def test_main_returns_2_on_empty(self): - with pytest.raises(SystemExit) as cm: + with pytest.raises(SystemExit) as cm: with capture_sys_output() as (stdout, stderr): nipype_cmd.main(['nipype_cmd']) - + exit_exception = cm.value assert exit_exception.code == 2 @@ -71,7 +71,7 @@ def test_main_returns_0_on_help(self): -h, --help show this help message and exit """ - + def test_list_nipy_interfacesp(self): with pytest.raises(SystemExit) as cm: with capture_sys_output() as (stdout, stderr): diff --git a/nipype/utils/tests/test_filemanip.py b/nipype/utils/tests/test_filemanip.py index dd4ec07d9e..f0dee52870 100644 --- a/nipype/utils/tests/test_filemanip.py +++ b/nipype/utils/tests/test_filemanip.py @@ -58,8 +58,8 @@ def test_fnames_presuffix(): ]) def test_hash_rename(filename, newname): new_name = hash_rename(filename, 'abc123') - assert new_name == newname - + assert new_name == newname + def test_check_forhash(): fname = 'foobar' @@ -253,7 +253,7 @@ def test_get_related_files_noninclusive(_temp_analyze_files): assert orig_hdr not in related_files @pytest.mark.parametrize("filename, expected", [ - ('foo.nii', ['foo.nii']), + ('foo.nii', ['foo.nii']), (['foo.nii'], ['foo.nii']), (('foo', 'bar'), ['foo', 'bar']), (12.34, None) @@ -261,7 +261,7 @@ def test_get_related_files_noninclusive(_temp_analyze_files): def test_filename_to_list(filename, expected): x = filename_to_list(filename) assert x == expected - + @pytest.mark.parametrize("list, expected", [ (['foo.nii'], 'foo.nii'), (['foo', 'bar'], ['foo', 'bar']),