ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 14 Nov 2018 19:02:48 +0100Rename Lambda in weight spacehttps://ask.sagemath.org/question/44280/rename-lambda-in-weight-space/ It's a basic question, but after looking at the manual for a while I couldn't find the answer, so here goes.
R = RootSystem(["A",7])
print R.weight_lattice().fundamental_weight(1)
returns `Lambda[1]`. Is it possible to rename Lambda here? I could hack this by overriding the `.__str__` method, but is there a cleaner method?Wed, 14 Nov 2018 15:53:24 +0100https://ask.sagemath.org/question/44280/rename-lambda-in-weight-space/Answer by nbruin for <p>It's a basic question, but after looking at the manual for a while I couldn't find the answer, so here goes.</p>
<pre><code>R = RootSystem(["A",7])
print R.weight_lattice().fundamental_weight(1)
</code></pre>
<p>returns <code>Lambda[1]</code>. Is it possible to rename Lambda here? I could hack this by overriding the <code>.__str__</code> method, but is there a cleaner method?</p>
https://ask.sagemath.org/question/44280/rename-lambda-in-weight-space/?answer=44281#post-id-44281You can do something like
L = R.weight_lattice()
L._print_options['prefix"]="your_prefix_of_choice"
There may be a more elegant way than just reaching into the private "_print_options" attribute.
**EDIT:** There is indeed a more elegant way:
L.print_options(prefix="b")
Note that this design is fundamentally conceptually wrong: The "weight lattice" is a UniqueRepresentation object and as such absolutely needs to be immutable (unrelated code could end up with a reference to the same object). So, changing the prefix amounts to scribbling in a global variable. You may find that a weight lattice that has been constructed in a completely unrelated setting also changes print prefix.Wed, 14 Nov 2018 16:58:52 +0100https://ask.sagemath.org/question/44280/rename-lambda-in-weight-space/?answer=44281#post-id-44281Comment by pbelmans for <p>You can do something like</p>
<pre><code>L = R.weight_lattice()
L._print_options['prefix"]="your_prefix_of_choice"
</code></pre>
<p>There may be a more elegant way than just reaching into the private "_print_options" attribute.</p>
<p><strong>EDIT:</strong> There is indeed a more elegant way:</p>
<pre><code>L.print_options(prefix="b")
</code></pre>
<p>Note that this design is fundamentally conceptually wrong: The "weight lattice" is a UniqueRepresentation object and as such absolutely needs to be immutable (unrelated code could end up with a reference to the same object). So, changing the prefix amounts to scribbling in a global variable. You may find that a weight lattice that has been constructed in a completely unrelated setting also changes print prefix.</p>
https://ask.sagemath.org/question/44280/rename-lambda-in-weight-space/?comment=44282#post-id-44282Great, thanks! It's at least more elegant than overwriting `__str__`.Wed, 14 Nov 2018 19:02:48 +0100https://ask.sagemath.org/question/44280/rename-lambda-in-weight-space/?comment=44282#post-id-44282