Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ cpdef find_brouwer_separable_design(int k, int n):
from sage.combinat.designs.database import QDM as __QDM
cdef dict _QDM = __QDM
cdef dict ioa_indexed_by_n_minus_x = {}
for x in _QDM.itervalues():
for x in _QDM.values():
for (n, _, _, u), (k, _) in x.items():
if u > 1:
if n not in ioa_indexed_by_n_minus_x:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/graphs/base/boost_graph.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ cdef boost_clustering_coeff(BoostGenGraph *g, vertices):
result_d = g[0].clustering_coeff(vi)
sig_off()
clust_of_v[v] = result_d
return ((sum(clust_of_v.itervalues()) / len(clust_of_v)), clust_of_v)
return ((sum(clust_of_v.values()) / len(clust_of_v)), clust_of_v)


cpdef clustering_coeff(g, vertices=None):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ def get_orbits(list gens, int n):
OP_dealloc(OP)
sig_free(perm_ints)

return list(orbit_dict.itervalues())
return list(orbit_dict.values())


# Canonical augmentation
Expand Down
5 changes: 3 additions & 2 deletions src/sage/libs/gap/element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,13 @@ cdef Obj make_gap_record(sage_dict) except NULL:
sage: libgap({'a': 1, 'b':123}) # indirect doctest
rec( a := 1, b := 123 )
"""
data = [ (str(key), libgap(value)) for key, value in sage_dict.iteritems() ]

cdef list data
cdef Obj rec
cdef GapElement val
cdef UInt rnam

data = [(str(key), libgap(value)) for key, value in sage_dict.items()]

try:
GAP_Enter()
rec = GAP_NewPrecord(len(data))
Expand Down
7 changes: 3 additions & 4 deletions src/sage/libs/singular/option.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ cdef class LibSingularOptions_abstract:
sage: opt['degBound']
2
"""
for k,v in kwds.iteritems():
for k, v in kwds.items():
self[k] = v

def __getitem__(self, name):
Expand Down Expand Up @@ -615,7 +615,7 @@ cdef class LibSingularOptionsContext:
self.bck_degBound.append(Kstd1_deg)
self.bck_multBound.append(Kstd1_mu)
opt = self.opt.__class__()
for k,v in self.options.iteritems():
for k, v in self.options.items():
opt[k] = v

def __call__(self, **kwds):
Expand All @@ -631,8 +631,7 @@ cdef class LibSingularOptionsContext:
....: opt['redTail']
False
"""
new = self.__class__(self.opt, **kwds)
return new
return self.__class__(self.opt, **kwds)

def __exit__(self, typ, value, tb):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/matrix/matrix2.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3018,7 +3018,7 @@ cdef class Matrix(Matrix1):
return self.dense_matrix()

if self.is_sparse():
values = {ij: phi(v) for ij, v in self.dict().iteritems()}
values = {ij: phi(v) for ij, v in self.dict().items()}
if R is None:
R = sage.structure.sequence.Sequence(values.values()).universe()
else:
Expand Down
15 changes: 8 additions & 7 deletions src/sage/matrix/matrix_sparse.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ cdef class Matrix_sparse(matrix.Matrix):

cdef long h = 0, k, l
cdef Py_ssize_t i, j
for ij, x in D.iteritems():
for ij, x in D.items():
sig_check()
i = (<tuple>ij)[0]
j = (<tuple>ij)[1]
Expand Down Expand Up @@ -362,7 +362,7 @@ cdef class Matrix_sparse(matrix.Matrix):
def _unpickle_generic(self, data, int version):
cdef Py_ssize_t i, j
if version == -1:
for (i, j), x in data.iteritems():
for (i, j), x in data.items():
self.set_unsafe(i, j, x)
else:
raise RuntimeError("unknown matrix version (=%s)" % version)
Expand Down Expand Up @@ -643,7 +643,7 @@ cdef class Matrix_sparse(matrix.Matrix):
R = phi.codomain()
M = sage.matrix.matrix_space.MatrixSpace(R, self._nrows,
self._ncols, sparse=True)
return M({ij: phi(z) for ij, z in self.dict().iteritems()})
return M({ij: phi(z) for ij, z in self.dict().items()})

def apply_map(self, phi, R=None, sparse=True):
r"""
Expand Down Expand Up @@ -768,7 +768,7 @@ cdef class Matrix_sparse(matrix.Matrix):
zero_res = phi(self.base_ring()(0))
else:
zero_res = None
v = [(ij, phi(z)) for ij,z in self_dict.iteritems()]
v = [(ij, phi(z)) for ij,z in self_dict.items()]
if R is None:
w = [x for _, x in v]
if zero_res is not None:
Expand Down Expand Up @@ -826,7 +826,8 @@ cdef class Matrix_sparse(matrix.Matrix):

