Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip test on Theano<=1.0.3 and NumPy>=1.16.0 #6001

Merged
merged 6 commits into from
Jan 16, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion chainer/links/theano/theano_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ class TheanoFunction(link.Link):
and backward calculation from inputs and ouptuts. And then, it sends data
in :class:`chainer.Variable` to the function and gets results from Theano.

.. admonition:: Example
.. rubric:: Example

.. doctest::
# See chainer/chainer#5997
:skipif: os.environ.get('READTHEDOCS') != 'True' \
Copy link
Member Author

@niboshi niboshi Jan 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the readthedocs build, this skipif should never be effective, because that would cause the code to disappear from the documentation.

and chainer.testing.is_requires_satisfied( \
'Theano<=1.0.3', 'numpy>=1.16.0')

>>> import theano
>>> x = theano.tensor.fvector()
Expand Down
1 change: 1 addition & 0 deletions chainer/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from chainer.testing.backend import inject_backend_tests # NOQA
from chainer.testing.distribution_test import distribution_unittest # NOQA
from chainer.testing.helper import assert_warns # NOQA
from chainer.testing.helper import is_requires_satisfied # NOQA
from chainer.testing.helper import patch # NOQA
from chainer.testing.helper import with_requires # NOQA
from chainer.testing.helper import without_requires # NOQA
Expand Down
18 changes: 18 additions & 0 deletions chainer/testing/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,24 @@ def without_requires(*requirements):
return unittest.skipIf(skip, msg)


def is_requires_satisfied(*requirements):
okuta marked this conversation as resolved.
Show resolved Hide resolved
"""Returns whether the given requirments are satisfied.

Args:
requirements: A list of string representing the requirements.

Returns:
bool: A boolean indicating whether the given requirements are
satisfied.
"""
ws = pkg_resources.WorkingSet()
try:
ws.require(*requirements)
except pkg_resources.ResolutionError:
return False
return True


@contextlib.contextmanager
def assert_warns(expected):
with warnings.catch_warnings(record=True) as w:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,8 @@
}

doctest_global_setup = '''
import os
import numpy as np
import cupy
import chainer
from chainer.backends import cuda
from chainer import Function, gradient_check, training, utils, Variable
Expand Down
4 changes: 4 additions & 0 deletions docs/source/guides/gpu.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ After reading this section, you will be able to:
* Write model-parallel computing in Chainer
* Write data-parallel computing in Chainer

.. testsetup::

import cupy

.. testcode::
:hide:

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
'mock',
],
'doctest': [
'sphinx==1.7.9',
'sphinx==1.8.0',
niboshi marked this conversation as resolved.
Show resolved Hide resolved
'matplotlib',
'theano',
],
'docs': [
'sphinx==1.7.9',
'sphinx==1.8.0',
niboshi marked this conversation as resolved.
Show resolved Hide resolved
'sphinx_rtd_theme',
],
'appveyor': [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@


@testing.with_requires('theano')
# chainer/chainer#5997
@testing.without_requires('Theano<=1.0.3', 'numpy>=1.16.0')
class TheanoFunctionTestBase(object):

forward_test_options = {}
Expand Down