Exemplo n.º 1
0
    def _test_inline(cls):
        """
        Detect whether weave.inline is functional.

        Produces compile warnings, which we suppress by capturing STDERR.
        """
        if not hasattr(cls, '_use_inline'):
            cls._use_inline = False
            if weave_inline is not None:
                logger = get_logger(__name__)
                extra_compile_args = []
                # See comment in __init__ for why this must be EXTENDED_DEBUG.
                if not logger.isEnabledFor(EXTENDED_DEBUG):
                    if os.name == 'posix':
                        extra_compile_args.append('2>/dev/null')
                    elif os.name == 'nt':
                        extra_compile_args.append('2>NUL')
                try:
                    with _patch_distutils_logging(logger):
                        weave_inline('int i=0; i=i;', force=1,
                                     extra_compile_args=extra_compile_args)
                    cls._use_inline = True
                except (weave.build_tools.CompileError,
                        distutils.errors.CompileError, ImportError):
                    pass
Exemplo n.º 2
0
    def _test_inline(cls):
        """
        Detect whether weave.inline is functional.

        Produces compile warnings, which we suppress by capturing STDERR.
        """
        if not hasattr(cls, '_use_inline'):
            cls._use_inline = False
            if weave_inline is not None:
                logger = get_logger(__name__)
                extra_compile_args = []
                # See comment in __init__ for why this must be EXTENDED_DEBUG.
                if not logger.isEnabledFor(EXTENDED_DEBUG):
                    if os.name == 'posix':
                        extra_compile_args.append('2>/dev/null')
                    elif os.name == 'nt':
                        extra_compile_args.append('2>NUL')
                try:
                    with _patch_distutils_logging(logger):
                        weave_inline('int i=0; i=i;', force=1,
                                     extra_compile_args=extra_compile_args)
                    cls._use_inline = True
                except (weave.build_tools.CompileError,
                        distutils.errors.CompileError, ImportError):
                    pass
                except ValueError as e:
                    if len(e.args) == 1 and \
                                        e.args[0] == "Symbol table not found":
                        get_logger(__name__).debug(
                            "'ValueError: Symbol table not found' "
                            "encountered; weave compiler is not functional")
                    else:
                        raise
Exemplo n.º 3
0
 def rhs(t, y, p):
     # note that the evaluated code sets ydot as a side effect
     weave_inline(
         code_eqs,
         ['ydot' if ydot is not None else 'jac', 't', 'y', 'p'],
         extra_compile_args=compiler_directives)
     return ydot if ydot is not None else jac
Exemplo n.º 4
0
    def _test_inline(cls):
        """
        Detect whether weave.inline is functional.

        Produces compile warnings, which we suppress by capturing STDERR.
        """
        if not hasattr(cls, '_use_inline'):
            cls._use_inline = False
            if weave_inline is not None:
                logger = get_logger(__name__)
                extra_compile_args = []
                # See comment in __init__ for why this must be EXTENDED_DEBUG.
                if not logger.isEnabledFor(EXTENDED_DEBUG):
                    if os.name == 'posix':
                        extra_compile_args.append('2>/dev/null')
                    elif os.name == 'nt':
                        extra_compile_args.append('2>NUL')
                try:
                    with _patch_distutils_logging(logger):
                        weave_inline('int i=0; i=i;', force=1,
                                     extra_compile_args=extra_compile_args)
                    cls._use_inline = True
                except (weave.build_tools.CompileError,
                        distutils.errors.CompileError,
                        ImportError,
                        ValueError) as e:
                    if not cls._check_compiler_error(e, 'weave'):
                        raise
Exemplo n.º 5
0
    def _test_inline(cls):
        """
        Detect whether weave.inline is functional.

        Produces compile warnings, which we suppress by capturing STDERR.
        """
        if not hasattr(cls, '_use_inline'):
            cls._use_inline = False
            try:
                if weave_inline is not None:
                    extra_compile_args = None
                    if os.name == 'posix':
                        extra_compile_args = ['2>/dev/null']
                    elif os.name == 'nt':
                        extra_compile_args = ['2>NUL']
                    weave_inline('int i=0; i=i;',
                                 force=1,
                                 extra_compile_args=extra_compile_args)
                    cls._use_inline = True
            except (weave.build_tools.CompileError,
                    distutils.errors.CompileError, ImportError):
                pass
Exemplo n.º 6
0
 def jacobian(t, y, p):
     jac = self.jac
     weave_inline(jac_eqs, ['jac', 't', 'y', 'p'],
                  extra_compile_args=['-w'])
     return jac
Exemplo n.º 7
0
 def rhs(t, y, p):
     ydot = self.ydot
     # note that the evaluated code sets ydot as a side effect
     weave_inline(code_eqs, ['ydot', 't', 'y', 'p'],
                  extra_compile_args=['-w'])
     return ydot
Exemplo n.º 8
0
 def jacobian(t, y, p):
     weave_inline(jac_eqs, ['jac', 't', 'y', 'p'],
                  extra_compile_args=extra_compile_args)
     return jac
Exemplo n.º 9
0
 def jacobian(t, y, p):
     weave_inline(jac_eqs, ['jac', 't', 'y', 'p'],
                  extra_compile_args=extra_compile_args)
     return jac
Exemplo n.º 10
0
 def rhs(t, y, p):
     # note that the evaluated code sets ydot as a side effect
     weave_inline(code_eqs, ['ydot', 't', 'y', 'p'],
                  extra_compile_args=extra_compile_args)
     return ydot
Exemplo n.º 11
0
 def rhs(t, y, p):
     # note that the evaluated code sets ydot as a side effect
     weave_inline(code_eqs, ['ydot' if ydot is not None else 'jac',
                             't', 'y', 'p'],
                  extra_compile_args=compiler_directives)
     return ydot if ydot is not None else jac