Opened 6 years ago
Last modified 6 years ago
#17559 new defect
Incorrect caching of variables' latex_name attribute
Reported by: | wonder | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-6.5 |
Component: | symbolics | Keywords: | |
Cc: | Merged in: | ||
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
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, 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?
Change History (5)
comment:1 Changed 6 years ago by
- Summary changed from load_session loses variable's latex_name to load() loses variable's latex_name
comment:2 Changed 6 years ago by
- Summary changed from load() loses variable's latex_name to Incorrect caching of variables' latex_name attribute
comment:3 Changed 6 years ago by
- Description modified (diff)
comment:4 Changed 6 years ago by
- Component changed from pickling to symbolics
- Description modified (diff)
According to the sage-support thread in question, perhaps the more recent bug is different