Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
taking care of the remaining classic divisions in combinat folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Frédéric Chapoton committed Apr 19, 2016
1 parent 0aec256 commit 4688e64
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/sage/combinat/alternating_sign_matrix.py
Expand Up @@ -1273,7 +1273,7 @@ def from_height_function(self,height):
[ 1 -1 1]
[ 0 1 0]
"""
return self.from_corner_sum(matrix( [[((i+j-height[i][j])/int(2))
return self.from_corner_sum(matrix( [[((i+j-height[i][j])//int(2))
for i in range(len(list(height)))]
for j in range(len(list(height)))] ))

Expand Down
4 changes: 2 additions & 2 deletions src/sage/combinat/diagram_algebras.py
Expand Up @@ -282,7 +282,7 @@ def check(self):
"""
if self._base_diagram:
tst = sorted(flatten(self._base_diagram))
if len(tst) % 2 != 0 or tst != range(-len(tst)/2,0) + range(1,len(tst)/2+1):
if len(tst) % 2 != 0 or tst != range(-len(tst) // 2,0) + range(1,len(tst) // 2+1):
raise ValueError("this does not represent two rows of vertices")

def __eq__(self, other):
Expand Down Expand Up @@ -744,7 +744,7 @@ def __contains__(self, obj):
return False
if len(obj.base_diagram()) > 0:
tst = sorted(flatten(obj.base_diagram()))
if len(tst)%2 != 0 or tst != range(-len(tst)/2,0) + range(1,len(tst)/2+1):
if len(tst)%2 != 0 or tst != range(-len(tst)//2,0) + range(1,len(tst)//2+1):
return False
return True
return self.order == 0
Expand Down
14 changes: 7 additions & 7 deletions src/sage/combinat/fully_packed_loop.py
Expand Up @@ -490,7 +490,7 @@ def __init__(self, parent, generator):
self._six_vertex_model = generator

self.configuration = matrix(list(self._six_vertex_model))
self._n = len(self._end_point_dictionary)/2
self._n = len(self._end_point_dictionary) // 2
Element.__init__(self, parent)

def _repr_(self):
Expand Down Expand Up @@ -1204,30 +1204,30 @@ def _end_point_dictionary(self):
for k in range(n):
if k % 2 == 0:
# top row
end_points[1 + k/2] = (0, k)
end_points[1 + k // 2] = (0, k)

# bottom row
end_points[n + 1 + k/2] = (n-1, n-1-k)
end_points[n + 1 + k // 2] = (n-1, n-1-k)

# sides for even case
if n % 2 == 0:
for k in range(n):
if k % 2 == 0:
# left side
end_points[((3*n + 2 + k)/2)] = (n-1-k, 0)
end_points[((3*n + 2 + k) // 2)] = (n-1-k, 0)

# right side
end_points[(n + 2 + k)/2] = (k, n-1)
end_points[(n + 2 + k) // 2] = (k, n-1)

# side for odd case
if n % 2 == 1:
for k in range(n):
if k % 2 == 1:
# left side
end_points[(3*n + 2 + k)/2] = (n-1-k, 0)
end_points[(3*n + 2 + k) // 2] = (n-1-k, 0)

# right side
end_points[(n + 2 + k)/2] = (k, n-1)
end_points[(n + 2 + k) // 2] = (k, n-1)

return end_points

Expand Down
3 changes: 2 additions & 1 deletion src/sage/combinat/perfect_matching.py
Expand Up @@ -834,7 +834,8 @@ def to_non_crossing_set_partition(self):
raise ValueError("matching must be non-crossing")
else:
perm = self.to_permutation()
perm2 = Permutation([(perm[2*i])/2 for i in range(len(perm)/2)])
perm2 = Permutation([perm[2 * i] // 2
for i in range(len(perm) // 2)])
return SetPartition(perm2.cycle_tuples())


Expand Down
11 changes: 6 additions & 5 deletions src/sage/combinat/q_analogues.py
Expand Up @@ -278,8 +278,8 @@ def q_binomial(n, k, q=None, algorithm='auto'):
is_polynomial = isinstance(q, Polynomial)

R = parent(q)
zero = R(0)
one = R(1)
zero = R.zero()
one = R.one()

if not(0 <= k and k <= n):
return zero
Expand All @@ -290,7 +290,7 @@ def q_binomial(n, k, q=None, algorithm='auto'):
if algorithm == 'auto':
from sage.symbolic.ring import SR
if is_polynomial:
if n <= 70 or k <= n/4:
if n <= 70 or k <= n // 4:
algorithm = 'naive'
else:
algorithm = 'cyclo_polynomial'
Expand Down Expand Up @@ -325,11 +325,12 @@ def q_binomial(n, k, q=None, algorithm='auto'):
from sage.rings.polynomial.cyclotomic import cyclotomic_value
return prod(cyclotomic_value(d,q)
for d in range(2,n+1)
if (n/d).floor() != (k/d).floor() + ((n-k)/d).floor())
if (n//d) != (k//d) + ((n-k)//d))
elif algorithm == 'cyclo_polynomial':
return prod(R.cyclotomic_polynomial(d)
for d in range(2,n+1)
if (n/d).floor() != (k/d).floor() + ((n-k)/d).floor())
if (n//d) != (k//d) + ((n-k)//d))


def gaussian_binomial(n, k, q=None, algorithm='auto'):
r"""
Expand Down
8 changes: 4 additions & 4 deletions src/sage/combinat/ribbon_tableau.py
Expand Up @@ -106,20 +106,20 @@ def length(self):
sage: RibbonTableau([[1,0],[2,0]]).length()
2
"""
if self.to_expr() == [[],[]]:
if self.to_expr() == [[], []]:
return 0

tableau = self.to_expr()[1]
l = 0
t = 0
for k in range(len(tableau)):
t += len( [ x for x in tableau[k] if x is not None and x > -1 ] )
l += len( [ x for x in tableau[k] if x is not None and x > 0 ] )
t += len([ x for x in tableau[k] if x is not None and x > -1])
l += len([ x for x in tableau[k] if x is not None and x > 0])

if l == 0:
return t
else:
return t/l
return t // l

def to_word(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/subword_complex.py
Expand Up @@ -341,7 +341,7 @@ def upper_root_configuration(self):
conf = self._root_configuration_indices()
W = self.parent().group()
Phi = W.roots()
N = len(Phi) / 2
N = len(Phi) // 2
return [Phi[i - N] for i in conf if i >= N]

# weights
Expand Down
4 changes: 2 additions & 2 deletions src/sage/combinat/tiling.py
Expand Up @@ -1479,8 +1479,8 @@ def _rows_mod_box_isometries(self, i):
We test that there are four times less rows for that polyomino::
sage: len(T.rows()) / len(T._rows_mod_box_isometries(0))
4
sage: len(T.rows()) == 4 * len(T._rows_mod_box_isometries(0))
True
Now, a real use case. A solution of the game Quantumino is a tiling
of a 5x8x2 box. Since a 5x8x2 box has four orientation preserving
Expand Down

0 comments on commit 4688e64

Please sign in to comment.