class documentation

class SameFunction:

View In Hierarchy

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 __call__ return number of directly preceding calls with similar id
Method __init__ Undocumented
Instance Variable count Undocumented
Instance Variable last Undocumented
@staticmethod
def filter(id):

remove instance information and return a tuple

def __call__(self, id):

return number of directly preceding calls with similar id

def __init__(self):

Undocumented

count: int =

Undocumented

last =

Undocumented