def test():
    """test of the `purecma` module, called ``if __name__ == "__main__"``.

    Currently only based on `doctest`:

    >>> try: import cma.purecma as pcma
    ... except ImportError: import purecma as pcma
    >>> import random
    >>> random.seed(3)
    >>> xmin, es = pcma.fmin(pcma.ff.rosenbrock, 4 * [0.5], 0.5,
    ...                      verb_disp=0, verb_log=1)
    >>> print(es.counteval)
    1680
    >>> print(es.best.evals)
    1664
    >>> assert es.best.f < 1e-12
    >>> random.seed(5)
    >>> es = pcma.CMAES(4 * [0.5], 0.5)
    >>> es.params = pcma.CMAESParameters(es.params.dimension,
    ...                                  es.params.lam,
    ...                                  pcma.RecombinationWeights)
    >>> while not es.stop():
    ...     X = es.ask()
    ...     es.tell(X, [pcma.ff.rosenbrock(x) for x in X])
    >>> print("%s, %s" % (pcma.ff.rosenbrock(es.result[0]) < 1e-13,
    ...                   es.result[2] < 1600))
    True, True

    Large population size:

    >>> random.seed(4)
    >>> es = pcma.CMAES(3 * [1], 1)
    >>> es.params = pcma.CMAESParameters(es.params.dimension, 300,
    ...                                  pcma.RecombinationWeights)
    >>> es.logger = pcma.CMAESDataLogger()
    >>> try:
    ...    es = es.optimize(pcma.ff.elli, verb_disp=0)
    ... except AttributeError:  # OOOptimizer.optimize is not available
    ...     while not es.stop():
    ...         X = es.ask()
    ...         es.tell(X, [pcma.ff.elli(x) for x in X])
    >>> assert es.result[1] < 1e13
    >>> print(es.result[2])
    9300

    """
    import doctest
    print('launching doctest...')
    print(doctest.testmod(report=True, verbose=0))
