[yt-svn] commit/yt: MatthewTurk: Merged in xarthisius/yt (pull request #1955)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue Jan 26 08:37:50 PST 2016


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/cd0a29c8ed02/
Changeset:   cd0a29c8ed02
Branch:      yt
User:        MatthewTurk
Date:        2016-01-26 16:37:45+00:00
Summary:     Merged in xarthisius/yt (pull request #1955)

Remove hard dependency on nose from yt core
Affected #:  3 files

diff -r 62e350b9531193afbbb0a6d97d3b1233ef25b4d2 -r cd0a29c8ed02c58096e6e0f3f6c7aaa6b8cf6dc3 yt/__init__.py
--- a/yt/__init__.py
+++ b/yt/__init__.py
@@ -170,8 +170,7 @@
 from yt.convenience import \
     load, simulation
 
-from yt.testing import \
-    run_nose
+from yt.testing import run_nose
 
 # Import some helpful math utilities
 from yt.utilities.math_utils import \

diff -r 62e350b9531193afbbb0a6d97d3b1233ef25b4d2 -r cd0a29c8ed02c58096e6e0f3f6c7aaa6b8cf6dc3 yt/testing.py
--- a/yt/testing.py
+++ b/yt/testing.py
@@ -31,7 +31,12 @@
 from numpy.testing import assert_string_equal  # NOQA
 from numpy.testing import assert_array_almost_equal_nulp  # NOQA
 from numpy.testing import assert_allclose, assert_raises  # NOQA
-from nose.tools import assert_true, assert_less_equal  # NOQA
+try:
+    from nose.tools import assert_true, assert_less_equal  # NOQA
+except ImportError:
+    # This means nose isn't installed, so the tests can't run and it's ok
+    # to not import these functions
+    pass
 from yt.convenience import load
 from yt.units.yt_array import YTArray, YTQuantity
 from yt.utilities.exceptions import YTUnitOperationError
@@ -779,11 +784,9 @@
 
 def run_nose(verbose=False, run_answer_tests=False, answer_big_data=False,
              call_pdb = False):
-    import nose
-    import os
+    from yt.utilities.on_demand_imports import _nose
     import sys
-    import yt
-    from yt.funcs import mylog
+    from yt.utilities.logger import ytLogger as mylog
     orig_level = mylog.getEffectiveLevel()
     mylog.setLevel(50)
     nose_argv = sys.argv
@@ -797,7 +800,7 @@
     if answer_big_data:
         nose_argv.append('--answer-big-data')
     initial_dir = os.getcwd()
-    yt_file = os.path.abspath(yt.__file__)
+    yt_file = os.path.abspath(__file__)
     yt_dir = os.path.dirname(yt_file)
     if os.path.samefile(os.path.dirname(yt_dir), initial_dir):
         # Provide a nice error message to work around nose bug
@@ -815,7 +818,7 @@
             )
     os.chdir(yt_dir)
     try:
-        nose.run(argv=nose_argv)
+        _nose.run(argv=nose_argv)
     finally:
         os.chdir(initial_dir)
         mylog.setLevel(orig_level)

diff -r 62e350b9531193afbbb0a6d97d3b1233ef25b4d2 -r cd0a29c8ed02c58096e6e0f3f6c7aaa6b8cf6dc3 yt/utilities/on_demand_imports.py
--- a/yt/utilities/on_demand_imports.py
+++ b/yt/utilities/on_demand_imports.py
@@ -13,14 +13,20 @@
 class NotAModule(object):
     """
     A class to implement an informative error message that will be outputted if
-    someone tries to use an on-demand import without having the requisite package installed.
+    someone tries to use an on-demand import without having the requisite
+    package installed.
     """
     def __init__(self, pkg_name):
         self.pkg_name = pkg_name
+        self.error = ImportError(
+            "This functionality requires the %s "
+            "package to be installed." % self.pkg_name)
 
     def __getattr__(self, item):
-        raise ImportError("This functionality requires the %s package to be installed."
-                          % self.pkg_name)
+        raise self.error
+
+    def __call__(self, *args, **kwargs):
+        raise self.error
 
 class astropy_imports:
     _name = "astropy"
@@ -272,3 +278,18 @@
         return self._version
 
 _h5py = h5py_imports()
+
+class nose_imports:
+    _name = "nose"
+    _run = None
+    @property
+    def run(self):
+        if self._run is None:
+            try:
+                from nose import run
+            except ImportError:
+                run = NotAModule(self._name)
+            self._run = run
+        return self._run
+
+_nose = nose_imports()

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list