Exemplo n.º 1
0
 def func(env):
     global counter
     with env:
         nthreads = os.getenv('OMP_NUM_THREADS')
         expected = omp_num_threads()
         with pool_threading() as pool:
             assert_equal(int(os.environ['OMP_NUM_THREADS']), 1)
             if mkl is not None:
                 assert_equal(mkl.get_max_threads(), 1)
             counter = 0
             pool.map(func_thread, range(pool._processes))
         assert_equal(os.getenv('OMP_NUM_THREADS'), nthreads)
         if mkl is not None:
             assert_equal(mkl.get_max_threads(), mkl_nthreads)
         assert_equal(counter, expected)
     assert_not_in('OMP_NUM_THREADS', os.environ)
Exemplo n.º 2
0
 def func(env):
     global counter
     with env:
         nthreads = os.getenv("OMP_NUM_THREADS")
         expected = omp_num_threads()
         with pool_threading() as pool:
             assert_equal(int(os.environ["OMP_NUM_THREADS"]), 1)
             if mkl is not None:
                 assert_equal(mkl.get_max_threads(), 1)
             counter = 0
             pool.map(func_thread, range(pool._processes))
         assert_equal(os.getenv("OMP_NUM_THREADS"), nthreads)
         if mkl is not None:
             assert_equal(mkl.get_max_threads(), mkl_nthreads)
         assert_equal(counter, expected)
     assert_not_in("OMP_NUM_THREADS", os.environ)
Exemplo n.º 3
0
def test_homothety_operator():
    s = HomothetyOperator(1)
    assert s.C is s.T is s.H is s.I is s

    s = HomothetyOperator(-1)
    assert s.C is s.T is s.H is s.I is s

    s = HomothetyOperator(2.)
    assert s.C is s.T is s.H is s
    assert_is_not(s.I, s)

    def func(o):
        assert_is_instance(o, HomothetyOperator)
    for o in (s.I, s.I.C, s.I.T, s.I.H, s.I.I):
        yield func, o

    s = HomothetyOperator(complex(1, 1))
    assert_is(s.T, s)
    assert_is(s.H, s.C)
    assert_not_in(s.I, (s, s.C))
    assert_not_in(s.I.C, (s, s.C))
    assert_is_instance(s.C, HomothetyOperator)
    for o in (s.I, s.I.C, s.I.T, s.I.H, s.I.I):
        yield func, o