Ticket #3133 (closed enhancement: fixed)

Opened 5 years ago

Last modified 4 years ago

[with patch, positive review] allow parametric_plot and parametric_plot3d to take a vector as input

Reported by: was Owned by: jason
Priority: major Milestone: sage-4.1.2
Component: graphics Keywords:
Cc: kcrisman, jason Work issues:
Report Upstream: Reviewers: Karl-Dieter Crisman
Authors: Jason Grout Merged in: Sage 4.1.2.alpha2
Dependencies: Stopgaps:

Description


On Thu, May 8, 2008 at 1:32 AM, Dan Drake <drake@mathsci.kaist.ac.kr> wrote:
> I'm teaching ODEs right now and I'd like to plot the usual sort of
>  solution to a 2-by-2 linear DE system, but the following doesn't work:
>  
>   sage: evec = vector([1,2])
>   sage: var('t')
>   sage: parametric_plot( exp(-t) * evec, 0, 2)
>  
>  The traceback's complaint is "<type 'exceptions.TypeError'>: function
>  takes at most 1 positional arguments (2 given)".
>  
>  I know I could manually do (exp(-t), 2*exp(-t)), but the above form
>  seems so natural. Is there a way to get that to work?

You could type

sage: parametric_plot( list(exp(-t) * evec), 0, 2)

I think it would be reasonable for us to improve parametric_plot so that it takes a vector 
as input instead of just a list or tuple. 

 -- William

Attachments

trac-3133-parametric_plot-vector.patch Download (4.8 KB) - added by jason 4 years ago.

Change History

comment:1 Changed 4 years ago by jason

  • Cc jason added
  • Owner changed from was to jason
  • Status changed from new to assigned

As a test, the following should work:

sage: var('x')
sage: parametric_plot(vector([x,2*x,3*x^2]), (x,-1,3))

comment:2 Changed 4 years ago by jason

The error is different now too:

sage: sage: var('x')
x
sage: sage: parametric_plot(vector([x,2*x,3*x^2]), (x,-1,3))
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (21, 0))

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)

/home/grout/.sage/temp/good/20161/_home_grout__sage_init_sage_0.py in <module>()

/home/grout/sage/local/lib/python2.5/site-packages/sage/plot/plot.pyc in parametric_plot(funcs, *args, **kwargs)
   1892         return plot(funcs, *args, **kwargs)
   1893     elif (num_funcs == 3 and num_vars <= 2):
-> 1894         return sage.plot.plot3d.parametric_plot3d.parametric_plot3d(funcs, *args, **kwargs)
   1895     else:
   1896         raise ValueError, "the number of functions and the number of free variables is not a possible combination for 2d or 3d parametric plots"

/home/grout/sage/local/lib/python2.5/site-packages/sage/plot/plot3d/parametric_plot3d.pyc in parametric_plot3d(f, urange, vrange, plot_points, **kwds)
    372             
    373     if not isinstance(f, (tuple, list)) or len(f) != 3:
--> 374         raise ValueError, "f must be a list or tuple of length 3"
    375 
    376     if vrange is None:

ValueError: f must be a list or tuple of length 3
sage: 

comment:3 Changed 4 years ago by jason

See #3315 for another input format that parametric_plot should take (functions returning tuples)

Changed 4 years ago by jason

comment:4 Changed 4 years ago by jason

  • Cc kcrisman added
  • Summary changed from allow parametric_plot and parametric_plot3d to take a vector as input to [with patch, needs review] allow parametric_plot and parametric_plot3d to take a vector as input

comment:5 follow-up: ↓ 6 Changed 4 years ago by kcrisman

Positive review of the content. My only concern is that the "internal" functions now have their names changed so we could possibly have to deprecate the non-underscored versions of them (however, only using the underscored ones). What do you think? Probably it's unnecessary, since they were never in the global namespace.

comment:6 in reply to: ↑ 5 Changed 4 years ago by jason

Replying to kcrisman:

Positive review of the content. My only concern is that the "internal" functions now have their names changed so we could possibly have to deprecate the non-underscored versions of them (however, only using the underscored ones). What do you think? Probably it's unnecessary, since they were never in the global namespace.

I thought it was probably okay since they were not in the global namespace *and* their documentation said that they were internal functions. I was just making them more conventional internal functions.

If you'd like I can make them deprecated. Let me know. I think it's okay in this case to just change the names.

comment:7 Changed 4 years ago by kcrisman

  • Reviewers set to Karl-Dieter Crisman
  • Summary changed from [with patch, needs review] allow parametric_plot and parametric_plot3d to take a vector as input to [with patch, positive review] allow parametric_plot and parametric_plot3d to take a vector as input
  • Authors set to Jason Grout

My thoughts exactly, actually - just wanted to see what your reasoning was.

comment:8 Changed 4 years ago by mvngu

  • Status changed from assigned to closed
  • Resolution set to fixed
  • Merged in set to Sage 4.1.2.alpha2

See #6963 for a follow up to this ticket.

Note: See TracTickets for help on using tickets.