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

Run the examples during automated testing or at release #10243

Open
moorepants opened this Issue Dec 11, 2015 · 11 comments

Comments

Projects
None yet
5 participants
@moorepants
Copy link
Member

moorepants commented Dec 11, 2015

Right now examples/advanced/autowrap_ufuncify doesn't run with the development version of SymPy because of backwards incompatible API changes, see #10234. We should figure out how to run these on Travis or simply before each release.

@leosartaj

This comment has been minimized.

Copy link
Member

leosartaj commented Dec 11, 2015

Some of these examples make graphs. They are of varying type. I am not sure what will be the best way to test them.

@moorepants

This comment has been minimized.

Copy link
Member

moorepants commented Dec 11, 2015

The don't have to be unit tested, per se, but simply shown that they still execute. If you want to test graphs you can use matplotlib's image comparison testing framework.

@asmeurer

This comment has been minimized.

Copy link
Member

asmeurer commented Dec 11, 2015

I think most of the examples are run, but we skip the ones with plots.

@tokencolour

This comment has been minimized.

Copy link
Contributor

tokencolour commented Dec 17, 2015

I would like to work on this.

@tokencolour

This comment has been minimized.

Copy link
Contributor

tokencolour commented Dec 20, 2015

I had made a few changes to autowrap_ufuncify.py so as to use plot from sympy.plotting and had run it interactively to find out:

>>> g=implemented_function('g', binary_poly)
>>> g._imp_(x)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: ufunc 'wrapper_module_5' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

>>> lambdified_poly=lambdify(x, expr)
>>> f=implemented_function('f', lamdified_poly)
>>> f._imp_(x)
63*x**5/8 - 35*x**3/4 + 15*x/8

It can plot f(x) for all n using plot() and plot.extend() but not g(x). It shows the following error:

Traceback (most recent call last):
  File "legendre_try.py", line 84, in <module>
    plot1.show()
  File "/usr/local/lib/python2.7/dist-packages/sympy-0.7.7.dev0-py2.7.egg/sympy/plotting/plot.py", line 185, in show
    self._backend.show()
  File "/usr/local/lib/python2.7/dist-packages/sympy-0.7.7.dev0-py2.7.egg/sympy/plotting/plot.py", line 1018, in show
    self.process_series()
  File "/usr/local/lib/python2.7/dist-packages/sympy-0.7.7.dev0-py2.7.egg/sympy/plotting/plot.py", line 897, in process_series
    collection = self.LineCollection(s.get_segments())
  File "/usr/local/lib/python2.7/dist-packages/sympy-0.7.7.dev0-py2.7.egg/sympy/plotting/plot.py", line 503, in get_segments
    f_start = f(self.start)
  File "/usr/local/lib/python2.7/dist-packages/sympy-0.7.7.dev0-py2.7.egg/sympy/plotting/experimental_lambdify.py", line 228, in __call__
    result = self.lambda_func(args)
  File "<string>", line 1, in <lambda>
  File "/usr/local/lib/python2.7/dist-packages/sympy-0.7.7.dev0-py2.7.egg/sympy/core/expr.py", line 231, in __complex__
    return complex(float(re), float(im))
  File "/usr/local/lib/python2.7/dist-packages/sympy-0.7.7.dev0-py2.7.egg/sympy/core/expr.py", line 226, in __float__
    raise TypeError("can't convert expression to float")
TypeError: can't convert expression to float

I guess that g(x), though an instance of the Function class just as f(x), is not being type-casted properly.
I can't seem to figure out how to get this to work.
Please help me.

@tokencolour

This comment has been minimized.

Copy link
Contributor

tokencolour commented Dec 23, 2015

Can you help me with this, @moorepants ?

@amitsaha

This comment has been minimized.

Copy link
Contributor

amitsaha commented Dec 24, 2015

Besides the matplotlib image testing framework, another option to actuallt test graphs created by plots is pytest-mpl: https://pypi.python.org/pypi/pytest-mpl which may be useful here.

@tokencolour

This comment has been minimized.

Copy link
Contributor

tokencolour commented Dec 24, 2015

@amitsaha , Once I get the plots using ufuncify, I'll try to write tests for it. As of now, I can only plot implemented functions via lambdify

@moorepants

This comment has been minimized.

Copy link
Member

moorepants commented Dec 24, 2015

I don't think it is necessary to turn the examples into unit tests. We really just needed to check and see if the examples execute before each release. Ideally, there is a script that we can run that will run them all from the top level directory, i.e.:

bin/run_examples

@asmeurer

This comment has been minimized.

Copy link
Member

asmeurer commented Dec 24, 2015

examples/all.py runs all the examples (but I think it skips this one).

@tokencolour

