Skip to content

Commit

Permalink
sagemathgh-36170: Fix the ascii art for the Heisenberg Lie algebras
Browse files Browse the repository at this point in the history
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

Applying `ascii_art(x)` to any element of the finite-dimensional
Heisenberg algebra raises an error due to a missing method
`_ascii_art_term`. We implement this.

<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->

URL: sagemath#36170
Reported by: Travis Scrimshaw
Reviewer(s): Frédéric Chapoton
  • Loading branch information
Release Manager committed Sep 2, 2023
2 parents f55e524 + 098ce29 commit 7ad2d9c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
6 changes: 3 additions & 3 deletions build/pkgs/configure/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tarball=configure-VERSION.tar.gz
sha1=80ee52a3b6855149693204f0816bd0690947e7ae
md5=4292c175bba9299bd057980cec7060fd
cksum=3914108326
sha1=402380b47b913708343c09557a28a1a7b43d836b
md5=97856a160839007d3a546bfedb7f47b0
cksum=1229430481
2 changes: 1 addition & 1 deletion build/pkgs/configure/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
57852a89c5c274ec6dbdd9269042972c7343e3ec
e091f3a0d28dd7daf0b1fade564aac5fe5006feb
17 changes: 17 additions & 0 deletions src/sage/algebras/lie_algebras/heisenberg.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,23 @@ def _repr_term(self, m):
"""
return m

def _ascii_art_term(self, m):
r"""
Return a string representation of the term indexed by ``m``.
EXAMPLES::
sage: H = lie_algebras.Heisenberg(QQ, 3)
sage: H._ascii_art_term('p1')
p1
sage: H._ascii_art_term('z')
z
sage: ascii_art(sum(i * b for i, b in enumerate(H.basis())))
p2 + 2*p3 + 3*q1 + 4*q2 + 5*q3 + 6*z
"""
from sage.typeset.ascii_art import ascii_art
return ascii_art(m)

def _latex_term(self, m):
r"""
Return a string representation of the term indexed by ``m``.
Expand Down

0 comments on commit 7ad2d9c

Please sign in to comment.