Skip to content

Commit 0e88a87

Browse files
committed
Suggestions by tscrim
1 parent cbb774b commit 0e88a87

File tree

5 files changed

+92
-79
lines changed

5 files changed

+92
-79
lines changed

src/sage/matroids/basis_exchange_matroid.pyx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,8 +1237,8 @@ cdef class BasisExchangeMatroid(Matroid):
12371237
Return the Whitney numbers of the second kind of the matroid.
12381238
12391239
The Whitney numbers of the second kind are here encoded as a vector
1240-
`(W_0, ..., W_r)`, where `W_i` is the number of flats of rank `i`, and
1241-
`r` is the rank of the matroid.
1240+
`(W_0, \ldots, W_r)`, where `W_i` is the number of flats of rank `i`,
1241+
and `r` is the rank of the matroid.
12421242
12431243
OUTPUT: a list of integers
12441244
@@ -1949,15 +1949,16 @@ cdef class BasisExchangeMatroid(Matroid):
19491949
sage: M._weak_invariant() == N._weak_invariant()
19501950
False
19511951
"""
1952+
from sage.matroids.utilities import cmp_elements_key
19521953
if self._weak_invariant_var is None:
19531954
if self.full_rank() == 0 or self.full_corank() == 0:
19541955
self._weak_invariant_var = 0
19551956
self._weak_partition_var = SetSystem(self._E, [self.groundset()])
19561957
else:
19571958
k = min(self.full_rank() - 1, 2)
19581959
fie, f_vec = self._flat_element_inv(k)
1959-
self._weak_invariant_var = hash(tuple([tuple([(f, len(fie[f])) for f in sorted(fie, key=str)]), f_vec]))
1960-
self._weak_partition_var = SetSystem(self._E, [fie[f] for f in sorted(fie, key=str)])
1960+
self._weak_invariant_var = hash(tuple([tuple([(f, len(fie[f])) for f in sorted(fie, key=cmp_elements_key)]), f_vec]))
1961+
self._weak_partition_var = SetSystem(self._E, [fie[f] for f in sorted(fie, key=cmp_elements_key)])
19611962
return self._weak_invariant_var
19621963

19631964
cpdef _weak_partition(self) noexcept:

src/sage/matroids/circuits_matroid.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,9 @@ cdef class CircuitsMatroid(Matroid):
612612
sage: C1 == C2
613613
True
614614
"""
615+
from sage.matroids.utilities import cmp_elements_key
615616
if ordering is None:
616-
ordering = sorted(self.groundset(), key=str)
617+
ordering = sorted(self.groundset(), key=cmp_elements_key)
617618
else:
618619
if frozenset(ordering) != self.groundset():
619620
raise ValueError("not an ordering of the groundset")

src/sage/matroids/matroid.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ cdef class Matroid(SageObject):
220220
cpdef _internal(self, B) noexcept
221221
cpdef _external(self, B) noexcept
222222
cpdef tutte_polynomial(self, x=*, y=*) noexcept
223-
cpdef characteristic_polynomial(self, l=*) noexcept
223+
cpdef characteristic_polynomial(self, la=*) noexcept
224224
cpdef flat_cover(self, solver=*, verbose=*, integrality_tolerance=*) noexcept
225225

226226
# misc

0 commit comments

Comments
 (0)