Repository: sagemath/sage

Issue:
Missing __hash__ function for elements of FundamentalGroupOfExtendedAffineWeylGroup
### Steps To Reproduce

1. Build the latest version of sagemath from source (though the issue persists in any version of sagemath I encountered over the past years)
2. Open a sagemath console
3. Create an `ExtendedAffineWeylGroup`, e.g.
```
W = ExtendedAffineWeylGroup('A4')
```
4. Create an element of the corresponding `fundamental_group` or `FW`-group, e.g.
```
fun = W.fundamental_group().an_element()
w = W.FW().an_element()
```
5. Attempt to calculate the `hash`-function of said element, or use it in a data structure that depends on it (e.g. as key in a dictionary)
```
hash(fun)
dictionary = {w: 0}
```

### Expected Behavior

The expression `hash(fun)` should evaluate to some integer which is unique among elements of the same fundamental group. The expression `{w: 0}` should evaluate to a python dictionary with `w` as its key.

The Borovoi fundamental group of an extended affine Weyl group is a finite or infinite cyclic group associated to an extended affine Weyl group. Its elements should be considered as mathematical objects and are hence immutable. Associating additional information to them in a python dictionary is desirable in some applications.

The extended affine Weyl group can be constructed as a semidirect product of the non-extended affine Weyl group (which is canonically a Coxeter group) and the Borovoi fundamental group. Its elements should be considered as mathematical objects and are hence immutable. Associating additional information to them in a python dictionary is desirable in many applications. As of now, one has to convert to a different construction of the extended affine Weyl group to do so, e.g.
```
dictionary = {W.W0P()(w): 0}
```
works. However, this conversion makes the code less readable, and can be very time-consuming for large groups and large elements.

### Actual Behavior

```
TypeError: unhashable type: 'FundamentalGroupOfExtendedAffineWeylGroup_Class_with_category.element_class'
```


### Additional Information

Adding the obvious two lines of code to `sage/combinat/root_system/fundamental_group.py` fixes the issue. I will try to submit a corresponding pull request.

### Environment

```markdown
- **OS**: Linux 6.4.0-2-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.4.4-3 (2023-08-08) x86_64 GNU/Linux
- **Sage Version**: SageMath version 10.1, Release Date: 2023-08-20. Using Python 3.11.4.
```


### Checklist

- [X] I have searched the existing issues for a bug report that matches the one I want to file, without success.
- [X] I have read the documentation and troubleshoot guide


Discussion:

Resolving patch:
diff --git a/src/sage/combinat/root_system/fundamental_group.py b/src/sage/combinat/root_system/fundamental_group.py
--- a/src/sage/combinat/root_system/fundamental_group.py
+++ b/src/sage/combinat/root_system/fundamental_group.py
@@ -324,6 +324,21 @@ def act_on_affine_lattice(self, wt):
         """
         return wt.map_support(self.parent().action(self.value()))
 
+    def __hash__(self):
+        r"""
+        Return the hash of ``self``.
+
+        TESTS:
+
+        Check that :issue:`36121` is fixed::
+
+            sage: W = ExtendedAffineWeylGroup('A4')
+            sage: fun = W.fundamental_group().an_element()
+            sage: hash(fun) == hash(fun.value())
+            True
+        """
+        return hash(self.value())
+
 
 class FundamentalGroupOfExtendedAffineWeylGroup_Class(UniqueRepresentation,
                                                       Parent):


Test patch: