Skip to content

Commit

Permalink
Merge pull request #48 from skirpichev/use-py.test-doctests
Browse files Browse the repository at this point in the history
Enable regular doctest testing with py.test
  • Loading branch information
skirpichev committed May 31, 2015
2 parents 6e09993 + fe4a398 commit f540b29
Show file tree
Hide file tree
Showing 26 changed files with 78 additions and 448 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,5 @@ doc/_build/
# Backup files
*~

# Temp output of sympy/printing/preview.py:
sample.tex

# IPython Notebook Checkpoints
.ipynb_checkpoints/
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: python
env:
matrix:
- TEST_DOCTESTS="true"
- SPLIT="1/2"
- SPLIT="2/2"
- TEST_EXTRA="true" TEST_PEP="true"
Expand All @@ -15,9 +14,6 @@ matrix:
- python: 2.7
env:
- TEST_SPHINX="true"
- python: "pypy3"
env:
- TEST_DOCTESTS="true"
- python: "pypy3"
env:
- SPLIT="1/2"
Expand Down
40 changes: 27 additions & 13 deletions bin/test_travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,47 @@
set -e -x # exit on error and echo each command

if [[ "${TEST_SPHINX}" == "true" ]]; then
bin/doctest `find doc/ -name '*.rst'`
make -C doc html-errors man latex
LATEXOPTIONS="-interaction=nonstopmode" make -C doc/_build/latex
else
if [[ "${TEST_DOCTESTS}" == "true" ]]; then
cat << EOF | python
import sympy
if not sympy.doctest():
raise Exception('Tests failed')
EOF
bin/doctest doc/
elif [[ "${TEST_SLOW}" == "true" ]]; then
py.test -m 'slow' --duration=100 --split="${SPLIT}" sympy/
if [[ "${TEST_SLOW}" == "true" ]]; then
py.test -m 'slow' --duration=100 --split="${SPLIT}" \
--ignore sympy/utilities/autowrap.py \
--ignore sympy/utilities/mathml/__init__.py \
--ignore sympy/plotting/plot.py \
--ignore sympy/plotting/plot_implicit.py \
sympy/
elif [[ "${TEST_EXTRA}" == "true" ]]; then
if [[ "${TRAVIS_PYTHON_VERSION}" == "2.7" ]]; then
py.test --duration=100 --cov sympy \
py.test --duration=100 --cov sympy --doctest-modules \
sympy/printing/tests/test_theanocode.py \
sympy/external/tests/test_autowrap.py \
sympy/polys/ sympy/plotting/
else
py.test --duration=100 \
py.test --duration=100 --doctest-modules \
sympy/printing/tests/test_theanocode.py \
sympy/external/tests/test_autowrap.py \
sympy/polys/ sympy/plotting/
fi
elif [[ "${TRAVIS_PYTHON_VERSION}" == "2.7" ]]; then
py.test -m 'not slow' --duration=100 --cov sympy --split="${SPLIT}" sympy/
py.test -m 'not slow' --duration=100 --cov sympy --split="${SPLIT}" \
--ignore sympy/utilities/autowrap.py \
--ignore sympy/utilities/mathml/__init__.py \
--ignore sympy/plotting/plot.py \
--ignore sympy/plotting/plot_implicit.py \
--doctest-modules sympy/
else
py.test -m 'not slow' --duration=100 --split="${SPLIT}" sympy/
if [[ "${TRAVIS_PYTHON_VERSION}" == "pypy3" ]]; then
EXTRA_IGNORE="--ignore sympy/matrices/dense.py --ignore sympy/tensor/tensor.py --ignore sympy/utilities/lambdify.py"
else
EXTRA_IGNORE=""
fi
py.test -m 'not slow' --duration=100 --split="${SPLIT}" \
--ignore sympy/utilities/autowrap.py \
--ignore sympy/utilities/mathml/__init__.py \
--ignore sympy/plotting/plot.py \
--ignore sympy/plotting/plot_implicit.py \
${EXTRA_IGNORE} --doctest-modules sympy/
fi
fi
2 changes: 0 additions & 2 deletions doc/modules/categories.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,3 @@ diagrams.
:members:

