sagemath / sage

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

py3 care for range again #22779

Closed fchapoton closed 7 years ago

fchapoton commented 7 years ago

another step in taking care of range, towards python3

part of #16081

CC: @tscrim @jm58660 @jdemeyer

Component: python3

Author: Frédéric Chapoton

Branch/Commit: 0d3b15a

Reviewer: Travis Scrimshaw

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

fchapoton commented 7 years ago

Branch: u/chapoton/22779

fchapoton commented 7 years ago

New commits:

2d622e9trac 22779 py3 range in various files
fchapoton commented 7 years ago

Commit: 2d622e9

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

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

bd4921etrac 22779 one more fix for range
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 7 years ago

Changed commit from 2d622e9 to bd4921e

tscrim commented 7 years ago
comment:4

These changes seem to be unnecessary in both Python 2 and 3:

@@ -483,7 +484,7 @@ class SimplicialSetMorphism(Morphism):
             if constant is not None:
                 self._constant = constant
                 check = False
-                data = {sigma: constant.apply_degeneracies(*range(sigma.dimension()-1,-1,-1))
+                data = {sigma: constant.apply_degeneracies(*list(range(sigma.dimension()-1,-1,-1)))
                         for sigma in domain.nondegenerate_simplices()}

         if (not isinstance(domain, SimplicialSet_arbitrary)
@@ -634,7 +635,7 @@ class SimplicialSetMorphism(Morphism):
             raise ValueError('element is not a simplex in the domain')
         if self.is_constant():
             target = self._constant
-            return target.apply_degeneracies(*range(x.dimension()-1,-1,-1))
+            return target.apply_degeneracies(*list(range(x.dimension()-1,-1,-1)))
         if self._is_identity:
             return x
         return self._dictionary[x.nondegenerate()].apply_degeneracies(*x.degeneracies())

In both Python 2 and 3:

>>> from six.moves import range  # in python 2
>>> it = range(5)
>>> def foo(*args):
...     print(args)
... 
>>> foo(*it)
(0, 1, 2, 3, 4)
>>> it = iter([1,2,3])
>>> foo(*it)
(1, 2, 3)
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 7 years ago

Changed commit from bd4921e to 0d3b15a

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

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

0d3b15atrac 22779 undo change in simplicial set morphism
fchapoton commented 7 years ago
comment:6

thanks, undone

tscrim commented 7 years ago
comment:7

Thanks. LGTM.

tscrim commented 7 years ago

Reviewer: Travis Scrimshaw

vbraun commented 7 years ago

Changed branch from u/chapoton/22779 to 0d3b15a