提交 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
global-include *.pkl
recursive-include doc
include bin/theano-cache
include bin/theano-nose
prune .jenkins
prune .travis
include versioneer.py
......
差异被折叠。
......@@ -25,7 +25,7 @@ requirements:
test:
requires:
- nose >=1.3.0
- pytest
imports:
- theano
......
......@@ -38,14 +38,14 @@ To get up to speed, you'll need to
trickier files (like tensor.py).
- Go through the `NumPy documentation`_.
- 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/
.. _reStructuredText: http://docutils.sourceforge.net/rst.html
.. _Allowed docstring sections in Napoleon: https://sphinxcontrib-napoleon.readthedocs.org/en/latest/#docstring-sections
.. _NumPy documentation: http://docs.scipy.org/numpy/
.. _unittest: http://docs.python.org/library/unittest.html
.. _nose: http://nose.readthedocs.org/en/latest/
.. _pytest: http://docs.pytest.org/en/latest/
.. _quality_contributions:
......@@ -53,16 +53,16 @@ To get up to speed, you'll need to
Requirements for Quality Contributions
======================================
* All the code should be properly tested.
* All the code should be properly tested.
* The code should be compatible with Python 2.7 and above, as well as
Python 3.4 and above (using `six` if needed).
* All the code should respect the
* All the code should respect the
`PEP8 Code Style Guide <http://www.python.org/dev/peps/pep-0008>`_.
* The docstrings of all the classes and functions should respect the
`PEP257 <https://www.python.org/dev/peps/pep-0257/>`_ rules and follow the
`PEP257 <https://www.python.org/dev/peps/pep-0257/>`_ rules and follow the
`Numpy docstring standard
<https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt>`_.
......@@ -85,7 +85,7 @@ make sure there are no global impacts.
Also, if you are changing GPU code, Travis doesn't test that, because
there are no GPUs on the test nodes.
To run the test suite with the default options, see
To run the test suite with the default options, see
:ref:`test_theano`.
Each night we execute all the unit tests automatically, with several
......@@ -101,8 +101,8 @@ this script:
theano/misc/do_nightly_build
This script accepts arguments that it forwards to nosetests. You can
run only some tests or enable pdb by giving the equivalent nosetests
This script accepts arguments that it forwards to ``pytest``. You can
run only some tests or enable pdb by giving the equivalent ``pytest``
parameters.
Setting up your Editor for PEP8
......@@ -130,7 +130,7 @@ To setup VIM:
.. warning:: Starting version 3.0.0, flake8 changed its dependencies and
moved its Python API to a legacy module, breaking Theano's flake8 tests.
We recommend using a version prior to 3.
We recommend using a version prior to 3.
.. note:: You can use ``easy_install`` instead of ``pip``, and ``pep8``
instead of ``flake8`` if you prefer. The important thing is that the
......@@ -167,9 +167,9 @@ To setup VIM:
let g:syntastic_auto_jump = 0 "do not jump to errors when detected
#. Open a new vim and run ``:PluginInstall`` to automatically install the
plugins. When the installation is done, close the installation "window"
with ``:q``.
From now on Vim will check for PEP8 errors and highlight them whenever a
plugins. When the installation is done, close the installation "window"
with ``:q``.
From now on Vim will check for PEP8 errors and highlight them whenever a
file is saved.
A few useful commands
......@@ -237,7 +237,6 @@ Then in your ``~/.emacs`` file, add this:
(require 'epy-completion) ;; If you want the autocompletion settings [optional]
(require 'epy-editing) ;; For configurations related to editing [optional]
;; [newer version of emacs-for-python]
(require 'epy-nose) ;; For shortcut to call nosetests [optional]
;; Define f10 to previous error
;; Define f11 to next error
......@@ -270,20 +269,20 @@ Documentation and docstrings
* The documentation should be written in `reStructuredText`_ and the
docstrings of all the classes and functions should respect the
`PEP257 <https://www.python.org/dev/peps/pep-0257/>`_ rules and follow the
`PEP257 <https://www.python.org/dev/peps/pep-0257/>`_ rules and follow the
`Numpy docstring standard
<https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt>`_.
* Split the docstrings in sections, according to the `Allowed docstring
sections in Napoleon`_
* To cross-reference other objects (e.g. reference other classes or methods) in
* To cross-reference other objects (e.g. reference other classes or methods) in
the docstrings, use the
`cross-referencing objects <http://www.sphinx-doc.org/en/stable/domains.html#cross-referencing-python-objects>`_
syntax. ``:py`` can be omitted, see e.g. this
`cross-referencing objects <http://www.sphinx-doc.org/en/stable/domains.html#cross-referencing-python-objects>`_
syntax. ``:py`` can be omitted, see e.g. this
`stackoverflow answer <http://stackoverflow.com/a/7754189>`_.
* See :ref:`metadocumentation`, for some information on how to generate the
* See :ref:`metadocumentation`, for some information on how to generate the
documentation.
......@@ -449,7 +448,7 @@ Once your code is ready for others to review, you need to commit all the changes
branch to your github fork first:
.. code-block:: bash
git commit -a -m "your message here"
.. code-block:: bash
......
......@@ -546,7 +546,7 @@ How To Test it
Theano has some functionalities to simplify testing. These help test the
``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
^^^^^^^^^^^
......@@ -676,50 +676,7 @@ For instance, to verify the Rop method of the DoubleOp, you can use this:
Running Your Tests
^^^^^^^^^^^^^^^^^^
To perform your tests, you may select either one of the three
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/>`_.
To perform your tests, simply run ``pytest``.
In-file
"""""""
......
......@@ -557,8 +557,8 @@ storage with the right shape and number of dimensions.
The ``c_code`` method accepts variable names as arguments (``name``, ``inp``,
``out``, ``sub``) and returns a C code fragment that computes the expression
output. In case of error, the ``%(fail)s`` statement cleans up and returns
``out``, ``sub``) and returns a C code fragment that computes the expression
output. In case of error, the ``%(fail)s`` statement cleans up and returns
properly.
More complex C Op example
......@@ -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).
Then you must start Python inside GDB and in it start your Python
process (e.g. theano-nose):
process:
.. code-block:: sh
$gdb python
(gdb)r bin/theano-nose theano/
(gdb)r pytest theano/
`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:
.. code-block:: python
try:
import scipy.linalg
imported_scipy = True
......@@ -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.")
...
from nose.plugins.skip import SkipTest
class TestSomeOp(utt.InferShapeTester):
...
@pytest.mark.skipif(not imported_scipy, reason="SciPy needed for the SomeOp op.")
def test_infer_shape(self):
if not imported_scipy:
raise SkipTest("SciPy needed for the SomeOp op.")
...
.. _sparse_ops:
......
......@@ -225,9 +225,9 @@ type this:
.. code-block:: bash
THEANO_FLAGS='mode=FAST_COMPILE' theano-nose
THEANO_FLAGS='mode=FAST_RUN' theano-nose
THEANO_FLAGS='mode=DebugMode' theano-nose
THEANO_FLAGS='mode=FAST_COMPILE' pytest
THEANO_FLAGS='mode=FAST_RUN' pytest
THEANO_FLAGS='mode=DebugMode' pytest
.. _random_value_in_tests:
......@@ -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
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
``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
making sure unittests are deterministic.
......@@ -285,7 +285,7 @@ Similarly, to provide a seed to ``numpy.random.RandomState``, simply use:
# OR providing an explicit seed
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
(against which we compare the theano outputs). These must then be
determined "algorithmically". Although this represents more work, the
......
.. include:: css.inc
.. _install_centos6:
CentOS 6 Installation Instructions
##################################
......@@ -25,5 +25,5 @@ Requirements through System Packages (not recommended)
.. 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
......@@ -12,9 +12,9 @@ Mac OS Installation Instructions
page <http://deeplearning.net/software/theano_versions/dev/install_macos.html>`_.
There are various ways to install Theano dependencies on a Mac. Here
we describe the process in detail with Anaconda, Homebrew or MacPorts
but if you did it differently and it worked, please let us know the
details on the `theano-users`_ mailing-list, so that we can add
we describe the process in detail with Anaconda, Homebrew or MacPorts
but if you did it differently and it worked, please let us know the
details on the `theano-users`_ mailing-list, so that we can add
alternative instructions here.
.. _theano-users: http://groups.google.com/group/theano-users?pli=1
......@@ -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
gcc binaries that you installed with MacPorts are visible first).
- MacPorts does not create automatically ``nosetests`` and ``pip`` symlinks
pointing to the MacPorts version, so you can add them yourself with
- MacPorts does not automatically create ``pip`` symlinks pointing to the
MacPorts version; you can add them yourself with
.. 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
......@@ -13,7 +13,7 @@ NVIDIA Jetson TX1 embedded platform
.. 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
Gentoo
......
......@@ -32,7 +32,7 @@ For Ubuntu 16.04 with cuda 7.5
.. 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
# 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:
.. 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:
.. 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
For Ubuntu 11.04:
.. 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)
-----------------------------------------
......
......@@ -24,7 +24,7 @@ Install requirements and optional packages
.. 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::
......
......@@ -12,7 +12,7 @@ Theano requirements
-------------------
- 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.
- python_: The programming language Theano is for.
- scipy_: A library for scientific computing.
......@@ -38,7 +38,7 @@ This is a sort of memo for developers and would-be developers.
.. _git: http://git-scm.com/
.. _nosetests: http://nose.readthedocs.org/en/latest/
.. _pytest: http://docs.pytest.org/en/latest/
.. _numpy: http://numpy.scipy.org/
.. _python: http://www.python.org
.. _scipy: http://scipy.org/
......@@ -54,4 +54,3 @@ This is a sort of memo for developers and would-be developers.
.. _unpython: http://code.google.com/p/unpython/
.. _pycppad: http://www.seanet.com/~bradbell/pycppad/index.xml
.. _shedskin: http://shed-skin.blogspot.com/
......@@ -35,9 +35,6 @@ Requirements
|PlatformCompiler|
**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/>`_
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
.. 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.
......
......@@ -110,32 +110,6 @@ write an Op:**
UnaryScalarOp is the same as scalar.ScalarOp with member variable nin=1.
**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
=======================================================
......
sphinx>=1.3.0
pygments
nose>=1.3.0
pytest
numpy
gnumpy
pydot
pydot2
Cython
scipy==0.13
[nosetest]
match=^test
nocapture=1
[flake8]
ignore=E501,E123,E133,FI12,FI14,FI15,FI50,FI51,FI53,W503,W504,E203,C901,E231,E741
per-file-ignores =
......
......@@ -127,12 +127,7 @@ def do_setup():
"theano.misc": ["*.sh"],
"theano.d3viz": ["html/*", "css/*", "js/*"],
},
entry_points={
"console_scripts": [
"theano-cache = bin.theano_cache:main",
"theano-nose = bin.theano_nose:main",
]
},
entry_points={"console_scripts": ["theano-cache = bin.theano_cache:main",]},
keywords=" ".join(
[
"theano",
......
......@@ -169,16 +169,6 @@ from theano.gradient import Rop, Lop, grad, subgraph_grad
# needed during that phase.
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 (
config.device.startswith("cuda")
or config.device.startswith("opencl")
......
......@@ -78,7 +78,7 @@ def thunk_hook(type, value, trace):
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)
......
#!/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
# If there is only one arg `infos`, this script prints some infos about
......@@ -10,8 +10,8 @@
# If there is only one arg `list`, this script prints all test cases without running them.
# python check_dnn_conv.py list
# Else, any arg will be directly passed to nosetests.
# python check_dnn_conv.py -xvs # nosetests: verbose mode, capture output, exit at first error.
# Else, any arg will be directly passed to pytest.
# python check_dnn_conv.py -xvs # verbose mode, capture output, exit at first error.
from __future__ import absolute_import, print_function, division
......@@ -885,10 +885,7 @@ class BaseTestDnnConv(object):
self.should_fail(self.run_conv_gradweight, *args)
def get_expected_tcount(self):
"""
Utility function to get expected test count
without actually run nosetests.
"""
"""Utility function to get expected test count without actually running pytest."""
return (
sum(1 for t in self.test_fwd())
+ sum(1 for t in self.test_gradweight())
......
......@@ -33,15 +33,13 @@ if [ "$1" == "--buildbot" ]; then
git rev-parse HEAD
#Run tests from inside the Theano directory to prevent import problem.
# PROFILING="--with-coverage --cover-package=theano"
NOSETESTS=${ROOT_CWD}/Theano/bin/theano-nose
export PYTHONPATH=${ROOT_CWD}:$PYTHONPATH
else
ROOT_CWD=.
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
# nosetests xunit for test profiling
# tests xunit for test profiling
XUNIT="--with-xunit --xunit-file="
echo "Number of elements in the compiledir:"
......@@ -65,23 +63,23 @@ FLAGS=${FLAGS},device=cpu,floatX=float64
if [ "$RELEASE" ]; then
echo "Executing tests with default mode and compute_test_value"
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:"
ls ${COMPILEDIR}|wc -l
echo
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
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:"
ls ${COMPILEDIR}|wc -l
echo
echo "Executing tests with cxx="
echo "THEANO_FLAGS=${FLAGS},cxx= ${NOSETESTS} ${ARGS}"
echo "THEANO_FLAGS=${FLAGS},cxx= pytest ${ARGS}"
date
THEANO_FLAGS=${FLAGS},cxx= ${NOSETESTS} ${ARGS}
THEANO_FLAGS=${FLAGS},cxx= pytest ${ARGS}
echo "Number of elements in the compiledir:"
ls ${COMPILEDIR}|wc -l
echo
......@@ -90,27 +88,27 @@ fi
echo "Executing tests with mode=FAST_RUN"
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
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:"
ls ${COMPILEDIR}|wc -l
echo
echo "Executing tests with mode=FAST_RUN,floatX=float32"
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
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:"
ls ${COMPILEDIR}|wc -l
echo
echo "Executing tests with linker=vm,vm.lazy=True,floatX=float32"
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
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:"
ls ${COMPILEDIR}|wc -l
echo
......@@ -119,9 +117,9 @@ echo
seed=$RANDOM
echo "Executing tests with mode=DEBUG_MODE with seed of the day $seed"
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
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:"
ls ${COMPILEDIR}|wc -l
......@@ -132,9 +130,9 @@ echo
# with --batch=1000" # The buildbot freeze sometimes when collecting the tests to run
echo "Executing tests with mode=FAST_COMPILE"
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
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:"
ls ${COMPILEDIR}|wc -l
......
......@@ -52,7 +52,7 @@ def makeSharedTester(
: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 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
SharedTester name. This parameter is mandatory (keeping the
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论