.. autofunction:: xypic_draw_diagram

.. autofunction:: preview_diagram
9 changes: 0 additions & 9 deletions doc/modules/printing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,6 @@ tree.

.. autofunction:: print_tree

Preview
-------

A useful function is ``preview``:

.. module:: sympy.printing.preview

.. autofunction:: preview

Implementation - Helper Classes/Functions
-----------------------------------------

Expand Down
1 change: 0 additions & 1 deletion doc/modules/utilities/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Contents:
memoization.rst
misc.rst
pkgdata.rst
pytest.rst
randtest.rst
runtests.rst
source.rst
Expand Down
6 changes: 0 additions & 6 deletions doc/modules/utilities/pytest.rst

This file was deleted.

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def run(self):
os.remove(os.path.join(root, file))

os.chdir(dir_setup)
names = ["python-build-stamp-2.4", "MANIFEST", "build", "dist", "doc/_build", "sample.tex", ".coverage"]
names = ["python-build-stamp-2.4", "MANIFEST", "build", "dist", "doc/_build", ".coverage"]

for f in names:
if os.path.isfile(f):
Expand Down
2 changes: 1 addition & 1 deletion sympy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __sympy_debug():
from .printing import pretty, pretty_print, pprint, pprint_use_unicode, \
pprint_try_use_unicode, print_gtk, print_tree, pager_print, TableForm
from .printing import ccode, fcode, jscode, mathematica_code, octave_code, \
latex, preview
latex
from .printing import python, print_python, srepr, sstr, sstrrepr
from .interactive import init_session, init_printing

Expand Down
2 changes: 1 addition & 1 deletion sympy/categories/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
Diagram)

