Skip to content

Commit

Permalink
Merge pull request #89 from skirpichev/plot-testing
Browse files Browse the repository at this point in the history
Restore broken (in sympy) support for matplotlib-enabled tests
  • Loading branch information
skirpichev committed May 24, 2015
2 parents e20906e + 260f81c commit 7a14571
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 22 deletions.
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ before_install:
sudo apt-get update;
sudo apt-get -qq install libgmp-dev libatlas-dev libatlas-base-dev liblapack-dev gfortran;
travis_wait 30 pip install numpy==1.7.1 scipy==0.12.0 gmpy==1.16 Theano==0.6;
travis_wait 30 pip install --allow-external matplotlib==1.2.1;
travis_wait 30 pip install matplotlib==1.3.1;
fi
- if [[ "${TEST_PEP}" == "true" ]]; then
pip install pep8==1.6.2;
Expand All @@ -45,6 +45,11 @@ before_install:
fi
install:
python setup.py install;
before_script:
- if [[ "${TEST_EXTRA}" == "true" ]]; then
sh -e /etc/init.d/xvfb start;
export DISPLAY=:99.0;
fi
script:
- if [[ "${TEST_PEP}" == "true" ]]; then
pep8;
Expand Down
38 changes: 19 additions & 19 deletions sympy/plotting/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def append(self, arg):
>>> p1 = plot(x*x)
>>> p2 = plot(x)
>>> p1.append(p2[0])
>>> p1
>>> print(str(p1))
Plot object containing:
[0]: cartesian line: x**2 for x over (-10.0, 10.0)
[1]: cartesian line: x for x over (-10.0, 10.0)
Expand Down Expand Up @@ -249,7 +249,7 @@ def extend(self, arg):
>>> p1 = plot(x*x)
>>> p2 = plot(x)
>>> p1.extend(p2)
>>> p1
>>> print(str(p1))
Plot object containing:
[0]: cartesian line: x**2 for x over (-10.0, 10.0)
[1]: cartesian line: x for x over (-10.0, 10.0)
Expand Down Expand Up @@ -1192,13 +1192,13 @@ def plot(*args, **kwargs):
Single Plot
>>> plot(x**2, (x, -5, 5))
>>> print(str(plot(x**2, (x, -5, 5))))
Plot object containing:
[0]: cartesian line: x**2 for x over (-5.0, 5.0)
Multiple plots with single range.
>>> plot(x, x**2, x**3, (x, -5, 5))
>>> print(str(plot(x, x**2, x**3, (x, -5, 5))))
Plot object containing:
[0]: cartesian line: x for x over (-5.0, 5.0)
[1]: cartesian line: x**2 for x over (-5.0, 5.0)
Expand All @@ -1207,14 +1207,14 @@ def plot(*args, **kwargs):
Multiple plots with different ranges.
>>> plot((x**2, (x, -6, 6)), (x, (x, -5, 5)))
>>> print(str(plot((x**2, (x, -6, 6)), (x, (x, -5, 5)))))
Plot object containing:
[0]: cartesian line: x**2 for x over (-6.0, 6.0)
[1]: cartesian line: x for x over (-5.0, 5.0)
No adaptive sampling.
>>> plot(x**2, adaptive=False, nb_of_points=400)
>>> print(str(plot(x**2, adaptive=False, nb_of_points=400)))
Plot object containing:
[0]: cartesian line: x**2 for x over (-10.0, 10.0)
Expand Down Expand Up @@ -1342,22 +1342,22 @@ def plot_parametric(*args, **kwargs):
Single Parametric plot
>>> plot_parametric(cos(u), sin(u), (u, -5, 5))
>>> print(str(plot_parametric(cos(u), sin(u), (u, -5, 5))))
Plot object containing:
[0]: parametric cartesian line: (cos(u), sin(u)) for u over (-5.0, 5.0)
Multiple parametric plot with single range.
>>> plot_parametric((cos(u), sin(u)), (u, cos(u)))
>>> print(str(plot_parametric((cos(u), sin(u)), (u, cos(u)))))
Plot object containing:
[0]: parametric cartesian line: (cos(u), sin(u)) for u over (-10.0, 10.0)
[1]: parametric cartesian line: (u, cos(u)) for u over (-10.0, 10.0)
Multiple parametric plots.
>>> plot_parametric((cos(u), sin(u), (u, -5, 5)),
... (cos(u), u, (u, -5, 5)))
>>> print(str(plot_parametric((cos(u), sin(u), (u, -5, 5)),
... (cos(u), u, (u, -5, 5)))))
Plot object containing:
[0]: parametric cartesian line: (cos(u), sin(u)) for u over (-5.0, 5.0)
[1]: parametric cartesian line: (cos(u), u) for u over (-5.0, 5.0)
Expand Down Expand Up @@ -1444,15 +1444,15 @@ def plot3d_parametric_line(*args, **kwargs):
Single plot.
>>> plot3d_parametric_line(cos(u), sin(u), u, (u, -5, 5))
>>> print(str(plot3d_parametric_line(cos(u), sin(u), u, (u, -5, 5))))
Plot object containing:
[0]: 3D parametric cartesian line: (cos(u), sin(u), u) for u over (-5.0, 5.0)
Multiple plots.
>>> plot3d_parametric_line((cos(u), sin(u), u, (u, -5, 5)),
... (sin(u), u**2, u, (u, -5, 5)))
>>> print(str(plot3d_parametric_line((cos(u), sin(u), u, (u, -5, 5)),
... (sin(u), u**2, u, (u, -5, 5)))))
Plot object containing:
[0]: 3D parametric cartesian line: (cos(u), sin(u), u) for u over (-5.0, 5.0)
[1]: 3D parametric cartesian line: (sin(u), u**2, u) for u over (-5.0, 5.0)
Expand Down Expand Up @@ -1548,23 +1548,23 @@ def plot3d(*args, **kwargs):
Single plot
>>> plot3d(x*y, (x, -5, 5), (y, -5, 5))
>>> print(str(plot3d(x*y, (x, -5, 5), (y, -5, 5))))
Plot object containing:
[0]: cartesian surface: x*y for x over (-5.0, 5.0) and y over (-5.0, 5.0)
Multiple plots with same range
>>> plot3d(x*y, -x*y, (x, -5, 5), (y, -5, 5))
>>> print(str(plot3d(x*y, -x*y, (x, -5, 5), (y, -5, 5))))
Plot object containing:
[0]: cartesian surface: x*y for x over (-5.0, 5.0) and y over (-5.0, 5.0)
[1]: cartesian surface: -x*y for x over (-5.0, 5.0) and y over (-5.0, 5.0)
Multiple plots with different ranges.
>>> plot3d((x**2 + y**2, (x, -5, 5), (y, -5, 5)),
... (x*y, (x, -3, 3), (y, -3, 3)))
>>> print(str(plot3d((x**2 + y**2, (x, -5, 5), (y, -5, 5)),
... (x*y, (x, -3, 3), (y, -3, 3)))))
Plot object containing:
[0]: cartesian surface: x**2 + y**2 for x over (-5.0, 5.0) and y over (-5.0, 5.0)
[1]: cartesian surface: x*y for x over (-3.0, 3.0) and y over (-3.0, 3.0)
Expand Down Expand Up @@ -1659,8 +1659,8 @@ def plot3d_parametric_surface(*args, **kwargs):
Single plot.
>>> plot3d_parametric_surface(cos(u + v), sin(u - v), u - v,
... (u, -5, 5), (v, -5, 5))
>>> print(str(plot3d_parametric_surface(cos(u + v), sin(u - v), u - v,
... (u, -5, 5), (v, -5, 5))))
Plot object containing:
[0]: parametric cartesian surface: (cos(u + v), sin(u - v), u - v) for u over (-5.0, 5.0) and v over (-5.0, 5.0)
Expand Down
2 changes: 1 addition & 1 deletion sympy/plotting/plot_implicit.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def get_raster(self):
yinterval = interval(self.start_y, self.end_y)
try:
temp = func(xinterval, yinterval)
except AttributeError:
except (AttributeError, NameError):
if self.use_interval_math:
warnings.warn("Adaptive meshing could not be applied to the"
" expression. Using uniform meshing.")
Expand Down
3 changes: 2 additions & 1 deletion sympy/plotting/tests/test_plot_implicit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
tan, pi)
from sympy.plotting.plot import unset_show
from tempfile import NamedTemporaryFile
from sympy.utilities.pytest import skip
from sympy.utilities.pytest import skip, XFAIL
from sympy.external import import_module

#Set plots not to show
Expand Down Expand Up @@ -64,6 +64,7 @@ def test_line_color():
p = plot_implicit(x**2 + y**2 - 1, line_color='r', show=False)
assert p._series[0].line_color == "r"

@XFAIL
def test_matplotlib():
matplotlib = import_module('matplotlib', min_module_version='1.1.0', catch=(RuntimeError,))
if matplotlib:
Expand Down

0 comments on commit 7a14571

Please sign in to comment.