10000 BUG: Make numpy import when run with Python flag '-OO'. · charris/numpy@dc45391 · GitHub
[go: up one dir, main page]

Skip to content

Commit dc45391

Browse files
committed
BUG: Make numpy import when run with Python flag '-OO'.
This consists of checking for a docstring equal to None and skipping two tests that require docstrings. Closes numpy#5148.
1 parent bbb7c3f commit dc45391

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

numpy/lib/tests/test_function_base.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
from __future__ import division, absolute_import, print_function
22

33
import warnings
4+
import sys
45

56
import numpy as np
67
from numpy.testing import (
78
run_module_suite, TestCase, assert_, assert_equal, assert_array_equal,
89
assert_almost_equal, assert_array_almost_equal, assert_raises,
9-
assert_allclose, assert_array_max_ulp, assert_warns, assert_raises_regex
10+
assert_allclose, assert_array_max_ulp, assert_warns,
11+
assert_raises_regex, dec
1012
)
1113
from numpy.random import rand
1214
from numpy.lib import *
@@ -2094,6 +2096,8 @@ def test_string_arg(self):
20942096

20952097

20962098
class TestAdd_newdoc(TestCase):
2099+
2100+
@dec.skipif(sys.flags.optimize == 2)
20972101
def test_add_doc(self):
20982102
# test np.add_newdoc
20992103
tgt = "Current flat index into the array."

numpy/lib/tests/test_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sys
44
from numpy.core import arange
55
from numpy.testing import (
6-
run_module_suite, assert_, assert_equal
6+
run_module_suite, assert_, assert_equal, dec
77
)
88
from numpy.lib import deprecate
99
import numpy.lib.utils as utils
@@ -14,6 +14,7 @@
1414
from StringIO import StringIO
1515

1616

17+
@dec.skipif(sys.flags.optimize == 2)
1718
def test_lookfor():
1819
out = StringIO()
1920
utils.lookfor('eigenvalue', module='numpy', output=out,

numpy/ma/extras.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,10 @@ def apply_over_axes(func, a, axes):
434434
raise ValueError("function is not returning "
435435
"an array of the correct shape")
436436
return val
437-
apply_over_axes.__doc__ = np.apply_over_axes.__doc__[
438-
:np.apply_over_axes.__doc__.find('Notes')].rstrip() + \
437+
438+
if apply_over_axes.__doc__ is not None:
439+
apply_over_axes.__doc__ = np.apply_over_axes.__doc__[
440+
:np.apply_over_axes.__doc__.find('Notes')].rstrip() + \
439441
"""
440442
441443
Examples
@@ -462,7 +464,7 @@ def apply_over_axes(func, a, axes):
462464
[[[46]
463465
[--]
464466
[124]]]
465-
"""
467+
"""
466468

467469

468470
def average(a, axis=None, weights=None, returned=False):

0 commit comments

Comments
 (0)
0