# Ticket #2858: trac_2858.patch

File trac_2858.patch, 2.3 KB (added by was, 12 years ago)
• ## sage/plot/plot3d/parametric_plot3d.py

```# HG changeset patch
# User William Stein <wstein@gmail.com>
# Date 1232795992 28800
# Node ID 1dcc23fa154c47fccf6c76f5f1d7c3cca23cc89d
# Parent  0864645ddf3714e143f4e2afc0926b3c4746bf29
trac #2858  -- parametric_plot3d throws an error when the sum of the components cancels a variable)

diff -r 0864645ddf37 -r 1dcc23fa154c sage/plot/plot3d/parametric_plot3d.py```
 a from sage.plot.misc import ensure_subs from sage.ext.fast_eval import fast_float, fast_float_constant, is_fast_float import sage.calculus.calculus def parametric_plot3d(f, urange, vrange=None, plot_points="automatic", **kwds): r""" Traceback (most recent call last): ... ValueError: plot variables should be distinct, but both are u. From trac 2858: sage: parametric_plot3d((u,-u,v), (-10,10),(-10,10)) sage: f(u)=u; g(v)=v^2; parametric_plot3d((g,f,f), (-10,10),(-10,10)) """ # TODO: #   * Surface -- behavior of functions not defined everywhere -- see note above g, (u,v) = adapt_to_callable(f, 2) except TypeError: g = tuple(f) else: if v is None: raise ValueError, "both ranges must specify a variable or neither must" function, expected arguments """ try: s = sum(f) # get common universe try: # If s is callable, will return the arguments in the right order vars = s.args() except AttributeError: if sum([sage.calculus.calculus.is_CallableSymbolicExpression(z) for z in f]): # Sum to get common universe; this works since f is callable, and summing # gets the arguments in the right order. vars = sum(f).args() else: # Otherwise any free variable names in any order try: vars = s.variables() vars = list(set(sum([z.variables() for z in f], ()))) vars.sort() except AttributeError: vars = () f = [fast_float_constant(x) for x in f]