Repository: nipy/nipype

Issue:
STUCK: cannot pass Travis tests due to DiPy 0.8 in new functions
 Travis is stuck with errors caused by new functions based on Dipy 0.8 which is not released officially (at least not in pip repository) 



Discussion:
It's not dipy. Tests should run without dependencies installed. #934 fixes this

@chrisfilo it is still failing on my side even after update from your commit:

```
Checking specs and autogenerating spec tests
python tools/checkspecs.py
(...)/nipype/nipype/__init__.py:57: UserWarning: Running the tests from the install directory may trigger some failures
  warnings.warn('Running the tests from the install directory may '
Traceback (most recent call last):
  File "tools/checkspecs.py", line 421, in <module>
    ic.check_modules()
  File "tools/checkspecs.py", line 377, in check_modules
    bad_specs = self.test_specs(m)
  File "tools/checkspecs.py", line 188, in test_specs
    __import__(uri)
  File "(...)/nipype/nipype/interfaces/dipy/__init__.py", line 3, in <module>
    from .preprocess import Resample, Denoise
  File "(...)/nipype/nipype/interfaces/dipy/preprocess.py", line 26, in <module>
    from dipy.denoise import nlmeans
ImportError: No module named denoise
make: *** [specs] Error 1
```

I suspect the tests will pass if you either uninstall dipy or update it to dev. We should fix this, but it's unrelated to travis.

Yes that's what i meant in my issue, travis generates errors for anyone having dipy version provided by pip (<0.8) because of some new functions calling dipy 0.8 libraries. 

Everyone trying to do tests or submitting PR to nipype will have this issue, is it really fine for them to require a dev version not available on the pip repository? Shouldn't the tests be compatible with current python libraries (not dev)? Just asking


Resolving patch:
diff --git a/nipype/interfaces/dipy/preprocess.py b/nipype/interfaces/dipy/preprocess.py
--- a/nipype/interfaces/dipy/preprocess.py
+++ b/nipype/interfaces/dipy/preprocess.py
@@ -1,9 +1,12 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
-# @Author: oesteban
-# @Date:   2014-09-01 10:33:35
-# @Last Modified by:   oesteban
-# @Last Modified time: 2014-09-03 15:07:46
+"""Change directory to provide relative paths for doctests
+   >>> import os
+   >>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
+   >>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
+   >>> os.chdir(datadir)
+"""
+
 from nipype.interfaces.base import (traits, TraitedSpec, BaseInterface,
                                     File, isdefined)
 from nipype.utils.filemanip import split_filename
@@ -23,7 +26,6 @@
 else:
     from dipy.align.aniso2iso import resample
     from dipy.core.gradients import GradientTable
-    from dipy.denoise.nlmeans import nlmeans
 
 
 class ResampleInputSpec(TraitedSpec):
@@ -125,6 +127,15 @@ class Denoise(BaseInterface):
     """
     input_spec = DenoiseInputSpec
     output_spec = DenoiseOutputSpec
+    
+    def __init__(self, **inputs):
+        try:
+            package_check('dipy', version='0.8.0.dev')
+        except Exception, e:
+            have_dipy = False
+        else:
+            from dipy.denoise.nlmeans import nlmeans
+        BaseInterface.__init__(self, **inputs)
 
     def _run_interface(self, runtime):
         out_file = op.abspath(self._gen_outfilename())
diff --git a/nipype/interfaces/dipy/tracks.py b/nipype/interfaces/dipy/tracks.py
--- a/nipype/interfaces/dipy/tracks.py
+++ b/nipype/interfaces/dipy/tracks.py
@@ -1,4 +1,10 @@
 # -*- coding: utf-8 -*-
+"""Change directory to provide relative paths for doctests
+   >>> import os
+   >>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
+   >>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
+   >>> os.chdir(datadir)
+"""
 from nipype.interfaces.base import (TraitedSpec, BaseInterface, BaseInterfaceInputSpec,
                                     File, isdefined, traits)
 from nipype.utils.filemanip import split_filename


Test patch: