sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.4k stars 473 forks source link

Py3 : database.oeis implement __getitem__ to replace __getslice__ #26704

Closed 4a781b2b-eada-4ae4-9b46-f6cbb63459b9 closed 5 years ago

4a781b2b-eada-4ae4-9b46-f6cbb63459b9 commented 5 years ago

Fix database.oeis module for python3 :

__getslice__ is deprecated since python 2.6 and removed in python 3.x

Component: python3

Keywords: thursdaysbdx

Author: Vincent Klein

Branch/Commit: 7d03e29

Reviewer: Frédéric Chapoton

Issue created by migration from https://trac.sagemath.org/ticket/26704

4a781b2b-eada-4ae4-9b46-f6cbb63459b9 commented 5 years ago

Description changed:

--- 
+++ 
@@ -1,4 +1,4 @@
 Fix database.oeis module for python3 : 
 - Remove an useless test
-- Replace `__getslice__` method with __getitem__.
+- Replace `__getslice__` method with `__getitem__` for `FancyTuple` object.
 `__getslice__` is deprecated since python 2.6 and removed in python 3.x
4a781b2b-eada-4ae4-9b46-f6cbb63459b9 commented 5 years ago

Branch: u/vklein/develop

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

Commit: ad8e0b8

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

ad8e0b8Trac #26704: Define `__getslice__` for python2
4a781b2b-eada-4ae4-9b46-f6cbb63459b9 commented 5 years ago

Changed commit from ad8e0b8 to none

4a781b2b-eada-4ae4-9b46-f6cbb63459b9 commented 5 years ago

Changed branch from u/vklein/develop to none

4a781b2b-eada-4ae4-9b46-f6cbb63459b9 commented 5 years ago

Description changed:

--- 
+++ 
@@ -1,4 +1,6 @@
 Fix database.oeis module for python3 : 
-- Remove an useless test
-- Replace `__getslice__` method with `__getitem__` for `FancyTuple` object.
+- Remove a useless test
+- Define `__getitem__` method with for `FancyTuple` object. It replace `__getslice__` method in python3.
+As `__getslice__` is still defined in tuple in python 2.7 we still need a `__getslice__` method in `FancyTuple` to override it.
+
 `__getslice__` is deprecated since python 2.6 and removed in python 3.x
4a781b2b-eada-4ae4-9b46-f6cbb63459b9 commented 5 years ago

Branch: u/vklein/26704

4a781b2b-eada-4ae4-9b46-f6cbb63459b9 commented 5 years ago

Commit: ad8e0b8

4a781b2b-eada-4ae4-9b46-f6cbb63459b9 commented 5 years ago

New commits:

840f17aTrac #26704: Fix database.oeis module for python3 :
ad8e0b8Trac #26704: Define `__getslice__` for python2
fchapoton commented 5 years ago
comment:7

Please add documentation and doctests to the new __getitem__ method.

4a781b2b-eada-4ae4-9b46-f6cbb63459b9 commented 5 years ago
comment:8

It would be the same doctests as those of __getslice__.

What do you think is the most appropriate ? :

  1. Leave as it is.
  2. Add documentation.
  3. Add documentation and doctests and then have the sames tests two times.
fchapoton commented 5 years ago
comment:9

either duplicate the doc or add a doctest for when the argument is not a slice but just one element

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

e3499b4Trac #26704: Fix database.oeis module for python3 :
9cae5bbTrac #26704: Define `__getslice__` for python2
34c80dcTrac #26704: Add doctests for __getitem__.
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

Changed commit from ad8e0b8 to 34c80dc

4a781b2b-eada-4ae4-9b46-f6cbb63459b9 commented 5 years ago
comment:11

Replying to @fchapoton:

either duplicate the doc or add a doctest for when the argument is not a slice but just one element

I ve done the second one.

fchapoton commented 5 years ago
comment:12

manque une ligne vide en dessous de TESTS::

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

Changed commit from 34c80dc to af1e030

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

af1e030Trac #26704: Add a mising Blankline after TESTS::.
4a781b2b-eada-4ae4-9b46-f6cbb63459b9 commented 5 years ago
comment:14

Replying to @fchapoton:

manque une ligne vide en dessous de TESTS::

My bad.

And my newest tests won't work in py2 as sage: ft[0] return '\xc3\xa9'.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

Changed commit from af1e030 to 7d03e29

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

7d03e29Trac #26704: Fix `__getitem__` doctests for python2
4a781b2b-eada-4ae4-9b46-f6cbb63459b9 commented 5 years ago

Changed keywords from none to thursdaysbdx

4a781b2b-eada-4ae4-9b46-f6cbb63459b9 commented 5 years ago
comment:17

Fixed

fchapoton commented 5 years ago

Reviewer: Frédéric Chapoton

fchapoton commented 5 years ago
comment:19

ok, thanks

vbraun commented 5 years ago

Changed branch from u/vklein/26704 to 7d03e29