if self._nrows==0 or self._ncols==0:
return self.__copy__()
v = [(ij, sage.calculus.functional.derivative(z, var)) for ij, z in self.dict().iteritems()]
v = [(ij, sage.calculus.functional.derivative(z, var))
for ij, z in self.dict().items()]
if R is None:
w = [x for _, x in v]
w = sage.structure.sequence.Sequence(w)
Expand Down Expand Up @@ -1154,7 +1155,7 @@ cdef class Matrix_sparse(matrix.Matrix):
raise ArithmeticError("number of rows of matrix must equal degree of vector")
parent = self.row_ambient_module(base_ring=None, sparse=v.is_sparse_c())
s = parent.zero_vector()
for (i, j), a in self._dict().iteritems():
for (i, j), a in self._dict().items():
s[j] += v[i] * a
return s

Expand Down Expand Up @@ -1207,7 +1208,7 @@ cdef class Matrix_sparse(matrix.Matrix):
raise ArithmeticError("number of columns of matrix must equal degree of vector")
parent = self.column_ambient_module(base_ring=None, sparse=v.is_sparse_c())
s = parent.zero_vector()
for (i, j), a in self._dict().iteritems():
for (i, j), a in self._dict().items():
s[i] += a * v[j]
return s

Expand Down
2 changes: 1 addition & 1 deletion src/sage/matrix/matrix_symbolic_dense.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ cdef class Matrix_symbolic_dense(Matrix_generic_dense):

if args:
if len(args) == 1 and isinstance(args[0], dict):
kwargs = {repr(x): vx for x, vx in args[0].iteritems()}
kwargs = {repr(x): vx for x, vx in args[0].items()}
else:
raise ValueError('use named arguments, like EXPR(x=..., y=...)')

Expand Down
2 changes: 1 addition & 1 deletion src/sage/matrix/matrix_symbolic_sparse.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ cdef class Matrix_symbolic_sparse(Matrix_generic_sparse):

if args:
if len(args) == 1 and isinstance(args[0], dict):
kwargs = {repr(x): vx for x, vx in args[0].iteritems()}
kwargs = {repr(x): vx for x, vx in args[0].items()}
else:
raise ValueError('use named arguments, like EXPR(x=..., y=...)')

Expand Down
6 changes: 3 additions & 3 deletions src/sage/matroids/linear_matroid.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2200,14 +2200,14 @@ cdef class LinearMatroid(BasisExchangeMatroid):
while todo:
r = todo.pop()
cocirc = self.fundamental_cocycle(B, r)
for s, v in cocirc.iteritems():
for s, v in cocirc.items():
if s != r and s not in mult2:
mult2[s] = mult[r] * v
todo2.add(s)
while todo2:
s = todo2.pop()
circ = self.fundamental_cycle(B, s)
for t, w in circ.iteritems():
for t, w in circ.items():
if t != s and t not in mult:
mult[t] = mult2[s] / w
if t not in T:
Expand Down Expand Up @@ -2398,7 +2398,7 @@ cdef class LinearMatroid(BasisExchangeMatroid):
parallel = True
e = min(p)
ratio = c[e] / p[e]
for f, w in p.iteritems():
for f, w in p.items():
if c[f] / w != ratio:
parallel = False
break
Expand Down
4 changes: 2 additions & 2 deletions src/sage/matroids/matroid.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6160,7 +6160,7 @@ cdef class Matroid(SageObject):
if not G.is_connected():
return False
# Step 4: Apply algorithm recursively
for B, M in Y_components.iteritems():
for B, M in Y_components.items():
N = M.simplify()
new_basis = basis & (B | Y)
# the set of fundamental cocircuit that might be separating for N
Expand Down Expand Up @@ -7672,7 +7672,7 @@ cdef class Matroid(SageObject):
dist += 1
X3 = X2.intersection(w)

for x, y in layers.iteritems():
for x, y in layers.items():
for z in y:
d[z] = x
if not X3: # if no path from X1 to X2, then no augmenting set exists
Expand Down
2 changes: 1 addition & 1 deletion src/sage/matroids/union_matroid.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ cdef class MatroidSum(Matroid):
partition[i] = set()
partition[i].add(x)
r = 0
for (i, Xi) in partition.iteritems():
for i, Xi in partition.items():
r += self.summands[i]._rank(frozenset(Xi))
return r

Expand Down
2 changes: 1 addition & 1 deletion src/sage/misc/reset.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def restore(vars=None):

def _restore(G, D, vars):
if vars is None:
for k, v in D.iteritems():
for k, v in D.items():
G[k] = v
else:
if isinstance(vars, str):
Expand Down
34 changes: 0 additions & 34 deletions src/sage/misc/weak_dict.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -813,24 +813,6 @@ cdef class WeakValueDictionary(dict):
"""
return list(iter(self))

def itervalues(self):
"""
Deprecated.

