Skip to content

Commit

Permalink
sagemathgh-36553: Add a hash function for the class TernaryQF.
Browse files Browse the repository at this point in the history
PR from sagemath#16956 (rebased from https://github.com/sagemath/sagetrac-
mirror/commit/091cbbdf6eed2c8bccca407addd07ff08e429c17)

Author: Gustavo Rama

### 📝 Checklist

- [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.

URL: sagemath#36553
Reported by: Gonzalo Tornaría
Reviewer(s):
  • Loading branch information
Release Manager committed Oct 28, 2023
2 parents ab10fe9 + 65be016 commit 64b399a
Show file tree
Hide file tree
Showing 3 changed files with 17 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=aa7054a0e6a582d2db1475dc47f63a54e6ac569f
md5=40eab024557ad51e08dfb08e2753a465
cksum=802824779
sha1=83682149aa0c33301f1742ef33fff6e95f7b099c
md5=715e6e15ab579b997de55b6644af54f9
cksum=363791132
2 changes: 1 addition & 1 deletion build/pkgs/configure/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c47788b02a42ef4907a0e61e702fbe9bbef27590
4f15805fd81ea2a59964ce343faeaa353fd32c50
13 changes: 13 additions & 0 deletions src/sage/quadratic_forms/ternary_qf.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,19 @@ def coefficients(self):
"""
return self._a, self._b, self._c, self._r, self._s, self._t

def __hash__(self):
"""
Returns a hash for self.
EXAMPLES::
sage: Q = TernaryQF([1, 2, 3, 4, 5, 6])
sage: Q.__hash__()
5881802312257552497
"""

return hash(self.coefficients())

def coefficient(self, n):
r"""
Return the `n`-th coefficient of the ternary quadratic form.
Expand Down

0 comments on commit 64b399a

Please sign in to comment.