First off, why do you use Lambda. Just use Max(x, 5).

This is definitely a bug.  You can work around it by wrapping x in
re(), like plot(Max(re(x), 5)).  Perhaps plot should automatically do
this if x is assumed to be real.  Even so, it should not have this
error regardless of assumptions.

Aaron Meurer

On Sat, Jan 12, 2013 at 11:53 AM, Andre Holzner <[email protected]> wrote:
> Dear sympy experts,
>
> I tried to plot a 'ramp function' as follows (sympy 0.7.2 on OSX):
>
> from sympy import *
> x = Symbol('x',real = True)
> f = Lambda(x, Max(x,5))
> plot(f(x), (x,0,10))
>
> but I get the exception shown below on the last line. Should I be doing this
> differently ?
> When evaluating the function f at some values, it looks like it is returning
> the correct values.
>
> best regards,
>
> Andre
>
> stack trace:
>
> Traceback (most recent call last):
>   File "/tmp/test.py", line 6, in <module>
>     plot(f(x), (x,0,10))
>   File
> "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sympy/plotting/plot.py",
> line 1165, in plot
>     plots.show()
>   File
> "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sympy/plotting/plot.py",
> line 193, in show
>     self._backend.show()
>   File
> "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sympy/plotting/plot.py",
> line 946, in show
>     self.process_series()
>   File
> "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sympy/plotting/plot.py",
> line 838, in process_series
>     collection = LineCollection(s.get_segments())
>   File
> "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sympy/plotting/plot.py",
> line 461, in get_segments
>     f_start = f(self.start)
>   File
> "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sympy/plotting/experimental_lambdify.py",
> line 204, in __call__
>     result = self.lambda_func(args)
>   File "<string>", line 1, in <lambda>
> TypeError: no ordering relation is defined for complex numbers
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/sympy/-/QHyOEPCLCt4J.
> 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?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" 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?hl=en.

Reply via email to