Пример #1
0
def setup():
    global tf
    tf = import_module('tensorflow')
    dtcwt.push_backend('tf')

    # Make sure we run tests on cpu rather than gpus
    os.environ["CUDA_VISIBLE_DEVICES"] = ""
Пример #2
0
def setup():
    global tf
    tf = import_module('tensorflow')
    dtcwt.push_backend('tf')

    # Make sure we run tests on cpu rather than gpus
    os.environ["CUDA_VISIBLE_DEVICES"] = ""
Пример #3
0
def test_backend_with_guard():
    """Test that manipulating the stack with preserve_backend_stack() will
    return the stack to its pristine state even i pushes and pops are
    imbalanced.

    """
    assert len(dtcwt._BACKEND_STACK) == 1
    with dtcwt.preserve_backend_stack():
        dtcwt.push_backend('numpy')
        assert len(dtcwt._BACKEND_STACK) == 2
    assert len(dtcwt._BACKEND_STACK) == 1
Пример #4
0
 def test_switch_to_numpy(self):
     assert dtcwt.Transform2d is npbackend.Transform2d
     assert dtcwt.Pyramid is npbackend.Pyramid
     assert dtcwt.backend_name == 'numpy'
     dtcwt.push_backend('numpy')
     assert dtcwt.Transform2d is npbackend.Transform2d
     assert dtcwt.Pyramid is npbackend.Pyramid
     assert dtcwt.backend_name == 'numpy'
     dtcwt.pop_backend()
     assert dtcwt.Transform2d is npbackend.Transform2d
     assert dtcwt.Pyramid is npbackend.Pyramid
     assert dtcwt.backend_name == 'numpy'
Пример #5
0
def test_backend_with_guard_and_exception():
    """Tests that even when preserving the backend stack, an exception is
    correctly propagated.

    """
    dtcwt.push_backend('numpy')
    assert len(dtcwt._BACKEND_STACK) == 2
    assert dtcwt.backend_name == 'numpy'
    with raises(RuntimeError):
        with dtcwt.preserve_backend_stack():
            dtcwt.push_backend('opencl')
            assert dtcwt.backend_name == 'opencl'
            assert len(dtcwt._BACKEND_STACK) == 3
            raise RuntimeError('test error')
    assert dtcwt.backend_name == 'numpy'
    assert len(dtcwt._BACKEND_STACK) == 2
Пример #6
0
def setup():
    global mandrill, in_p, pyramid_ops
    global tf, Transform1d, dtwavexfm2, dtwaveifm2, Pyramid_tf
    global np_dtypes, tf_dtypes, stats
    # Import the tensorflow modules
    tf = import_module('tensorflow')
    dtcwt_tf = import_module('dtcwt.tf')
    dtcwt_tf_xfm1 = import_module('dtcwt.tf.transform1d')
    Transform1d = getattr(dtcwt_tf, 'Transform1d')
    Pyramid_tf = getattr(dtcwt_tf, 'Pyramid')
    np_dtypes = getattr(dtcwt_tf_xfm1, 'np_dtypes')
    tf_dtypes = getattr(dtcwt_tf_xfm1, 'tf_dtypes')

    mandrill = datasets.mandrill()
    # Make sure we run tests on cpu rather than gpus
    os.environ["CUDA_VISIBLE_DEVICES"] = ""
    dtcwt.push_backend('tf')
Пример #7
0
def setup():
    global mandrill, in_p, pyramid_ops
    global tf, Transform1d, dtwavexfm2, dtwaveifm2, Pyramid_tf
    global np_dtypes, tf_dtypes, stats
    # Import the tensorflow modules
    tf = import_module('tensorflow')
    dtcwt_tf = import_module('dtcwt.tf')
    dtcwt_tf_xfm1 = import_module('dtcwt.tf.transform1d')
    Transform1d = getattr(dtcwt_tf, 'Transform1d')
    Pyramid_tf = getattr(dtcwt_tf, 'Pyramid')
    np_dtypes = getattr(dtcwt_tf_xfm1, 'np_dtypes')
    tf_dtypes = getattr(dtcwt_tf_xfm1, 'tf_dtypes')

    mandrill = datasets.mandrill()
    # Make sure we run tests on cpu rather than gpus
    os.environ["CUDA_VISIBLE_DEVICES"] = ""
    dtcwt.push_backend('tf')
Пример #8
0
def setup():
    # Import some tf only dependencies
    global mandrill, Transform2d, Pyramid
    global tf, np_dtypes, tf_dtypes, dtwavexfm2, dtwaveifm2
    # Import the tensorflow modules
    tf = import_module('tensorflow')
    dtcwt.push_backend('tf')
    Transform2d = getattr(dtcwt, 'Transform2d')
    Pyramid = getattr(dtcwt, 'Pyramid')
    compat = import_module('dtcwt.compat')
    dtwavexfm2 = getattr(compat, 'dtwavexfm2')
    dtwaveifm2 = getattr(compat, 'dtwaveifm2')
    import dtcwt.tf.transform2d as transform2d
    np_dtypes = getattr(transform2d, 'np_dtypes')
    tf_dtypes = getattr(transform2d, 'tf_dtypes')

    mandrill = datasets.mandrill()
    # Make sure we run tests on cpu rather than gpus
    os.environ["CUDA_VISIBLE_DEVICES"] = ""
Пример #9
0
 def test_switch_to_invalid(self):
     with raises(ValueError):
         dtcwt.push_backend('does-not-exist')
Пример #10
0
 def tst():
     with dtcwt.preserve_backend_stack():
         dtcwt.push_backend('numpy')
         assert len(dtcwt._BACKEND_STACK) == 2
         raise RuntimeError('test error')
Пример #11
0
 def test_switch_to_invalid(self):
     dtcwt.push_backend('does-not-exist')