This comment has been minimized.

Copy link
Contributor

tokencolour commented Dec 25, 2015

I have changed the file so that it uses the new plot API. Though I feel, just plotting the expr defeats the purpose. Kindly have a look at it and should it be necessary, suggest some alternative solution.

tokencolour added a commit to tokencolour/sympy that referenced this issue Dec 25, 2015

Changed the use of pyglet Plot module
This example uses, as of now, the old pyglet plotting module
which is not working right now.
My fix uses matplotlib as suggested by @moorepants.
Fixes sympy#10243

tokencolour added a commit to tokencolour/sympy that referenced this issue Dec 25, 2015

Changed the use of pyglet Plot module
Added EOL after main and proper importing of matplotlib.
Fixes sympy#10243

@moorepants moorepants reopened this Dec 27, 2015

Shaswat27 added a commit to Shaswat27/sympy that referenced this issue Dec 27, 2015

Changed the use of pyglet plot module
This example uses, as of now, the old pyglet plotting module
which is not working right now.
Changed so that it uses the new plot API.
Trying to fix sympy#10243

Shaswat27 added a commit to Shaswat27/sympy that referenced this issue Dec 27, 2015

Changed the use of pyglet Plot module
This example uses, as of now, the old pyglet plotting module
which is not working right now.
My fix uses matplotlib as suggested by @moorepants.
Fixes sympy#10243

Shaswat27 added a commit to Shaswat27/sympy that referenced this issue Dec 27, 2015

Changed the use of pyglet Plot module
Added EOL after main and proper importing of matplotlib.
Fixes sympy#10243

Shaswat27 added a commit to Shaswat27/sympy that referenced this issue Dec 27, 2015

Squashed commit of the following:
commit b539d02
Merge: 0b9ab6c 9c1a133
Author: Shaswat27 <shaswatdatta@hotmail.com>
Date:   Sun Dec 27 15:23:07 2015 +0530

    Merge branch 'master' of https://github.com/sympy/sympy

commit 0b9ab6c
Author: Shaswat27 <shaswatdatta@hotmail.com>
Date:   Sun Dec 27 15:22:30 2015 +0530

    code_quality test pass

commit 874784e
Author: Shaswat27 <shaswatdatta@hotmail.com>
Date:   Sun Dec 27 13:02:12 2015 +0530

    Line space removed

commit 81e5a30
Author: tokencolour <tokencolour@gmail.com>
Date:   Sat Dec 26 01:06:42 2015 +0530

    Changed the use of pyglet Plot module

    Added EOL after main and proper importing of matplotlib.
    Fixes sympy#10243

commit 133aefc
Author: tokencolour <tokencolour@gmail.com>
Date:   Sat Dec 26 00:22:40 2015 +0530

    Changed the use of pyglet Plot module

    This example uses, as of now, the old pyglet plotting module
    which is not working right now.
    My fix uses matplotlib as suggested by @moorepants.
    Fixes sympy#10243

commit 31a7014
Author: tokencolour <tokencolour@gmail.com>
Date:   Fri Dec 25 22:58:49 2015 +0530

    Changed the use of pyglet plot module

    This example uses, as of now, the old pyglet plotting module
    which is not working right now.
    Changed so that it uses the new plot API.
    Trying to fix sympy#10243

commit 9c1a133
Merge: d38d491 9837c8d
Author: Jason K. Moore <moorepants@gmail.com>
Date:   Sat Dec 26 18:11:31 2015 -0800

    Merge pull request sympy#10316 from tokencolour/check_plot

    Changed the use of pyglet plot module

commit 9837c8d
Author: tokencolour <tokencolour@gmail.com>
Date:   Sat Dec 26 01:06:42 2015 +0530

    Changed the use of pyglet Plot module

    Added EOL after main and proper importing of matplotlib.
    Fixes sympy#10243

commit 6c76b4f
Author: tokencolour <tokencolour@gmail.com>
Date:   Sat Dec 26 00:22:40 2015 +0530

    Changed the use of pyglet Plot module

    This example uses, as of now, the old pyglet plotting module
    which is not working right now.
    My fix uses matplotlib as suggested by @moorepants.
    Fixes sympy#10243

commit 7fcd761
Author: tokencolour <tokencolour@gmail.com>
Date:   Fri Dec 25 22:58:49 2015 +0530

    Changed the use of pyglet plot module

    This example uses, as of now, the old pyglet plotting module
    which is not working right now.
    Changed so that it uses the new plot API.
    Trying to fix sympy#10243

megh1241 added a commit to megh1241/sympy that referenced this issue Dec 30, 2015

