提交 98229fd2 authored 作者: carriepl's avatar carriepl

Merge pull request #3159 from nouiz/tests

Remove printing during test
...@@ -24,8 +24,8 @@ before_install: ...@@ -24,8 +24,8 @@ before_install:
- conda update --yes conda - conda update --yes conda
install: install:
- if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then conda create --yes -q -n pyenv mkl python=2.6 numpy=1.6.2 scipy=0.11 nose=1.1 pyparsing=1.5 pip flake8==2.3 six==1.9.0; fi - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then conda create --yes -q -n pyenv mkl python=2.6 numpy=1.6.2 scipy=0.11 nose=1.1 pyparsing=1.5 pip flake8==2.3 six==1.9.0 pep8==1.6.2 pyflakes==0.8.1; fi
- if [[ $TRAVIS_PYTHON_VERSION == '3.3' ]]; then conda create --yes -q -n pyenv mkl python=3.3 numpy=1.9.1 scipy=0.14.0 nose=1.3.4 pyparsing=1.5 pip flake8==2.3 six==1.9.0; fi - if [[ $TRAVIS_PYTHON_VERSION == '3.3' ]]; then conda create --yes -q -n pyenv mkl python=3.3 numpy=1.9.1 scipy=0.14.0 nose=1.3.4 pyparsing=1.5 pip flake8==2.3 six==1.9.0 pep8==1.6.2 pyflakes==0.8.1; fi
- source activate pyenv - source activate pyenv
- if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then pip install pydot; fi - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then pip install pydot; fi
- pip install . --no-deps - pip install . --no-deps
......
...@@ -20,12 +20,14 @@ but here are some guidelines for the major things to be aware of. ...@@ -20,12 +20,14 @@ but here are some guidelines for the major things to be aware of.
syntax: syntax:
.. code-block:: python .. code-block:: python
except Exception as e: except Exception as e:
... ...
* No tuple-unpacking in the argument list: * No tuple-unpacking in the argument list:
.. code-block:: python .. code-block:: python
def f(a, (b, c)): # wrong def f(a, (b, c)): # wrong
... ...
...@@ -35,6 +37,7 @@ but here are some guidelines for the major things to be aware of. ...@@ -35,6 +37,7 @@ but here are some guidelines for the major things to be aware of.
* Always use ``print(...)`` as a function, and add * Always use ``print(...)`` as a function, and add
.. code-block:: python .. code-block:: python
from __future__ import print_function from __future__ import print_function
At the top of files that use ``print``, above all other imports. At the top of files that use ``print``, above all other imports.
......
...@@ -76,11 +76,11 @@ installation and configuration, see :ref:`installing Theano <install>`. ...@@ -76,11 +76,11 @@ installation and configuration, see :ref:`installing Theano <install>`.
.. raw:: html .. raw:: html
<a href="https://crate.io/packages/Theano/"><img src="https://pypip.in/v/Theano/badge.png" alt="Latest PyPI version" /></a>&nbsp; <a href="https://crate.io/packages/Theano/"><img src="https://img.shields.io/pypi/v/Theano.svg" alt="Latest PyPI version" /></a>&nbsp;
.. raw:: html .. raw:: html
<a href="https://crate.io/packages/Theano/"><img src="https://pypip.in/d/Theano/badge.png" alt="Number of PyPI downloads" /></a>&nbsp; <a href="https://crate.io/packages/Theano/"><img src="https://img.shields.io/pypi/dm/Theano.svg" alt="Number of PyPI downloads" /></a>&nbsp;
.. _available on PyPI: http://pypi.python.org/pypi/Theano .. _available on PyPI: http://pypi.python.org/pypi/Theano
.. _Related Projects: https://github.com/Theano/Theano/wiki/Related-projects .. _Related Projects: https://github.com/Theano/Theano/wiki/Related-projects
......
.. _nanguardmode: .. _nanguardmode:
================= ===================
:mod:`nanguardmode` :mod:`nanguardmode`
================= ===================
.. module:: nanguardmode .. module:: nanguardmode
:platform: Unix, Windows :platform: Unix, Windows
......
...@@ -389,14 +389,18 @@ import theano and print the config variable, as in: ...@@ -389,14 +389,18 @@ import theano and print the config variable, as in:
.. attribute:: on_opt_error .. attribute:: on_opt_error
String value: 'warn', 'raise' or 'pdb' String value: 'warn', 'raise', 'pdb' or 'ignore'
Default: 'warn' Default: 'warn'
When a crash occurs while trying to apply some optimization, either warn When a crash occurs while trying to apply some optimization, either warn
the user and skip this optimization ('warn'), raise the exception the user and skip this optimization ('warn'), raise the exception
('raise'), or fall into the pdb debugger ('pdb'). ('raise'), fall into the pdb debugger ('pdb') or ignore it ('ignore').
We suggest to never use 'ignore' except in tests.
If you encounter a warning, report it on `theano-dev`_.
.. _theano-dev: http://groups.google.com/group/theano-dev
.. attribute:: assert_no_cpu_op .. attribute:: assert_no_cpu_op
......
...@@ -296,7 +296,7 @@ Tips: ...@@ -296,7 +296,7 @@ Tips:
"Why does my GPU function seem to be slow?" "Why does my GPU function seem to be slow?"
------------------------------------------ -------------------------------------------
When you compile a theano function, if you do not get the speedup that you expect over the When you compile a theano function, if you do not get the speedup that you expect over the
CPU performance of the same code. It is oftentimes due to the fact that some Ops might be running CPU performance of the same code. It is oftentimes due to the fact that some Ops might be running
...@@ -307,7 +307,7 @@ options: ...@@ -307,7 +307,7 @@ options:
* ``warn``: Raise a warning * ``warn``: Raise a warning
* ``pdb``: Stop with a pdb in the computational graph during the compilation * ``pdb``: Stop with a pdb in the computational graph during the compilation
* ``raise``: Raise an error, * ``raise``: Raise an error,
if there is a CPU Op in the computational graph. if there is a CPU Op in the computational graph.
It is possible to use this mode by providing the flag in THEANO_FLAGS, such as: It is possible to use this mode by providing the flag in THEANO_FLAGS, such as:
``THEANO_FLAGS="float32,device=gpu,assert_no_cpu_op='raise'" python test.py`` ``THEANO_FLAGS="float32,device=gpu,assert_no_cpu_op='raise'" python test.py``
......
...@@ -246,7 +246,7 @@ AddConfigVar( ...@@ -246,7 +246,7 @@ AddConfigVar(
'on_opt_error', 'on_opt_error',
("What to do when an optimization crashes: warn and skip it, raise " ("What to do when an optimization crashes: warn and skip it, raise "
"the exception, or fall into the pdb debugger."), "the exception, or fall into the pdb debugger."),
EnumStr('warn', 'raise', 'pdb'), EnumStr('warn', 'raise', 'pdb', 'ignore'),
in_c_key=False) in_c_key=False)
......
...@@ -1364,6 +1364,7 @@ class NavigatorOptimizer(Optimizer): ...@@ -1364,6 +1364,7 @@ class NavigatorOptimizer(Optimizer):
def warn(exc, nav, repl_pairs, local_opt): def warn(exc, nav, repl_pairs, local_opt):
"""failure_callback for NavigatorOptimizer: print traceback """failure_callback for NavigatorOptimizer: print traceback
""" """
if config.on_opt_error != 'ignore':
_logger.error("Optimization failure due to: %s" % str(local_opt)) _logger.error("Optimization failure due to: %s" % str(local_opt))
_logger.error("TRACEBACK:") _logger.error("TRACEBACK:")
_logger.error(traceback.format_exc()) _logger.error(traceback.format_exc())
......
...@@ -106,15 +106,17 @@ def test_local_assert_no_cpu_op(): ...@@ -106,15 +106,17 @@ def test_local_assert_no_cpu_op():
mode_local_assert = mode_local_assert.excluding("local_gpu_elemwise_1") mode_local_assert = mode_local_assert.excluding("local_gpu_elemwise_1")
old = config.assert_no_cpu_op old = config.assert_no_cpu_op
old2 = config.on_opt_error
# If the flag is raise # If the flag is raise
try: try:
config.assert_no_cpu_op = 'raise' config.assert_no_cpu_op = 'raise'
config.on_opt_error = 'ignore'
assert_raises(AssertionError, theano.function, assert_raises(AssertionError, theano.function,
[], out, mode=mode_local_assert) [], out, mode=mode_local_assert)
finally: finally:
config.assert_no_cpu_op = old config.assert_no_cpu_op = old
config.on_opt_error = old2
# If the flag is ignore # If the flag is ignore
try: try:
......
...@@ -4298,6 +4298,12 @@ class T_Scan(unittest.TestCase): ...@@ -4298,6 +4298,12 @@ class T_Scan(unittest.TestCase):
# There should be 3 outputs greater than 10: prior_result[0] at step 3, # There should be 3 outputs greater than 10: prior_result[0] at step 3,
# and prior_result[1] at steps 2 and 3. # and prior_result[1] at steps 2 and 3.
if theano.config.mode in ["DEBUG_MODE", "DebugMode"]:
# DebugMode will run all the intermediate nodes, so we
# should expect a multiple of 3, not exactly 3.
assert detect_large_outputs.large_count % 3 == 0
else:
assert detect_large_outputs.large_count == 3 assert detect_large_outputs.large_count == 3
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论