EXAMPLES::

sage: import sage.misc.weak_dict
sage: class Vals(): pass
sage: L = [Vals() for _ in range(10)]
sage: D = sage.misc.weak_dict.WeakValueDictionary(enumerate(L))
sage: T = list(D.itervalues())
doctest:warning...:
DeprecationWarning: use values instead
See https://github.com/sagemath/sage/issues/34488 for details.
"""
deprecation(34488, "use values instead")
return self.values()

def values(self):
"""
Iterate over the values of this dictionary.
Expand Down Expand Up @@ -918,22 +900,6 @@ cdef class WeakValueDictionary(dict):
"""
return list(self.values())

def iteritems(self):
"""
EXAMPLES::

sage: import sage.misc.weak_dict
sage: class Vals(): pass
sage: L = [Vals() for _ in range(10)]
sage: D = sage.misc.weak_dict.WeakValueDictionary(enumerate(L))
sage: T = list(D.iteritems())
doctest:warning...:
DeprecationWarning: use items instead
See https://github.com/sagemath/sage/issues/34488 for details.
"""
deprecation(34488, "use items instead")
return self.items()

def items(self):
"""
Iterate over the items of this dictionary.
Expand Down
10 changes: 5 additions & 5 deletions src/sage/numerical/backends/cvxopt_backend.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ cdef class CVXOPTBackend(GenericBackend):

G = matrix(G)

#cvxopt minimizes on default
# cvxopt minimizes on default
if self.is_maximize:
c = [-1 * float(e) for e in self.objective_function]
else:
Expand All @@ -544,12 +544,12 @@ cdef class CVXOPTBackend(GenericBackend):
h = [float(e) for e in h]
h = matrix(h)

#solvers comes from the cvxopt library
for k,v in self.param.iteritems():
# solvers comes from the cvxopt library
for k, v in self.param.items():
solvers.options[k] = v
self.answer = solvers.lp(c,G,h)
self.answer = solvers.lp(c, G, h)

#possible outcomes
# possible outcomes
if self.answer['status'] == 'optimized':
pass
elif self.answer['status'] == 'primal infeasible':
Expand Down
8 changes: 4 additions & 4 deletions src/sage/numerical/backends/cvxopt_sdp_backend.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend):
G_temp.insert(j,[float(0) for t in range(self.matrices_dim[row_index]**2)])
G_matrix += [c_matrix(G_temp)]
debug_g += [(G_temp)]
#raise Exception("G_matrix " + str(debug_g) + "\nh_matrix: " + str(debug_h) + "\nc_matrix: " + str(debug_c))
# raise Exception("G_matrix " + str(debug_g) + "\nh_matrix: " + str(debug_h) + "\nc_matrix: " + str(debug_c))

#solvers comes from the cvxopt library
for k,v in self.param.iteritems():
# solvers comes from the cvxopt library
for k, v in self.param.items():
solvers.options[k] = v

self.answer = solvers.sdp(c,Gs=G_matrix,hs=h_matrix)

#possible outcomes
# possible outcomes
if self.answer['status'] == 'optimized':
pass
elif self.answer['status'] == 'primal infeasible':
Expand Down
12 changes: 6 additions & 6 deletions src/sage/numerical/backends/scip_backend.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,11 @@ cdef class SCIPBackend(GenericBackend):
self.model.freeTransform()
if coeff is None:
return self.variables[variable].getObj()
else:
objexpr = self.model.getObjective()
var = self.variables[variable]
linfun = sum([e * c for e, c in objexpr.terms.iteritems() if e != var]) + var * coeff
self.model.setObjective(linfun, sense=self.model.getObjectiveSense())

objexpr = self.model.getObjective()
var = self.variables[variable]
linfun = sum([e * c for e, c in objexpr.terms.items() if e != var]) + var * coeff
self.model.setObjective(linfun, sense=self.model.getObjectiveSense())

cpdef problem_name(self, name=None):
"""
Expand Down Expand Up @@ -500,7 +500,7 @@ cdef class SCIPBackend(GenericBackend):
valslinear = self.model.getValsLinear(self.get_constraints()[index])
cdef list indices = []
cdef list values = []
for var, coeff in valslinear.iteritems():
for var, coeff in valslinear.items():
indices.append(namedvars.index(var))
values.append(coeff)
return (indices, values)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/numerical/linear_functions.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ cdef class LinearFunctionsParent_class(Parent):
cdef class LinearFunction(LinearFunctionOrConstraint):
cdef dict _f
cpdef _add_(self, other)
cpdef iteritems(self)
cpdef items(self)
cpdef _acted_upon_(self, x, bint self_on_left)
cpdef is_zero(self)
cpdef equals(LinearFunction left, LinearFunction right)
Expand Down
Loading
Loading