Changed the use of pyglet plot module
This example uses, as of now, the old pyglet plotting module
which is not working right now.
Changed so that it uses the new plot API.
Trying to fix sympy#10243

megh1241 added a commit to megh1241/sympy that referenced this issue Dec 30, 2015

Changed the use of pyglet Plot module
This example uses, as of now, the old pyglet plotting module
which is not working right now.
My fix uses matplotlib as suggested by @moorepants.
Fixes sympy#10243

megh1241 added a commit to megh1241/sympy that referenced this issue Dec 30, 2015

Changed the use of pyglet Plot module
Added EOL after main and proper importing of matplotlib.
Fixes sympy#10243

Shaswat27 added a commit to Shaswat27/sympy that referenced this issue Jan 4, 2016

Squashed commit of the following:
commit b539d02
Merge: 0b9ab6c 9c1a133
Author: Shaswat27 <shaswatdatta@hotmail.com>
Date:   Sun Dec 27 15:23:07 2015 +0530

    Merge branch 'master' of https://github.com/sympy/sympy

commit 0b9ab6c
Author: Shaswat27 <shaswatdatta@hotmail.com>
Date:   Sun Dec 27 15:22:30 2015 +0530

    code_quality test pass

commit 874784e
Author: Shaswat27 <shaswatdatta@hotmail.com>
Date:   Sun Dec 27 13:02:12 2015 +0530

    Line space removed

commit 81e5a30
Author: tokencolour <tokencolour@gmail.com>
Date:   Sat Dec 26 01:06:42 2015 +0530

    Changed the use of pyglet Plot module

    Added EOL after main and proper importing of matplotlib.
    Fixes sympy#10243

commit 133aefc
Author: tokencolour <tokencolour@gmail.com>
Date:   Sat Dec 26 00:22:40 2015 +0530

    Changed the use of pyglet Plot module

    This example uses, as of now, the old pyglet plotting module
    which is not working right now.
    My fix uses matplotlib as suggested by @moorepants.
    Fixes sympy#10243

commit 31a7014
Author: tokencolour <tokencolour@gmail.com>
Date:   Fri Dec 25 22:58:49 2015 +0530

    Changed the use of pyglet plot module

    This example uses, as of now, the old pyglet plotting module
    which is not working right now.
    Changed so that it uses the new plot API.
    Trying to fix sympy#10243

commit 9c1a133
Merge: d38d491 9837c8d
Author: Jason K. Moore <moorepants@gmail.com>
Date:   Sat Dec 26 18:11:31 2015 -0800

    Merge pull request sympy#10316 from tokencolour/check_plot

    Changed the use of pyglet plot module

commit 9837c8d
Author: tokencolour <tokencolour@gmail.com>
Date:   Sat Dec 26 01:06:42 2015 +0530

    Changed the use of pyglet Plot module

    Added EOL after main and proper importing of matplotlib.
    Fixes sympy#10243

commit 6c76b4f
Author: tokencolour <tokencolour@gmail.com>
Date:   Sat Dec 26 00:22:40 2015 +0530

    Changed the use of pyglet Plot module

    This example uses, as of now, the old pyglet plotting module
    which is not working right now.
    My fix uses matplotlib as suggested by @moorepants.
    Fixes sympy#10243

commit 7fcd761
Author: tokencolour <tokencolour@gmail.com>
Date:   Fri Dec 25 22:58:49 2015 +0530

    Changed the use of pyglet plot module

    This example uses, as of now, the old pyglet plotting module
    which is not working right now.
    Changed so that it uses the new plot API.
    Trying to fix sympy#10243

skirpichev added a commit to skirpichev/diofant that referenced this issue Jul 16, 2016

Changed the use of pyglet plot module
This example uses, as of now, the old pyglet plotting module
which is not working right now.
Changed so that it uses the new plot API.

Fixes sympy/sympy#10243

// edited by skirpichev

Signed-off-by: Sergey B Kirpichev <skirpichev@gmail.com>

skirpichev added a commit to skirpichev/diofant that referenced this issue Jul 17, 2016

Changed the use of pyglet plot module
This example uses, as of now, the old pyglet plotting module
which is not working right now.
Changed so that it uses the new plot API.

Fixes sympy/sympy#10243

// edited by skirpichev

Signed-off-by: Sergey B Kirpichev <skirpichev@gmail.com>

skirpichev added a commit to skirpichev/diofant that referenced this issue Jul 17, 2016

Changed the use of pyglet plot module
This example uses, as of now, the old pyglet plotting module
which is not working right now.
Changed so that it uses the new plot API.

Fixes sympy/sympy#10243

// edited by skirpichev

Signed-off-by: Sergey B Kirpichev <skirpichev@gmail.com>

@moorepants moorepants reopened this Aug 10, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment