# Path: pactools/utils/parallel.py
# class _FakeParallel(object):
#     """Useless decorator that is used like Parallel"""
#     def __init__(self, n_jobs=1, *args, **kwargs):
#         if n_jobs != 1:
#             warnings.warn(
#                 "You have set n_jobs=%s to use parallel processing, "
#                 "but it has currently no effect. Please install joblib or "
#                 "scikit-learn to use it."
#                 % (n_jobs, ))
# 
#     def __call__(self, iterable):
# 
#         return list(iterable)
# 
# def _fake_delayed(func):
#     return func
# 
# Path: pactools/utils/testing.py
# def assert_array_not_almost_equal(*args, **kwargs):
#     def func():


import numpy as np
from pactools.utils.parallel import _FakeParallel, _fake_delayed
from pactools.utils.testing import assert_array_equal, assert_equal



def twice(a):
    return 2 * a


def test_fake_parallel():
    # Test that _FakeParallel does nothing but unrolling the generator
    generator = (twice(b) for b in range(10))
    results = _FakeParallel(n_jobs=1)(generator)
    reference = [twice(b) for b in range(10)]

# Path: pactools/utils/parallel.py
# class _FakeParallel(object):
#     """Useless decorator that is used like Parallel"""
#     def __init__(self, n_jobs=1, *args, **kwargs):
#         if n_jobs != 1:
#             warnings.warn(
#                 "You have set n_jobs=%s to use parallel processing, "
#                 "but it has currently no effect. Please install joblib or "
#                 "scikit-learn to use it."
#                 % (n_jobs, ))
# 
#     def __call__(self, iterable):
# 
#         return list(iterable)
# 
# def _fake_delayed(func):
#     return func
# 
# Path: pactools/utils/testing.py
# def assert_array_not_almost_equal(*args, **kwargs):
#     def func():


# Path: pactools/utils/tests/test_parallel.py
import numpy as np
from pactools.utils.parallel import _FakeParallel, _fake_delayed
from pactools.utils.testing import assert_array_equal, assert_equal




def twice(a):
    return 2 * a


def test_fake_parallel():
    # Test that _FakeParallel does nothing but unrolling the generator
    generator = (twice(b) for b in range(10))
    results = _FakeParallel(n_jobs=1)(generator)
    reference = [twice(b) for b in range(10)]

    assert_array_equal(np.array(results), np.array(reference))