Status: Accepted
Owner: asmeurer
Labels: Type-Defect Priority-Medium
New issue 2567 by asmeurer: Piecewise does not work when not given
an "otherwise" condition
http://code.google.com/p/sympy/issues/detail?id=2567
In [33]: Piecewise((x, x<0)).subs(x, 1)
Out[33]:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/Users/aaronmeurer/Documents/python/sympy/sympy-scratch/<ipython console>
in <module>()
/sw/lib/python2.7/site-packages/IPython/Prompts.pyc in __call__(self, arg)
550
551 # and now call a possibly user-defined print mechanism
--> 552 manipulated_val = self.display(arg)
553
554 # user display hooks can change the variable to be
stored in
/sw/lib/python2.7/site-packages/IPython/Prompts.pyc in _display(self, arg)
576 return IPython.generics.result_display(arg)
577 except TryNext:
--> 578 return self.shell.hooks.result_display(arg)
579
580 # Assign the default display method:
/sw/lib/python2.7/site-packages/IPython/hooks.pyc in __call__(self, *args,
**kw)
139 #print "prio",prio,"cmd",cmd #dbg
140 try:
--> 141 ret = cmd(*args, **kw)
142 return ret
143 except ipapi.TryNext, exc:
/Users/aaronmeurer/Documents/python/sympy/sympy-scratch/sympy/interactive/printing.pyc
in
result_display(self, arg)
36 """
37 if self.rc.pprint:
---> 38 out = stringify_func(arg)
39
40 if '\n' in out:
/Users/aaronmeurer/Documents/python/sympy/sympy-scratch/sympy/printing/pretty/pretty.pyc
in
pretty(expr, **settings)
1154
1155 try:
-> 1156 return pp.doprint(expr)
1157 finally:
1158 pretty_use_unicode(uflag)
/Users/aaronmeurer/Documents/python/sympy/sympy-scratch/sympy/printing/pretty/pretty.pyc
in
doprint(self, expr)
38
39 def doprint(self, expr):
---> 40 return self._print(expr).render(**self._settings)
41
42 # empty op so _print(stringPict) returns the same
/Users/aaronmeurer/Documents/python/sympy/sympy-scratch/sympy/printing/printer.pyc
in
_print(self, expr, *args)
246 printmethod = '_print_' + cls.__name__
247 if hasattr(self, printmethod):
--> 248 return getattr(self, printmethod)(expr, *args)
249
250 # Unknown object, fall back to the emptyPrinter.
/Users/aaronmeurer/Documents/python/sympy/sympy-scratch/sympy/printing/pretty/pretty.pyc
in
_print_Piecewise(self, pexpr)
527 # max widths
528 maxw = [max([P[i,j].width() for i in xrange(len_args)]) \
--> 529 for j in xrange(2)]
530
531 # FIXME: Refactor this code and matrix into some tabular
environment.
ValueError: max() arg is an empty sequence
Now, the question here is, what *should* this return? It does say in the
docstring:
- If the function is evaluated at a place where all conditions are False,
a ValueError exception will be raised.
But I think this is wrong. The standard thing to do when the value of a
function is unknown is to return nan.
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.