#17559: Incorrect caching of variables' latex_name attribute
-----------------------------+------------------------
Reporter: wonder | Owner:
Type: defect | Status: new
Priority: major | Milestone: sage-6.5
Component: symbolics | Resolution:
Keywords: | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
-----------------------------+------------------------
Changes (by wonder):
* component: pickling => symbolics
Old description:
> Saving and loading variables apparently doesn't reload the `latex_name`
> attribute:
>
> {{{
> ┌────────────────────────────────────────────────────────────────────┐
> │ Sage Version 6.4.1, Release Date: 2014-11-23 │
> │ Type "notebook()" for the browser-based notebook interface. │
> │ Type "help()" for help. │
> └────────────────────────────────────────────────────────────────────┘
> sage: xhat = SR.symbol( 'xhat', latex_name='\hat{x}' )
> sage: latex(xhat)
> \hat{x}
> sage: save_session( 'xhat' )
> sage: l = load( 'xhat.sobj' )
> sage: latex( l['xhat'] )
> \hat{x}
> sage:
> Exiting Sage (CPU time 0m0.20s, Wall time 2m49.25s).
> }}}
> {{{
> ┌────────────────────────────────────────────────────────────────────┐
> │ Sage Version 6.4.1, Release Date: 2014-11-23 │
> │ Type "notebook()" for the browser-based notebook interface. │
> │ Type "help()" for help. │
> └────────────────────────────────────────────────────────────────────┘
> sage: l = load( 'xhat.sobj' )
> sage: latex( l['xhat'] )
> \mathit{xhat}
> }}}
> It looks as if it tries to keep these objects unique, and `load()` will
> leave an existing variable's `latex_name` in place, but won't set it when
> creating a variable.
>
> I can see arguments for and against considering `SR.symbol('x',
> latex_name='y')` a different variable from `SR.symbol('x')`. It seems
> reasonable to consider them the same, in which case the latex name should
> be discarded if there's already a variable of the same name. But it
> should use the saved latex name when loading a variable that isn't
> already defined.
>
> Seems possibly related: #5466
>
> Update: I think this report, [https://groups.google.com/d/msg/sage-
> support/pZ4rCvBYtTY/b_KTxC-6BIoJ posted to sage-support today], is the
> same issue:
>
> > If you do something like this
> >
> > sage: a = var('a',latex_name='BLAH')
> >
> > and then
>
> > sage: a = var('a')
> > > sage: latex(a)
> > BLAH
> >
> > So the first a=var(...) did have an impact on the second one, no?
New description:
Saving and loading variables apparently doesn't reload the `latex_name`
attribute:
{{{
┌────────────────────────────────────────────────────────────────────┐
│ Sage Version 6.4.1, Release Date: 2014-11-23 │
│ Type "notebook()" for the browser-based notebook interface. │
│ Type "help()" for help. │
└────────────────────────────────────────────────────────────────────┘
sage: xhat = SR.symbol( 'xhat', latex_name='\hat{x}' )
sage: latex(xhat)
\hat{x}
sage: save_session( 'xhat' )
sage: l = load( 'xhat.sobj' )
sage: latex( l['xhat'] )
\hat{x}
sage:
Exiting Sage (CPU time 0m0.20s, Wall time 2m49.25s).
}}}
{{{
┌────────────────────────────────────────────────────────────────────┐
│ Sage Version 6.4.1, Release Date: 2014-11-23 │
│ Type "notebook()" for the browser-based notebook interface. │
│ Type "help()" for help. │
└────────────────────────────────────────────────────────────────────┘
sage: l = load( 'xhat.sobj' )
sage: latex( l['xhat'] )
\mathit{xhat}
}}}
It looks as if it tries to keep these objects unique, and `load()` will
leave an existing variable's `latex_name` in place, but won't set it when
creating a variable.
I can see arguments for and against considering `SR.symbol('x',
latex_name='y')` a different variable from `SR.symbol('x')`. It seems
reasonable to consider them the same, in which case the latex name should
be discarded if there's already a variable of the same name. But it
should use the saved latex name when loading a variable that isn't already
defined.
Seems possibly related: #5466
Update: I think this report, [https://groups.google.com/d/msg/sage-
support/pZ4rCvBYtTY/b_KTxC-6BIoJ posted to sage-support today], is the
same issue:
> If you do something like this
>
> sage: a = var('a',latex_name='BLAH')
>
> and then
> sage: a = var('a')
> sage: latex(a)
> BLAH
> So the first a=var(...) did have an impact on the second one, no?
--
--
Ticket URL: <http://trac.sagemath.org/ticket/17559#comment:4>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.