from .diagram_drawing import (DiagramGrid, XypicDiagramDrawer,
xypic_draw_diagram, preview_diagram)
xypic_draw_diagram)
34 changes: 0 additions & 34 deletions sympy/categories/diagram_drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2551,37 +2551,3 @@ def xypic_draw_diagram(diagram, masked=None, diagram_format="",
grid = DiagramGrid(diagram, groups, **hints)
drawer = XypicDiagramDrawer()
return drawer.draw(diagram, grid, masked, diagram_format)


@doctest_depends_on(exe=('latex', 'dvipng'), modules=('pyglet',))
def preview_diagram(diagram, masked=None, diagram_format="", groups=None,
output='png', viewer=None, euler=True, **hints):
"""
Combines the functionality of ``xypic_draw_diagram`` and
``sympy.printing.preview``. The arguments ``masked``,
``diagram_format``, ``groups``, and ``hints`` are passed to
``xypic_draw_diagram``, while ``output``, ``viewer, and ``euler``
are passed to ``preview``.
Examples
========
>>> from sympy.categories import Object, NamedMorphism, Diagram
>>> from sympy.categories import preview_diagram
>>> A = Object("A")
>>> B = Object("B")
>>> C = Object("C")
>>> f = NamedMorphism(A, B, "f")
>>> g = NamedMorphism(B, C, "g")
>>> d = Diagram([f, g], {g * f: "unique"})
>>> preview_diagram(d)
See Also
========
xypic_draw_diagram
"""
from sympy.printing import preview
latex_output = xypic_draw_diagram(diagram, masked, diagram_format,
groups, **hints)
preview(latex_output, output, viewer, euler, ("xypic",))
4 changes: 3 additions & 1 deletion sympy/combinatorics/permutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2272,8 +2272,9 @@ def inversion_vector(self):
of the permutation, the -ith element cycling through 0..i.
>>> p = Permutation(2)
>>> Permutation.print_cyclic = False
>>> while p:
... print('%s %s %s' % (p, p.inversion_vector(), p.rank()))
... print('%s %s %s' % (repr(p), p.inversion_vector(), p.rank()))
... p = p.next_lex()
...
Permutation([0, 1, 2]) [0, 0] 0
Expand Down Expand Up @@ -2441,6 +2442,7 @@ def get_precedence_matrix(self):
>>> from sympy.combinatorics.permutations import Permutation
>>> p = Permutation.josephus(3,6,1)
>>> Permutation.print_cyclic = False
>>> p
Permutation([2, 5, 3, 1, 4, 0])
>>> p.get_precedence_matrix()
Expand Down
3 changes: 2 additions & 1 deletion sympy/combinatorics/polyhedron.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def __new__(cls, corners, faces=[], pgroup=[]):
>>> from sympy.combinatorics.polyhedron import cube
>>> cube.edges
{(0, 1), (0, 3), (0, 4), '...', (4, 7), (5, 6), (6, 7)}
{(0, 1), (0, 3), (0, 4), ..., (4, 7), (5, 6), (6, 7)}
If you want to use letters or other names for the corners you
can still use the pre-calculated faces:
Expand Down Expand Up @@ -432,6 +432,7 @@ def array_form(self):
[0, 2, 3, 1]
>>> tetrahedron.pgroup[0].array_form
[0, 2, 3, 1]
>>> tetrahedron.reset()
See Also
========
Expand Down
2 changes: 1 addition & 1 deletion sympy/functions/special/error_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,7 @@ class li(Function):
We can even compute Soldner's constant by the help of mpmath:
>>> from mpmath import findroot
>>> findroot(li, 2)
>>> print(findroot(li, 2))
1.45136923488338
Further transformations include rewriting `li` in terms of
Expand Down
4 changes: 2 additions & 2 deletions sympy/geometry/point.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Point(GeometryEntity):
>>> Point(0.5, 0.25)
Point(1/2, 1/4)
>>> Point(0.5, 0.25, evaluate=False)
>>> print(Point(0.5, 0.25, evaluate=False))
Point(0.5, 0.25)
"""
Expand Down Expand Up @@ -376,7 +376,7 @@ def evalf(self, prec=None, **options):
>>> p1 = Point(Rational(1, 2), Rational(3, 2))
>>> p1
Point(1/2, 3/2)
>>> p1.evalf()
>>> print(p1.evalf())
Point(0.5, 1.5)
"""
Expand Down
4 changes: 2 additions & 2 deletions sympy/geometry/point3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Point3D(GeometryEntity):
>>> Point3D(0.5, 0.25, 2)
Point3D(1/2, 1/4, 2)
>>> Point3D(0.5, 0.25, 3, evaluate=False)
>>> print(Point3D(0.5, 0.25, 3, evaluate=False))
Point3D(0.5, 0.25, 3)
"""
Expand Down Expand Up @@ -410,7 +410,7 @@ def evalf(self, prec=None, **options):
>>> p1 = Point3D(Rational(1, 2), Rational(3, 2), Rational(5, 2))
>>> p1
Point3D(1/2, 3/2, 5/2)
>>> p1.evalf()
>>> print(p1.evalf())
Point3D(0.5, 1.5, 2.5)
"""
Expand Down
31 changes: 17 additions & 14 deletions sympy/integrals/quadrature.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ def gauss_legendre(n, n_digits):
========
>>> from sympy.integrals.quadrature import gauss_legendre
>>> from sympy.printing import pprint
>>> x, w = gauss_legendre(3, 5)
>>> x
>>> pprint(x)
[-0.7746, 0, 0.7746]
>>> w
>>> pprint(w)
[0.55556, 0.88889, 0.55556]
>>> x, w = gauss_legendre(4, 5)
>>> x
>>> pprint(x)
[-0.86114, -0.33998, 0.33998, 0.86114]
>>> w
>>> pprint(w)
[0.34786, 0.65215, 0.65215, 0.34786]
See Also
Expand Down Expand Up @@ -115,6 +116,7 @@ def gauss_laguerre(n, n_digits):
========
>>> from sympy.integrals.quadrature import gauss_laguerre
>>> from sympy.printing import pprint
>>> x, w = gauss_laguerre(3, 5)
>>> x
[0.41577, 2.2943, 6.2899]
Expand All @@ -123,7 +125,7 @@ def gauss_laguerre(n, n_digits):
>>> x, w = gauss_laguerre(6, 5)
>>> x
[0.22285, 1.1889, 2.9927, 5.7751, 9.8375, 15.983]
>>> w
>>> pprint(w)
[0.45896, 0.417, 0.11337, 0.010399, 0.00026102, 8.9855e-7]
See Also
Expand Down Expand Up @@ -187,6 +189,7 @@ def gauss_hermite(n, n_digits):
========
>>> from sympy.integrals.quadrature import gauss_hermite
>>> from sympy.printing import pprint
>>> x, w = gauss_hermite(3, 5)
>>> x
[-1.2247, 0, 1.2247]
Expand All @@ -196,7 +199,7 @@ def gauss_hermite(n, n_digits):
>>> x, w = gauss_hermite(6, 5)
>>> x
[-2.3506, -1.3358, -0.43608, 0.43608, 1.3358, 2.3506]
>>> w
>>> pprint(w)
[0.00453, 0.15707, 0.72463, 0.72463, 0.15707, 0.00453]
See Also
Expand Down Expand Up @@ -262,12 +265,12 @@ def gauss_gen_laguerre(n, alpha, n_digits):
Examples
========
>>> from sympy import S
>>> from sympy import S, pprint
>>> from sympy.integrals.quadrature import gauss_gen_laguerre
>>> x, w = gauss_gen_laguerre(3, -S.Half, 5)
>>> x
[0.19016, 1.7845, 5.5253]
>>> w
>>> pprint(w)
[1.4493, 0.31413, 0.00906]
>>> x, w = gauss_gen_laguerre(4, 3*S.Half, 5)
Expand Down Expand Up @@ -338,7 +341,7 @@ def gauss_chebyshev_t(n, n_digits):
Examples
========
>>> from sympy import S
>>> from sympy import S, pprint
>>> from sympy.integrals.quadrature import gauss_chebyshev_t
>>> x, w = gauss_chebyshev_t(3, 5)
>>> x
Expand All @@ -349,7 +352,7 @@ def gauss_chebyshev_t(n, n_digits):
>>> x, w = gauss_chebyshev_t(6, 5)
>>> x
[0.96593, 0.70711, 0.25882, -0.25882, -0.70711, -0.96593]
>>> w
>>> pprint(w)
[0.5236, 0.5236, 0.5236, 0.5236, 0.5236, 0.5236]
See Also
Expand Down Expand Up @@ -409,12 +412,12 @@ def gauss_chebyshev_u(n, n_digits):
Examples
========
>>> from sympy import S
>>> from sympy import S, pprint
>>> from sympy.integrals.quadrature import gauss_chebyshev_u
>>> x, w = gauss_chebyshev_u(3, 5)
>>> x
[0.70711, 0, -0.70711]
>>> w
>>> pprint(w)
[0.3927, 0.7854, 0.3927]
>>> x, w = gauss_chebyshev_u(6, 5)
Expand Down Expand Up @@ -485,7 +488,7 @@ def gauss_jacobi(n, alpha, beta, n_digits):
Examples
========
>>> from sympy import S
>>> from sympy import S, pprint
>>> from sympy.integrals.quadrature import gauss_jacobi
>>> x, w = gauss_jacobi(3, S.Half, -S.Half, 5)
>>> x
Expand All @@ -494,7 +497,7 @@ def gauss_jacobi(n, alpha, beta, n_digits):
[1.7063, 1.0973, 0.33795]
>>> x, w = gauss_jacobi(6, 1, 1, 5)
>>> x
>>> pprint(x)
[-0.87174, -0.5917, -0.2093, 0.2093, 0.5917, 0.87174]
>>> w
[0.050584, 0.22169, 0.39439, 0.39439, 0.22169, 0.050584]
Expand Down
Loading

0 comments on commit f540b29

Please sign in to comment.