MCPcopy Index your code
hub / github.com/python/cpython / Squares

Class Squares

Lib/test/test_functools.py:1038–1052  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1036class TestReduce:
1037 def test_reduce(self):
1038 class Squares:
1039 def __init__(self, max):
1040 self.max = max
1041 self.sofar = []
1042
1043 def __len__(self):
1044 return len(self.sofar)
1045
1046 def __getitem__(self, i):
1047 if not 0 <= i < self.max: raise IndexError
1048 n = len(self.sofar)
1049 while n <= i:
1050 self.sofar.append(n*n)
1051 n += 1
1052 return self.sofar[i]
1053 def add(x, y):
1054 return x + y
1055 self.assertEqual(self.reduce(add, ['a', 'b', 'c'], ''), 'abc')

Callers 1

test_reduceMethod · 0.70

Calls

no outgoing calls

Tested by 1

test_reduceMethod · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…