If I define a piecewise function from -infinity to +infininty, and I want to plot it, I get an error message like below. Any ideas how to fix this? Any workarounds?
{{{id=11| f = Piecewise([[(-infinity,1),1],[(1,+infinity),2]]) /// }}}
{{{id=12| plot(f) /// Traceback (most recent call last): File "<stdin>", line 1, in <module> File "_sage_input_110.py", line 10, in <module> exec compile(u'open("___code___.py","w").write("# -- coding: utf-8 --\n" + _support_.preparse_worksheet_cell(base64.b64decode("cGxvdChmKQ=="),globals())+"\n"); execfile(os.path.abspath("___code___.py"))' + '\n', '', 'single') File "", line 1, in <module>
File "/tmp/tmph_Lqwg/___code___.py", line 2, in <module> exec compile(u'plot(f)' + '\n', '', 'single') File "", line 1, in <module>
File "/opt/sage-4.7.1-linux-64bit-ubuntu_10.04.1_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/misc/decorators.py", line 657, in wrapper return func(args, *kwds) File "/opt/sage-4.7.1-linux-64bit-ubuntu_10.04.1_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/misc/decorators.py", line 504, in wrapper return func(args, *options) File "/opt/sage-4.7.1-linux-64bit-ubuntu_10.04.1_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/plot/plot.py", line 3058, in plot G = funcs.plot(args, *original_opts) File "/opt/sage-4.7.1-linux-64bit-ubuntu_10.04.1_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/functions/piecewise.py", line 1018, in plot return sum([plot(f, a, b, args, *kwds) for (a,b),f in self.list()]) File "/opt/sage-4.7.1-linux-64bit-ubuntu_10.04.1_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/misc/decorators.py", line 657, in wrapper return func(args, *kwds) File "/opt/sage-4.7.1-linux-64bit-ubuntu_10.04.1_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/misc/decorators.py", line 504, in wrapper return func(args, *options) File "/opt/sage-4.7.1-linux-64bit-ubuntu_10.04.1_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/plot/plot.py", line 3077, in plot G = _plot(funcs, (xmin, xmax), args, *kwds) File "/opt/sage-4.7.1-linux-64bit-ubuntu_10.04.1_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/plot/plot.py", line 3180, in _plot data = generate_plot_points(f, xrange, plot_points, adaptive_tolerance, adaptive_recursion, randomize) File "/opt/sage-4.7.1-linux-64bit-ubuntu_10.04.1_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/plot/plot.py", line 4180, in generate_plot_points data = srange(*ranges[0], include_endpoint=True) File "/opt/sage-4.7.1-linux-64bit-ubuntu_10.04.1_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/misc/misc.py", line 1149, in srange L = list(xsrange(start,end,step,universe,check,include_endpoint,endpoint_tolerance)) File "/opt/sage-4.7.1-linux-64bit-ubuntu_10.04.1_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/misc/misc.py", line 1242, in xsrange icount = int(math.ceil(float(count) - endpoint_tolerance)) ValueError: cannot convert float NaN to integer }}}