Count the number of consecutive instances of the same function.

Useful to limit the number of repetitions on the same function.

Example:

>>> import cocoex
>>> from cocoex.utilities import SameFunction
>>>
>>> suite = cocoex.Suite('bbob', '', '')
>>> already_seen = SameFunction()
>>> processed = 0
>>> for problem in suite:
...     if already_seen(problem.id) > 5:
...         continue
...     # do something here only with the first five instances
...     processed += 1
>>> processed, len(suite), already_seen.count
(864, 2160, 15)

More arbitrary tests:

>>> for i in range(4):
...     if seen('f001_i%d' % i) > 2:
...         continue
...     # do something here only the first two instances
>>> seen.count
4
>>> seen('f_d03_i001')
0
>>> seen('f_d03_i02')
1
>>> for i in range(4):
...     if seen('f%d_i%d' % (i, i)):
...         break
>>> i, seen.count
(3, 1)
Static Method filter remove instance information and return a tuple
Method __init__ Undocumented
Method __call__ return number of directly preceding calls with similar id
@staticmethod
def filter(id):
remove instance information and return a tuple
def __init__(self):
Undocumented
def __call__(self, id):
return number of directly preceding calls with similar id
API Documentation for cocoex, generated by pydoctor at 2020-01-21 17:05:05.