On Sat, 18 Jul 2009 06:29:22 -0700 (PDT) Golam Mortuza Hossain <gmhoss...@gmail.com> wrote:
> > Hi, > > On Jun 25, 9:05 am, Burcin Erocal <bur...@erocal.org> wrote: > > On Thu, 25 Jun 2009 13:22:46 +0200 > > > > Stan Schymanski <schym...@gmail.com> wrote: > > > > > I have been asked to forward the below to the sage-devel list. > > > Ticket #6290 introduced a way to custom-define thelatexstyle of > > > functions, but it would be great if something similar was made > > > possible for any variable. Is there a way for this already? I > > > used to do it in the following way, but now I get an error > > > message: > > > > > sage: var('hi kunsati delyui') > > > sage: hi._latex_ = lambda: 'h_i' # Matric suction > > > head in layer i (=pcapvec) > > > sage: kunsati._latex_ = lambda: 'K_{unsat,i}' # Unsaturated > > > hydraulic conductivity in layer i > > > sage: delyui._latex_ = lambda: '\delta_{yu,i}' # Soil layer > > > thickness in layer i > > > Traceback (most recent call last): > > > ... > > > AttributeError: 'sage.symbolic.expression.Expression' object > > > attribute '_latex_' is read-only > > > > Since Expression is a cython class, you cannot overwrite the > > _latex_() method. > > > > Pynac supports settinglatexnames forvariablesat creation, but this > > functionality is not exposed in the wrapper. Another solution by > > hacking latex_variable_name() might be possible, but I would like to > > avoid that if possible. > > > I was looking into Pynac/Ginac code to see how difficult it would be > to expose the Ginac's Tex_name feature for variables. > > (1) Pynac allows to specify Tex_name while defining variables. > > (2) Currently, pynac is patched to effectively use > latex_variable_name > for printing latex as it is better than Ginac's default print_latex > for variables > > > I suggest following changes: > > (1) Compute latex string for variable using Sage's > "latex_variable_name" > while defining it unless user provides a latex string. > > (2) Store this latex string in Ginac symbol framework and use Ginac's > print_latex method. Sounds good to me. Please make the changes, an send me a patch for pynac. Calling latex_variable_name() can be done in the code for var() in Sage. Then, you would only need to change the get_symbol() function in symbol.cpp line 399-409 to pass the right parameter to the symbol() constructor. The patch submission process for pynac is not well defined yet. There were plans to set up a trac server, but I never got around to it. I'll try to do that after the conferences here (in about 2 weeks). In the mean time, as Minh mentioned in another thread, you can send patches to http://groups.google.com/group/pynac-devel Thanks. Burcin --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---