Skip to content

Commit

Permalink
Trac #22485: py3 get rid of the last .iteritems
Browse files Browse the repository at this point in the history
as a move to py3

possibly the last step to fix #15981 ?

just touch one file, which is cleaned-up a little bit

URL: https://trac.sagemath.org/22485
Reported by: chapoton
Ticket author(s): Frédéric Chapoton
Reviewer(s): André Apitzsch
  • Loading branch information
Release Manager authored and vbraun committed Mar 6, 2017
2 parents 2d5b437 + d04a0d3 commit c23563a
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions src/sage/modules/multi_filtered_vector_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
# the License, or (at your option) any later version.
# http://www.gnu.org/licenses/
#*****************************************************************************
from six import iteritems

from sage.rings.all import QQ, ZZ, RDF, RR, Integer
from sage.rings.infinity import InfinityRing, infinity, minus_infinity
Expand Down Expand Up @@ -186,10 +187,11 @@ def change_ring(self, base_ring):
sage: MultiFilteredVectorSpace(3, base_ring=QQ).change_ring(RR)
Unfiltered RR^3
"""
if len(self._filt) == 0:
return MultiFilteredVectorSpace(self.dimension(), base_ring=base_ring)
filtrations = dict()
for key, F in self._filt.iteritems():
if not self._filt:
return MultiFilteredVectorSpace(self.dimension(),
base_ring=base_ring)
filtrations = {}
for key, F in iteritems(self._filt):
filtrations[key] = F.change_ring(base_ring)
return MultiFilteredVectorSpace(filtrations, base_ring=base_ring)

Expand Down Expand Up @@ -322,7 +324,7 @@ def min_degree(self):
sage: V.min_degree()
1
"""
if len(self._filt) == 0:
if not self._filt:
return infinity
return min(F.min_degree() for F in self._filt.values())

Expand All @@ -345,7 +347,7 @@ def max_degree(self):
sage: V.max_degree()
4
"""
if len(self._filt) == 0:
if not self._filt:
return minus_infinity
return max(F.max_degree() for F in self._filt.values())

Expand Down Expand Up @@ -453,8 +455,9 @@ def _repr_(self):
sage: MultiFilteredVectorSpace(123, base_ring=RR)
Unfiltered RR^123
"""
if len(self._filt) == 0:
F = FilteredVectorSpace(self.dimension(), base_ring=self.base_ring())
if not self._filt:
F = FilteredVectorSpace(self.dimension(),
base_ring=self.base_ring())
return 'Unfiltered ' + repr(F)
rows = []
support = self.support()
Expand Down Expand Up @@ -489,7 +492,7 @@ def __cmp__(self, other):
False
"""
return cmp(self._filt, other._filt)

def direct_sum(self, other):
"""
Return the direct sum.
Expand Down Expand Up @@ -522,8 +525,9 @@ def direct_sum(self, other):
b: QQ^3 >= QQ^2 >= QQ^2 >= QQ^2 >= 0
"""
if not self.index_set() == other.index_set():
raise ValueError('the index sets of the two summands must be the same')
filtrations = dict()
raise ValueError('the index sets of the two summands'
' must be the same')
filtrations = {}
for key in self.index_set():
filtrations[key] = self._filt[key] + other._filt[key]
return MultiFilteredVectorSpace(filtrations)
Expand Down Expand Up @@ -563,8 +567,9 @@ def tensor_product(self, other):
b: QQ^2 >= QQ^2 >= QQ^1 >= QQ^1 >= QQ^1 >= 0
"""
if not self.index_set() == other.index_set():
raise ValueError('the index sets of the two summands must be the same')
filtrations = dict()
raise ValueError('the index sets of the two summands'
' must be the same')
filtrations = {}
for key in self.index_set():
filtrations[key] = self._filt[key] * other._filt[key]
return MultiFilteredVectorSpace(filtrations)
Expand Down Expand Up @@ -595,7 +600,7 @@ def exterior_power(self, n):
a: QQ^1 >= 0 >= 0
b: QQ^1 >= QQ^1 >= 0
"""
filtrations = dict()
filtrations = {}
for key in self.index_set():
filtrations[key] = self._filt[key].exterior_power(n)
return MultiFilteredVectorSpace(filtrations)
Expand Down Expand Up @@ -626,7 +631,7 @@ def symmetric_power(self, n):
a: QQ^3 >= QQ^3 >= QQ^3 >= 0 >= 0 >= 0 >= 0 >= 0
b: QQ^3 >= QQ^2 >= QQ^2 >= QQ^2 >= QQ^1 >= QQ^1 >= QQ^1 >= 0
"""
filtrations = dict()
filtrations = {}
for key in self.index_set():
filtrations[key] = self._filt[key].symmetric_power(n)
return MultiFilteredVectorSpace(filtrations)
Expand All @@ -650,7 +655,7 @@ def dual(self):
a: QQ^2 >= QQ^2 >= QQ^2 >= 0 >= 0
b: QQ^2 >= QQ^1 >= QQ^1 >= QQ^1 >= 0
"""
filtrations = dict()
filtrations = {}
for key in self.index_set():
filtrations[key] = self._filt[key].dual()
return MultiFilteredVectorSpace(filtrations)
Expand All @@ -674,7 +679,7 @@ def shift(self, deg):
sage: V.shift(-5).support()
(-5, -4, -2)
"""
filtrations = dict()
filtrations = {}
for key in self.index_set():
filtrations[key] = self._filt[key].shift(deg)
return MultiFilteredVectorSpace(filtrations)
Expand Down Expand Up @@ -706,7 +711,7 @@ def random_deformation(self, epsilon=None):
Basis matrix:
[ 1 8/1197]
"""
filtrations = dict()
filtrations = {}
for key in self.index_set():
filtrations[key] = self._filt[key].random_deformation(epsilon)
return MultiFilteredVectorSpace(filtrations)

0 comments on commit c23563a

Please sign in to comment.