Repository: sympy/sympy

Issue:
PolyRing.index doesn't appear to follow Python's list indexing convention
I was using the `PolyRing.index()` function during a study:

https://github.com/sympy/sympy/blob/13bb6ab638b2c81a47c3f588130993730d54dd2b/sympy/polys/rings.py#L417-L446

There's a branch that's entered when the input `gen` is an `int` and specifically when it's a negative integer, in the range `[-self.ngens, -1]`, I guess here the Python convention of indexing a list is followed and passing a negative index in the correct range returns element from the end of the list iterating backwards. 

Although I'm not sure if the behavior here is correctly matching the Python convention or not:

```python
In [1]: from sympy.polys.rings import PolyRing

In [2]: from sympy import ZZ

In [3]: ring_zz = PolyRing(['x', 'y', 'z'], ZZ)

In [4]: x, y, z = ring_zz.gens

In [5]: ring_zz.index(0) # index of x
Out[5]: 0

In [6]: ring_zz.index(1) # index of y
Out[6]: 1

In [7]: ring_zz.index(2) # index of z
Out[7]: 2

In [8]: ring_zz.index(-1) # Should return 2, iterating from the back for -ve i, returns 0 instead
Out[8]: 0
```
Maybe, the branch should look like this then:
```python
        elif isinstance(gen, int):
            i = gen

            if 0 <= i and i < self.ngens:
                pass
            elif -self.ngens <= i and i <= -1:
                i = self.ngens + i # instead of -i - 1
            else:
                raise ValueError("invalid generator index: %s" % gen)
        elif self.is_element(gen):
            try:
                i = self.gens.index(gen)
            except ValueError:
                raise ValueError("invalid generator: %s" % gen)
```
Am I making this out wrong or thinking in the wrong way and returning `0` was actually the ideal behavior ? If it is then let me know, if this is indeed a bug, then I think it will be a quick patch. 

Discussion:

Fix (patch):
diff --git a/sympy/polys/rings.py b/sympy/polys/rings.py
index ba50af4c71..8cf5d11831 100644
--- a/sympy/polys/rings.py
+++ b/sympy/polys/rings.py
@@ -485,9 +485,6 @@ def _gen_index(self, gen):
         if isinstance(gen, int):
             if 0 <= gen < self.ngens:
                 return gen
-            elif -self.ngens <= gen <= -1:
-                gen = -gen - 1
-                return gen
             else:
                 raise ValueError(f"invalid generator index: {gen}")
         else:  # gen is a string


Test changes:
diff --git a/sympy/polys/tests/test_rings.py b/sympy/polys/tests/test_rings.py
index d3e4b518fb..7c17f10234 100644
--- a/sympy/polys/tests/test_rings.py
+++ b/sympy/polys/tests/test_rings.py
@@ -252,7 +252,8 @@ def test_PolyRing_index():
     assert ring.index(0) == 0
     assert ring.index(1) == 1
     assert ring.index(2) == 2
-    assert ring.index(-1) == 0
+
+    raises(ValueError, lambda: ring.index(-1)) # negative generator indices not allowed
 
     R = PolyRing('x,y,z', ZZ, lex)
     x, y, z = ring.gens