提交 6e8c2b92 authored 作者: Brandon T. Willard's avatar Brandon T. Willard

Remove theano_nose.py and other nose references

上级 603c7167
...@@ -8,7 +8,6 @@ global-include *.sh ...@@ -8,7 +8,6 @@ global-include *.sh
global-include *.pkl global-include *.pkl
recursive-include doc recursive-include doc
include bin/theano-cache include bin/theano-cache
include bin/theano-nose
prune .jenkins prune .jenkins
prune .travis prune .travis
include versioneer.py include versioneer.py
......
差异被折叠。
...@@ -25,7 +25,7 @@ requirements: ...@@ -25,7 +25,7 @@ requirements:
test: test:
requires: requires:
- nose >=1.3.0 - pytest
imports: imports:
- theano - theano
......
...@@ -38,14 +38,14 @@ To get up to speed, you'll need to ...@@ -38,14 +38,14 @@ To get up to speed, you'll need to
trickier files (like tensor.py). trickier files (like tensor.py).
- Go through the `NumPy documentation`_. - Go through the `NumPy documentation`_.
- Learn to write reStructuredText_ for Sphinx_. - Learn to write reStructuredText_ for Sphinx_.
- Learn about how unittest_ and nose_ work - Learn about how unittest_ and pytest_ work
.. _Sphinx: http://sphinx.pocoo.org/ .. _Sphinx: http://sphinx.pocoo.org/
.. _reStructuredText: http://docutils.sourceforge.net/rst.html .. _reStructuredText: http://docutils.sourceforge.net/rst.html
.. _Allowed docstring sections in Napoleon: https://sphinxcontrib-napoleon.readthedocs.org/en/latest/#docstring-sections .. _Allowed docstring sections in Napoleon: https://sphinxcontrib-napoleon.readthedocs.org/en/latest/#docstring-sections
.. _NumPy documentation: http://docs.scipy.org/numpy/ .. _NumPy documentation: http://docs.scipy.org/numpy/
.. _unittest: http://docs.python.org/library/unittest.html .. _unittest: http://docs.python.org/library/unittest.html
.. _nose: http://nose.readthedocs.org/en/latest/ .. _pytest: http://docs.pytest.org/en/latest/
.. _quality_contributions: .. _quality_contributions:
...@@ -101,8 +101,8 @@ this script: ...@@ -101,8 +101,8 @@ this script:
theano/misc/do_nightly_build theano/misc/do_nightly_build
This script accepts arguments that it forwards to nosetests. You can This script accepts arguments that it forwards to ``pytest``. You can
run only some tests or enable pdb by giving the equivalent nosetests run only some tests or enable pdb by giving the equivalent ``pytest``
parameters. parameters.
Setting up your Editor for PEP8 Setting up your Editor for PEP8
...@@ -237,7 +237,6 @@ Then in your ``~/.emacs`` file, add this: ...@@ -237,7 +237,6 @@ Then in your ``~/.emacs`` file, add this:
(require 'epy-completion) ;; If you want the autocompletion settings [optional] (require 'epy-completion) ;; If you want the autocompletion settings [optional]
(require 'epy-editing) ;; For configurations related to editing [optional] (require 'epy-editing) ;; For configurations related to editing [optional]
;; [newer version of emacs-for-python] ;; [newer version of emacs-for-python]
(require 'epy-nose) ;; For shortcut to call nosetests [optional]
;; Define f10 to previous error ;; Define f10 to previous error
;; Define f11 to next error ;; Define f11 to next error
......
...@@ -546,7 +546,7 @@ How To Test it ...@@ -546,7 +546,7 @@ How To Test it
Theano has some functionalities to simplify testing. These help test the Theano has some functionalities to simplify testing. These help test the
``infer_shape``, ``grad`` and ``R_op`` methods. Put the following code ``infer_shape``, ``grad`` and ``R_op`` methods. Put the following code
in a file and execute it with the ``theano-nose`` program. in a file and execute it with the ``pytest`` program.
Basic Tests Basic Tests
^^^^^^^^^^^ ^^^^^^^^^^^
...@@ -676,50 +676,7 @@ For instance, to verify the Rop method of the DoubleOp, you can use this: ...@@ -676,50 +676,7 @@ For instance, to verify the Rop method of the DoubleOp, you can use this:
Running Your Tests Running Your Tests
^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^
To perform your tests, you may select either one of the three To perform your tests, simply run ``pytest``.
following methods:
theano-nose
"""""""""""
The method of choice to conduct tests is to run the file
``theano-nose``. In a regular Theano installation, the latter will be
on the operating system's path and directly accessible from any
folder. Otherwise, it can be accessed in the ``Theano/bin``
folder. The following command lines may be used for the corresponding
purposes:
* ``theano-nose --theano``: Run every test found in Theano's path.
* ``theano-nose folder_name``: Run every test found in the folder *folder_name*.
* ``theano-nose test_file.py``: Run every test found in the file *test_file.py*.
The following are particularly useful for development purposes since
they call for particular classes or even for particular tests:
* ``theano-nose test_file.py:TestDoubleRop``: Run every test found inside the
class *TestDoubleRop*.
* ``theano-nose test_file.py:TestDoubleRop.test_double_op``: Run only the test
*test_double_op* in the class *TestDoubleRop*.
Help with the use and functionalities of ``theano-nose`` may be
obtained by running it with the command line parameter ``--help
(-h)``.
nosetests
"""""""""
The command ``nosetests`` can also be used. Although it lacks the
useful functionalities that ``theano-nose`` provides, ``nosetests``
can be called similarly to ``theano-nose`` from any folder in Python's
path like so:
``nosetests [suffix similar to the above]``.
More documentation on ``nosetests`` is available here:
`nosetests <http://readthedocs.org/docs/nose/en/latest/>`_.
In-file In-file
""""""" """""""
......
...@@ -1038,12 +1038,12 @@ For the GPU, you must add in this second flag `nvcc.flags=-g` (it slow ...@@ -1038,12 +1038,12 @@ For the GPU, you must add in this second flag `nvcc.flags=-g` (it slow
down computation on the GPU, but it is enabled by default on the CPU). down computation on the GPU, but it is enabled by default on the CPU).
Then you must start Python inside GDB and in it start your Python Then you must start Python inside GDB and in it start your Python
process (e.g. theano-nose): process:
.. code-block:: sh .. code-block:: sh
$gdb python $gdb python
(gdb)r bin/theano-nose theano/ (gdb)r pytest theano/
`Quick guide to GDB <https://www.cs.cmu.edu/~gilpin/tutorial/>`_. `Quick guide to GDB <https://www.cs.cmu.edu/~gilpin/tutorial/>`_.
......
...@@ -47,6 +47,7 @@ Here is some code that allows the Op to be optional: ...@@ -47,6 +47,7 @@ Here is some code that allows the Op to be optional:
.. code-block:: python .. code-block:: python
try: try:
import scipy.linalg import scipy.linalg
imported_scipy = True imported_scipy = True
...@@ -61,12 +62,10 @@ Here is some code that allows the Op to be optional: ...@@ -61,12 +62,10 @@ Here is some code that allows the Op to be optional:
"SciPy not available. SciPy is needed for the SomeOp op.") "SciPy not available. SciPy is needed for the SomeOp op.")
... ...
from nose.plugins.skip import SkipTest
class TestSomeOp(utt.InferShapeTester): class TestSomeOp(utt.InferShapeTester):
... ...
@pytest.mark.skipif(not imported_scipy, reason="SciPy needed for the SomeOp op.")
def test_infer_shape(self): def test_infer_shape(self):
if not imported_scipy:
raise SkipTest("SciPy needed for the SomeOp op.")
... ...
.. _sparse_ops: .. _sparse_ops:
......
...@@ -225,9 +225,9 @@ type this: ...@@ -225,9 +225,9 @@ type this:
.. code-block:: bash .. code-block:: bash
THEANO_FLAGS='mode=FAST_COMPILE' theano-nose THEANO_FLAGS='mode=FAST_COMPILE' pytest
THEANO_FLAGS='mode=FAST_RUN' theano-nose THEANO_FLAGS='mode=FAST_RUN' pytest
THEANO_FLAGS='mode=DebugMode' theano-nose THEANO_FLAGS='mode=DebugMode' pytest
.. _random_value_in_tests: .. _random_value_in_tests:
...@@ -267,7 +267,7 @@ The behaviour of ``seed_rng`` is as follows: ...@@ -267,7 +267,7 @@ The behaviour of ``seed_rng`` is as follows:
The main advantage of using ``unittest_tools.seed_rng`` is that it allows The main advantage of using ``unittest_tools.seed_rng`` is that it allows
us to change the seed used in the unitests, without having to manually us to change the seed used in the unitests, without having to manually
edit all the files. For example, this allows the nightly build to run edit all the files. For example, this allows the nightly build to run
``theano-nose`` repeatedly, changing the seed on every run (hence achieving ``pytest`` repeatedly, changing the seed on every run (hence achieving
a higher confidence that the variables are correct), while still a higher confidence that the variables are correct), while still
making sure unittests are deterministic. making sure unittests are deterministic.
...@@ -285,7 +285,7 @@ Similarly, to provide a seed to ``numpy.random.RandomState``, simply use: ...@@ -285,7 +285,7 @@ Similarly, to provide a seed to ``numpy.random.RandomState``, simply use:
# OR providing an explicit seed # OR providing an explicit seed
rng = numpy.random.RandomState(unittest_tools.fetch_seed(1231)) # again not recommended rng = numpy.random.RandomState(unittest_tools.fetch_seed(1231)) # again not recommended
Note that the ability to change the seed from one nosetest to another, Note that the ability to change the seed from one test to another,
is incompatible with the method of hard-coding the baseline variables is incompatible with the method of hard-coding the baseline variables
(against which we compare the theano outputs). These must then be (against which we compare the theano outputs). These must then be
determined "algorithmically". Although this represents more work, the determined "algorithmically". Although this represents more work, the
......
...@@ -25,5 +25,5 @@ Requirements through System Packages (not recommended) ...@@ -25,5 +25,5 @@ Requirements through System Packages (not recommended)
.. code-block:: bash .. code-block:: bash
sudo yum install python-devel python-nose python-setuptools gcc gcc-gfortran gcc-c++ blas-devel lapack-devel atlas-devel sudo yum install python-devel python-pytest python-setuptools gcc gcc-gfortran gcc-c++ blas-devel lapack-devel atlas-devel
sudo easy_install pip sudo easy_install pip
...@@ -147,10 +147,9 @@ Theano dependencies is easy, but be aware that it will take a long time ...@@ -147,10 +147,9 @@ Theano dependencies is easy, but be aware that it will take a long time
``/opt/local/sbin`` before any other paths (to ensure that the Python and ``/opt/local/sbin`` before any other paths (to ensure that the Python and
gcc binaries that you installed with MacPorts are visible first). gcc binaries that you installed with MacPorts are visible first).
- MacPorts does not create automatically ``nosetests`` and ``pip`` symlinks - MacPorts does not automatically create ``pip`` symlinks pointing to the
pointing to the MacPorts version, so you can add them yourself with MacPorts version; you can add them yourself with
.. code-block:: bash .. code-block:: bash
$ sudo ln -s /opt/local/bin/nosetests-2.7 /opt/local/bin/nosetests
$ sudo ln -s /opt/local/bin/pip-2.7 /opt/local/bin/pip $ sudo ln -s /opt/local/bin/pip-2.7 /opt/local/bin/pip
...@@ -13,7 +13,7 @@ NVIDIA Jetson TX1 embedded platform ...@@ -13,7 +13,7 @@ NVIDIA Jetson TX1 embedded platform
.. code-block:: bash .. code-block:: bash
sudo apt-get install python-numpy python-scipy python-dev python-pip python-nose g++ libblas-dev git sudo apt-get install python-numpy python-scipy python-dev python-pip python-pytest g++ libblas-dev git
pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git --user # Need Theano 0.8 or more recent pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git --user # Need Theano 0.8 or more recent
Gentoo Gentoo
......
...@@ -32,7 +32,7 @@ For Ubuntu 16.04 with cuda 7.5 ...@@ -32,7 +32,7 @@ For Ubuntu 16.04 with cuda 7.5
.. code-block:: bash .. code-block:: bash
sudo apt-get install python-numpy python-scipy python-dev python-pip python-nose g++ libopenblas-dev git graphviz sudo apt-get install python-numpy python-scipy python-dev python-pip python-pytest g++ libopenblas-dev git graphviz
sudo pip install Theano sudo pip install Theano
# cuda 7.5 don't support the default g++ version. Install an supported version and make it the default. # cuda 7.5 don't support the default g++ version. Install an supported version and make it the default.
...@@ -54,20 +54,20 @@ For Ubuntu 11.10 through 14.04: ...@@ -54,20 +54,20 @@ For Ubuntu 11.10 through 14.04:
.. code-block:: bash .. code-block:: bash
sudo apt-get install python-numpy python-scipy python-dev python-pip python-nose g++ libopenblas-dev git sudo apt-get install python-numpy python-scipy python-dev python-pip python-pytest g++ libopenblas-dev git
On 14.04, this will install Python 2 by default. If you want to use Python 3: On 14.04, this will install Python 2 by default. If you want to use Python 3:
.. code-block:: bash .. code-block:: bash
sudo apt-get install python3-numpy python3-scipy python3-dev python3-pip python3-nose g++ libopenblas-dev git sudo apt-get install python3-numpy python3-scipy python3-dev python3-pip python3-pytest g++ libopenblas-dev git
sudo pip3 install Theano sudo pip3 install Theano
For Ubuntu 11.04: For Ubuntu 11.04:
.. code-block:: bash .. code-block:: bash
sudo apt-get install python-numpy python-scipy python-dev python-pip python-nose g++ git libatlas3gf-base libatlas-dev sudo apt-get install python-numpy python-scipy python-dev python-pip python-pytest g++ git libatlas3gf-base libatlas-dev
Manual Openblas installation (deprecated) Manual Openblas installation (deprecated)
----------------------------------------- -----------------------------------------
......
...@@ -24,7 +24,7 @@ Install requirements and optional packages ...@@ -24,7 +24,7 @@ Install requirements and optional packages
.. code-block:: bash .. code-block:: bash
conda install numpy scipy mkl-service libpython <m2w64-toolchain> <nose> <sphinx> <pydot-ng> <git> conda install numpy scipy mkl-service libpython <m2w64-toolchain> pytest <sphinx> <pydot-ng> <git>
.. note:: .. note::
......
...@@ -12,7 +12,7 @@ Theano requirements ...@@ -12,7 +12,7 @@ Theano requirements
------------------- -------------------
- git_: A distributed revision control system (RCS). - git_: A distributed revision control system (RCS).
- nosetests_: A system for unit tests. - pytest_: A system for unit testing.
- numpy_: A library for efficient numerical computing. - numpy_: A library for efficient numerical computing.
- python_: The programming language Theano is for. - python_: The programming language Theano is for.
- scipy_: A library for scientific computing. - scipy_: A library for scientific computing.
...@@ -38,7 +38,7 @@ This is a sort of memo for developers and would-be developers. ...@@ -38,7 +38,7 @@ This is a sort of memo for developers and would-be developers.
.. _git: http://git-scm.com/ .. _git: http://git-scm.com/
.. _nosetests: http://nose.readthedocs.org/en/latest/ .. _pytest: http://docs.pytest.org/en/latest/
.. _numpy: http://numpy.scipy.org/ .. _numpy: http://numpy.scipy.org/
.. _python: http://www.python.org .. _python: http://www.python.org
.. _scipy: http://scipy.org/ .. _scipy: http://scipy.org/
...@@ -54,4 +54,3 @@ This is a sort of memo for developers and would-be developers. ...@@ -54,4 +54,3 @@ This is a sort of memo for developers and would-be developers.
.. _unpython: http://code.google.com/p/unpython/ .. _unpython: http://code.google.com/p/unpython/
.. _pycppad: http://www.seanet.com/~bradbell/pycppad/index.xml .. _pycppad: http://www.seanet.com/~bradbell/pycppad/index.xml
.. _shedskin: http://shed-skin.blogspot.com/ .. _shedskin: http://shed-skin.blogspot.com/
...@@ -35,9 +35,6 @@ Requirements ...@@ -35,9 +35,6 @@ Requirements
|PlatformCompiler| |PlatformCompiler|
**Highly recommended.** Theano can fall back on a NumPy-based Python execution model, but a C compiler allows for vastly faster execution. **Highly recommended.** Theano can fall back on a NumPy-based Python execution model, but a C compiler allows for vastly faster execution.
`nose <http://nose.readthedocs.io/en/latest/>`_ >= 1.3.0
Recommended, to run Theano's test-suite.
`Sphinx <http://sphinx.pocoo.org/>`_ >= 0.5.1, `pygments <http://pygments.org/>`_ `Sphinx <http://sphinx.pocoo.org/>`_ >= 0.5.1, `pygments <http://pygments.org/>`_
For building the documentation. LaTeX_ and dvipng_ are also necessary for math to show up as images. For building the documentation. LaTeX_ and dvipng_ are also necessary for math to show up as images.
...@@ -83,7 +80,7 @@ Install requirements and optional packages ...@@ -83,7 +80,7 @@ Install requirements and optional packages
.. code-block:: bash .. code-block:: bash
conda install numpy scipy mkl <nose> <sphinx> <pydot-ng> conda install numpy scipy mkl pytest <sphinx> <pydot-ng>
* Arguments between <...> are optional. * Arguments between <...> are optional.
......
...@@ -110,32 +110,6 @@ write an Op:** ...@@ -110,32 +110,6 @@ write an Op:**
UnaryScalarOp is the same as scalar.ScalarOp with member variable nin=1. UnaryScalarOp is the same as scalar.ScalarOp with member variable nin=1.
**give an example of this** **give an example of this**
=======================================================
Documentation on how to write tests
=======================================================
Guillaume can you make sure to hit these points:
* What are canonical examples of tests?
* What are the different test patterns?
* nnet.py:
* What is going on with test1, test2, test3, test4?
* What is the right eq function to use?
* There are a lot of tests that define their own epsilon, but this should be standardized. e.g. in test_elemwise.py ``self.assertTrue((numpy.abs(f(xv) - zv) < 1e-10).all())``
* If the expected variable of a test is that an Exception is thrown, how do we correctly detect and handle that?
nosetests has ``assertRaises``
* Convention is that all test files must start with ``test_``, not
``_test_``, so rename all that use the old convention?
======================================================= =======================================================
How to use the PrintOp How to use the PrintOp
======================================================= =======================================================
......
sphinx>=1.3.0 sphinx>=1.3.0
pygments pygments
nose>=1.3.0 pytest
numpy numpy
gnumpy gnumpy
pydot pydot
pydot2 pydot2
Cython Cython
scipy==0.13 scipy==0.13
[nosetest]
match=^test
nocapture=1
[flake8] [flake8]
ignore=E501,E123,E133,FI12,FI14,FI15,FI50,FI51,FI53,W503,W504,E203,C901,E231,E741 ignore=E501,E123,E133,FI12,FI14,FI15,FI50,FI51,FI53,W503,W504,E203,C901,E231,E741
per-file-ignores = per-file-ignores =
......
...@@ -127,12 +127,7 @@ def do_setup(): ...@@ -127,12 +127,7 @@ def do_setup():
"theano.misc": ["*.sh"], "theano.misc": ["*.sh"],
"theano.d3viz": ["html/*", "css/*", "js/*"], "theano.d3viz": ["html/*", "css/*", "js/*"],
}, },
entry_points={ entry_points={"console_scripts": ["theano-cache = bin.theano_cache:main",]},
"console_scripts": [
"theano-cache = bin.theano_cache:main",
"theano-nose = bin.theano_nose:main",
]
},
keywords=" ".join( keywords=" ".join(
[ [
"theano", "theano",
......
...@@ -169,16 +169,6 @@ from theano.gradient import Rop, Lop, grad, subgraph_grad ...@@ -169,16 +169,6 @@ from theano.gradient import Rop, Lop, grad, subgraph_grad
# needed during that phase. # needed during that phase.
import theano.tests import theano.tests
if hasattr(theano.tests, "TheanoNoseTester"):
test = theano.tests.TheanoNoseTester().test
else:
def test():
raise ImportError(
"The nose module is not installed." " It is needed for Theano tests."
)
if ( if (
config.device.startswith("cuda") config.device.startswith("cuda")
or config.device.startswith("opencl") or config.device.startswith("opencl")
......
...@@ -78,7 +78,7 @@ def thunk_hook(type, value, trace): ...@@ -78,7 +78,7 @@ def thunk_hook(type, value, trace):
Notes Notes
----- -----
This hook replaced by nosetests, so it does not run in nose tests. This hook replaced in testing, so it does not run.
""" """
log_thunk_trace(value) log_thunk_trace(value)
......
#!/usr/bin/env python #!/usr/bin/env python
# Without args, this script executes all its tests like `nosetests -vs` # Without args, this script executes all its tests like `pytest -vs`
# python check_dnn_conv.py # python check_dnn_conv.py
# If there is only one arg `infos`, this script prints some infos about # If there is only one arg `infos`, this script prints some infos about
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
# If there is only one arg `list`, this script prints all test cases without running them. # If there is only one arg `list`, this script prints all test cases without running them.
# python check_dnn_conv.py list # python check_dnn_conv.py list
# Else, any arg will be directly passed to nosetests. # Else, any arg will be directly passed to pytest.
# python check_dnn_conv.py -xvs # nosetests: verbose mode, capture output, exit at first error. # python check_dnn_conv.py -xvs # verbose mode, capture output, exit at first error.
from __future__ import absolute_import, print_function, division from __future__ import absolute_import, print_function, division
...@@ -885,10 +885,7 @@ class BaseTestDnnConv(object): ...@@ -885,10 +885,7 @@ class BaseTestDnnConv(object):
self.should_fail(self.run_conv_gradweight, *args) self.should_fail(self.run_conv_gradweight, *args)
def get_expected_tcount(self): def get_expected_tcount(self):
""" """Utility function to get expected test count without actually running pytest."""
Utility function to get expected test count
without actually run nosetests.
"""
return ( return (
sum(1 for t in self.test_fwd()) sum(1 for t in self.test_fwd())
+ sum(1 for t in self.test_gradweight()) + sum(1 for t in self.test_gradweight())
......
...@@ -33,15 +33,13 @@ if [ "$1" == "--buildbot" ]; then ...@@ -33,15 +33,13 @@ if [ "$1" == "--buildbot" ]; then
git rev-parse HEAD git rev-parse HEAD
#Run tests from inside the Theano directory to prevent import problem. #Run tests from inside the Theano directory to prevent import problem.
# PROFILING="--with-coverage --cover-package=theano" # PROFILING="--with-coverage --cover-package=theano"
NOSETESTS=${ROOT_CWD}/Theano/bin/theano-nose
export PYTHONPATH=${ROOT_CWD}:$PYTHONPATH export PYTHONPATH=${ROOT_CWD}:$PYTHONPATH
else else
ROOT_CWD=. ROOT_CWD=.
COMPILEDIR=`python -c "from __future__ import print_function; import theano; print(theano.config.compiledir)"|tail -1` COMPILEDIR=`python -c "from __future__ import print_function; import theano; print(theano.config.compiledir)"|tail -1`
NOSETESTS=`python -c "from __future__ import print_function; import theano; print(theano.__path__[0])"|tail -1`/../bin/theano-nose
fi fi
# nosetests xunit for test profiling # tests xunit for test profiling
XUNIT="--with-xunit --xunit-file=" XUNIT="--with-xunit --xunit-file="
echo "Number of elements in the compiledir:" echo "Number of elements in the compiledir:"
...@@ -65,23 +63,23 @@ FLAGS=${FLAGS},device=cpu,floatX=float64 ...@@ -65,23 +63,23 @@ FLAGS=${FLAGS},device=cpu,floatX=float64
if [ "$RELEASE" ]; then if [ "$RELEASE" ]; then
echo "Executing tests with default mode and compute_test_value" echo "Executing tests with default mode and compute_test_value"
date date
THEANO_FLAGS=${FLAGS},compute_test_value=ignore ${NOSETESTS} ${ARGS} THEANO_FLAGS=${FLAGS},compute_test_value=ignore pytest ${ARGS}
echo "Number of elements in the compiledir:" echo "Number of elements in the compiledir:"
ls ${COMPILEDIR}|wc -l ls ${COMPILEDIR}|wc -l
echo echo
echo "Executing tests with linker=vm,floatX=float32" echo "Executing tests with linker=vm,floatX=float32"
echo "THEANO_FLAGS=${FLAGS},linker=vm,floatX=float32 ${NOSETESTS} ${ARGS}" echo "THEANO_FLAGS=${FLAGS},linker=vm,floatX=float32 pytest ${ARGS}"
date date
THEANO_FLAGS=${FLAGS},linker=vm,floatX=float32 ${NOSETESTS} ${ARGS} THEANO_FLAGS=${FLAGS},linker=vm,floatX=float32 pytest ${ARGS}
echo "Number of elements in the compiledir:" echo "Number of elements in the compiledir:"
ls ${COMPILEDIR}|wc -l ls ${COMPILEDIR}|wc -l
echo echo
echo "Executing tests with cxx=" echo "Executing tests with cxx="
echo "THEANO_FLAGS=${FLAGS},cxx= ${NOSETESTS} ${ARGS}" echo "THEANO_FLAGS=${FLAGS},cxx= pytest ${ARGS}"
date date
THEANO_FLAGS=${FLAGS},cxx= ${NOSETESTS} ${ARGS} THEANO_FLAGS=${FLAGS},cxx= pytest ${ARGS}
echo "Number of elements in the compiledir:" echo "Number of elements in the compiledir:"
ls ${COMPILEDIR}|wc -l ls ${COMPILEDIR}|wc -l
echo echo
...@@ -90,27 +88,27 @@ fi ...@@ -90,27 +88,27 @@ fi
echo "Executing tests with mode=FAST_RUN" echo "Executing tests with mode=FAST_RUN"
FILE=${ROOT_CWD}/theano_fastrun_tests.xml FILE=${ROOT_CWD}/theano_fastrun_tests.xml
echo "THEANO_FLAGS=cmodule.warn_no_version=True,${FLAGS},mode=FAST_RUN ${NOSETESTS} ${PROFILING} ${ARGS} ${XUNIT}${FILE}" echo "THEANO_FLAGS=cmodule.warn_no_version=True,${FLAGS},mode=FAST_RUN pytest ${PROFILING} ${ARGS} ${XUNIT}${FILE}"
date date
THEANO_FLAGS=cmodule.warn_no_version=True,${FLAGS},mode=FAST_RUN ${NOSETESTS} ${PROFILING} ${ARGS} ${XUNIT}${FILE} THEANO_FLAGS=cmodule.warn_no_version=True,${FLAGS},mode=FAST_RUN pytest ${PROFILING} ${ARGS} ${XUNIT}${FILE}
echo "Number of elements in the compiledir:" echo "Number of elements in the compiledir:"
ls ${COMPILEDIR}|wc -l ls ${COMPILEDIR}|wc -l
echo echo
echo "Executing tests with mode=FAST_RUN,floatX=float32" echo "Executing tests with mode=FAST_RUN,floatX=float32"
FILE=${ROOT_CWD}/theano_fastrun_float32_tests.xml FILE=${ROOT_CWD}/theano_fastrun_float32_tests.xml
echo "THEANO_FLAGS=${FLAGS},mode=FAST_RUN,floatX=float32 ${NOSETESTS} ${ARGS} ${XUNIT}${FILE}" echo "THEANO_FLAGS=${FLAGS},mode=FAST_RUN,floatX=float32 pytest ${ARGS} ${XUNIT}${FILE}"
date date
THEANO_FLAGS=${FLAGS},mode=FAST_RUN,floatX=float32 ${NOSETESTS} ${ARGS} ${XUNIT}${FILE} THEANO_FLAGS=${FLAGS},mode=FAST_RUN,floatX=float32 pytest ${ARGS} ${XUNIT}${FILE}
echo "Number of elements in the compiledir:" echo "Number of elements in the compiledir:"
ls ${COMPILEDIR}|wc -l ls ${COMPILEDIR}|wc -l
echo echo
echo "Executing tests with linker=vm,vm.lazy=True,floatX=float32" echo "Executing tests with linker=vm,vm.lazy=True,floatX=float32"
FILE=${ROOT_CWD}/theano_fastrun_float32_lazyvm_tests.xml FILE=${ROOT_CWD}/theano_fastrun_float32_lazyvm_tests.xml
echo "THEANO_FLAGS=${FLAGS},linker=vm,vm.lazy=True,floatX=float32 ${NOSETESTS} ${ARGS} ${XUNIT}${FILE}" echo "THEANO_FLAGS=${FLAGS},linker=vm,vm.lazy=True,floatX=float32 pytest ${ARGS} ${XUNIT}${FILE}"
date date
THEANO_FLAGS=${FLAGS},linker=vm,vm.lazy=True,floatX=float32 ${NOSETESTS} ${ARGS} ${XUNIT}${FILE} THEANO_FLAGS=${FLAGS},linker=vm,vm.lazy=True,floatX=float32 pytest ${ARGS} ${XUNIT}${FILE}
echo "Number of elements in the compiledir:" echo "Number of elements in the compiledir:"
ls ${COMPILEDIR}|wc -l ls ${COMPILEDIR}|wc -l
echo echo
...@@ -119,9 +117,9 @@ echo ...@@ -119,9 +117,9 @@ echo
seed=$RANDOM seed=$RANDOM
echo "Executing tests with mode=DEBUG_MODE with seed of the day $seed" echo "Executing tests with mode=DEBUG_MODE with seed of the day $seed"
FILE=${ROOT_CWD}/theano_debug_tests.xml FILE=${ROOT_CWD}/theano_debug_tests.xml
echo "THEANO_FLAGS=${FLAGS},unittests.rseed=$seed,mode=DEBUG_MODE,DebugMode.check_strides=0,DebugMode.patience=3,DebugMode.check_preallocated_output= ${NOSETESTS} ${ARGS} ${XUNIT}${FILE}" echo "THEANO_FLAGS=${FLAGS},unittests.rseed=$seed,mode=DEBUG_MODE,DebugMode.check_strides=0,DebugMode.patience=3,DebugMode.check_preallocated_output= pytest ${ARGS} ${XUNIT}${FILE}"
date date
THEANO_FLAGS=${FLAGS},unittests.rseed=$seed,mode=DEBUG_MODE,DebugMode.check_strides=0,DebugMode.patience=3,DebugMode.check_preallocated_output= ${NOSETESTS} ${ARGS} ${XUNIT}${FILE} THEANO_FLAGS=${FLAGS},unittests.rseed=$seed,mode=DEBUG_MODE,DebugMode.check_strides=0,DebugMode.patience=3,DebugMode.check_preallocated_output= pytest ${ARGS} ${XUNIT}${FILE}
echo "Number of elements in the compiledir:" echo "Number of elements in the compiledir:"
ls ${COMPILEDIR}|wc -l ls ${COMPILEDIR}|wc -l
...@@ -132,9 +130,9 @@ echo ...@@ -132,9 +130,9 @@ echo
# with --batch=1000" # The buildbot freeze sometimes when collecting the tests to run # with --batch=1000" # The buildbot freeze sometimes when collecting the tests to run
echo "Executing tests with mode=FAST_COMPILE" echo "Executing tests with mode=FAST_COMPILE"
FILE=${ROOT_CWD}/theano_fastcompile_tests.xml FILE=${ROOT_CWD}/theano_fastcompile_tests.xml
echo "THEANO_FLAGS=${FLAGS},mode=FAST_COMPILE ${NOSETESTS} ${ARGS} ${XUNIT}${FILE}" echo "THEANO_FLAGS=${FLAGS},mode=FAST_COMPILE pytest ${ARGS} ${XUNIT}${FILE}"
date date
THEANO_FLAGS=${FLAGS},mode=FAST_COMPILE ${NOSETESTS} ${ARGS} ${XUNIT}${FILE} THEANO_FLAGS=${FLAGS},mode=FAST_COMPILE pytest ${ARGS} ${XUNIT}${FILE}
echo "Number of elements in the compiledir:" echo "Number of elements in the compiledir:"
ls ${COMPILEDIR}|wc -l ls ${COMPILEDIR}|wc -l
......
...@@ -52,7 +52,7 @@ def makeSharedTester( ...@@ -52,7 +52,7 @@ def makeSharedTester(
:param ref_fct_: A reference function that should return the same value as the theano_fct_ :param ref_fct_: A reference function that should return the same value as the theano_fct_
:param cast_value_: A callable that cast an ndarray into the internal shared variable representation :param cast_value_: A callable that cast an ndarray into the internal shared variable representation
:param name: This string is used to set the returned class' __name__ :param name: This string is used to set the returned class' __name__
attribute. This is needed for nosetests to properly tag the attribute. This is needed for tests to properly tag the
test with its correct name, rather than use the generic test with its correct name, rather than use the generic
SharedTester name. This parameter is mandatory (keeping the SharedTester name. This parameter is mandatory (keeping the
default None value will raise an error), and must be set to default None value will raise an error), and must be set to
......
from __future__ import absolute_import, print_function, division
try:
from theano.tests.main import main, TheanoNoseTester
except ImportError:
pass
from __future__ import absolute_import, print_function, division
import os
import unittest
import sys
try:
from numpy.testing.nosetester import NoseTester
except ImportError:
# The tester has been moved in recent versions of numpy
from numpy.testing._private.nosetester import NoseTester
# This class contains code adapted from NumPy,
# numpy/testing/nosetester.py,
# Copyright (c) 2005-2011, NumPy Developers
class TheanoNoseTester(NoseTester):
"""
Nose test runner.
This class enables running nose tests from inside Theano,
by calling theano.test().
This version is more adapted to what we want than Numpy's one.
"""
def _test_argv(self, verbose, extra_argv):
"""
Generate argv for nosetest command
:type verbose: int
:param verbose: Verbosity value for test outputs, in the range 1-10.
Default is 1.
:type extra_argv: list
:param extra_argv: List with any extra arguments to pass to nosetests.
"""
# self.package_path = os.path.abspath(self.package_path)
argv = [__file__, self.package_path]
argv += ["--verbosity", str(verbose)]
if extra_argv:
argv += extra_argv
return argv
def _show_system_info(self):
import theano
print("Theano version %s" % theano.__version__)
theano_dir = os.path.dirname(theano.__file__)
print("theano is installed in %s" % theano_dir)
super(TheanoNoseTester, self)._show_system_info()
def prepare_test_args(
self,
verbose=1,
extra_argv=None,
coverage=False,
capture=True,
knownfailure=True,
):
"""
Prepare arguments for the `test` method.
Takes the same arguments as `test`.
"""
import nose.plugins.builtin
# compile argv
argv = self._test_argv(verbose, extra_argv)
# numpy way of doing coverage
if coverage:
argv += [
"--cover-package=%s" % self.package_name,
"--with-coverage",
"--cover-tests",
"--cover-inclusive",
"--cover-erase",
]
# Capture output only if needed
if not capture:
argv += ["-s"]
# construct list of plugins
plugins = []
if knownfailure:
from numpy.testing.noseclasses import KnownFailure
plugins.append(KnownFailure())
plugins += [p() for p in nose.plugins.builtin.plugins]
return argv, plugins
def test(
self,
verbose=1,
extra_argv=None,
coverage=False,
capture=True,
knownfailure=True,
):
"""
Run tests for module using nose.
:type verbose: int
:param verbose: Verbosity value for test outputs, in the range 1-10.
Default is 1.
:type extra_argv: list
:param extra_argv: List with any extra arguments to pass to nosetests.
:type coverage: bool
:param coverage: If True, report coverage of Theano
code. Default is False.
:type capture: bool
:param capture: If True, capture the standard output of the tests, like
nosetests does in command-line. The output of failing
tests will be displayed at the end. Default is True.
:type knownfailure: bool
:param knownfailure: If True, tests raising KnownFailureTest will
not be considered Errors nor Failure, but reported as
"known failures" and treated quite like skipped tests.
Default is True.
:returns: Returns the result of running the tests as a
``nose.result.TextTestResult`` object.
"""
from nose.config import Config
from nose.plugins.manager import PluginManager
from numpy.testing.noseclasses import NumpyTestProgram
# Many Theano tests suppose device=cpu, so we need to raise an
# error if device==gpu.
if not os.path.exists("theano/__init__.py"):
try:
from theano import config
if config.device != "cpu":
raise ValueError(
"Theano tests must be run with device=cpu."
" This will also run GPU tests when possible.\n"
" If you want GPU-related tests to run on a"
" specific GPU device, and not the default one,"
" you should use the init_gpu_device theano flag."
)
except ImportError:
pass
# cap verbosity at 3 because nose becomes *very* verbose beyond that
verbose = min(verbose, 3)
self._show_system_info()
cwd = os.getcwd()
if self.package_path in os.listdir(cwd):
# The tests give weird errors if the package to test is
# in current directory.
raise RuntimeError(
(
"This function does not run correctly when, at the time "
"theano was imported, the working directory was theano's "
"parent directory. You should exit your Python prompt, change "
"directory, then launch Python again, import theano, then "
"launch theano.test()."
)
)
argv, plugins = self.prepare_test_args(
verbose, extra_argv, coverage, capture, knownfailure
)
# The "plugins" keyword of NumpyTestProgram gets ignored if config is
# specified. Moreover, using "addplugins" instead can lead to strange
# errors. So, we specify the plugins in the Config as well.
cfg = Config(includeExe=True, plugins=PluginManager(plugins=plugins))
t = NumpyTestProgram(argv=argv, exit=False, config=cfg)
return t.result
def main(modulename):
if 0:
unittest.main()
elif len(sys.argv) == 2 and sys.argv[1] == "--debug":
module = __import__(modulename)
tests = unittest.TestLoader().loadTestsFromModule(module)
tests.debug()
elif len(sys.argv) == 1:
module = __import__(modulename)
tests = unittest.TestLoader().loadTestsFromModule(module)
unittest.TextTestRunner(verbosity=2).run(tests)
else:
print("options: [--debug]")
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论