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

Commit a7c8bb9

Browse files
committed
Use items instead of iteritems (py3)
1 parent e29f667 commit a7c8bb9

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

src/sage/functions/piecewise.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,30 @@ def expressions(cls, self, parameters, variable):
384384
"""
385385
return tuple(fun for dom, fun in parameters)
386386

387-
def iteritems(cls, self, parameters, variable):
387+
def items(cls, self, parameters, variable):
388+
"""
389+
Iterate over the pieces of the piecewise function
390+
391+
.. NOTE::
392+
393+
You should probably use :meth:`pieces` instead, which
394+
offers a nicer interface.
395+
396+
OUTPUT:
397+
398+
This method iterates over pieces of the piecewise
399+
function, each represented by a pair. The first element is
400+
the support, and the second the function over that
401+
support.
402+
403+
EXAMPLES::
404+
405+
sage: f = piecewise([([0,0], sin(x)), ((0,2), cos(x))])
406+
sage: for support, function in f.items():
407+
....: print('support is {0}, function is {1}'.format(support, function))
408+
support is {0}, function is sin(x)
409+
support is (0, 2), function is cos(x)
410+
"""
388411
for pair in parameters:
389412
yield pair
390413

@@ -407,7 +430,7 @@ def __call__(cls, self, parameters, variable, value=None, **kwds):
407430
"""
408431
self = piecewise(parameters, var=variable)
409432
substitution = dict()
410-
for k, v in kwds.iteritems():
433+
for k, v in kwds.items():
411434
substitution[SR.var(k)] = v
412435
if value is not None:
413436
substitution[variable] = value
@@ -896,7 +919,7 @@ def convolution(cls, self, parameters, variable, other):
896919
uu = SR.var('uu')
897920
conv = 0
898921
fd,f0 = parameters[0]
899-
gd,g0 = other.iteritems().next()
922+
gd,g0 = next(other.items())
900923
if len(f)==1 and len(g)==1:
901924
f = f.unextend_zero()
902925
g = g.unextend_zero()

0 commit comments

Comments
 (0)