Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, *args, **kwargs):
self.compile_kwargs = copy.deepcopy(_compile_kwargs)
self.compile_kwargs['define'] = ['PYCVODES_NO_KLU={}'.format("0" if config.get('KLU', True) else "1"),
'PYCVODES_NO_LAPACK={}'.format("0" if config.get('LAPACK', True) else "1"),
'ANYODE_NO_LAPACK={}'.format("0" if config.get('LAPACK', True) else "1")]
self.compile_kwargs['include_dirs'].append(get_include())
self.compile_kwargs['libraries'].extend(_libs.get_libs().split(','))
self.compile_kwargs['libraries'].extend([l for l in os.environ.get(
'PYODESYS_LAPACK', "lapack,blas" if config["LAPACK"] else "").split(",") if l != ""])
self.compile_kwargs['flags'] = [f for f in os.environ.get("PYODESYS_CVODE_FLAGS", "").split() if f]
self.compile_kwargs['ldflags'] = [f for f in os.environ.get("PYODESYS_CVODE_LDFLAGS", "").split() if f]
super(NativeCvodeCode, self).__init__(*args, **kwargs)
class NativeCvodeSys(_NativeSysBase):
_NativeCode = NativeCvodeCode
_native_name = 'cvode'
def as_standalone(self, out_file=None, compile_kwargs=None):
from pycompilation.compilation import src2obj, link
from pycodeexport.util import render_mako_template_to
compile_kwargs = compile_kwargs or {}
impl_src = open([f for f in self._native._written_files if f.endswith('.cpp')][0], 'rt').read()
f = render_mako_template_to(
os.path.join(os.path.dirname(__file__), 'sources/standalone_template.cpp'),
'%s.cpp' % out_file, {'p_odesys': self, 'p_odesys_impl': impl_src})
kw = copy.deepcopy(self._native.compile_kwargs)
kw.update(compile_kwargs)
objf = src2obj(f, **kw)
kw['libraries'].append('boost_program_options')
return link([objf], out_file, **kw)
_config, get_include = import_('pygslodeiv2', '_config', 'get_include')
class NativeGSLCode(_NativeCodeBase):
""" Looks for the environment variable: ``PYODESYS_BLAS`` (``gslcblas``) """
wrapper_name = '_gsl_wrapper'
def __init__(self, *args, **kwargs):
self.compile_kwargs = copy.deepcopy(_compile_kwargs)
self.compile_kwargs['include_dirs'].append(get_include())
self.compile_kwargs['libraries'].extend(_config.env['GSL_LIBS'].split(','))
self.compile_kwargs['libraries'].extend(os.environ.get('PYODESYS_BLAS', _config.env['BLAS']).split(','))
super(NativeGSLCode, self).__init__(*args, **kwargs)
class NativeGSLSys(_NativeSysBase):
_NativeCode = NativeGSLCode
_native_name = 'gsl'
def integrate(self, *args, **kwargs):
integrator = kwargs.pop('integrator', 'native')
if integrator not in ('native', self._native_name):
raise ValueError("Got incompatible kwargs integrator=%s" % integrator)
else:
kwargs['integrator'] = 'native'
return super(_NativeSysBase, self).integrate(*args, **kwargs)
from ._base import _NativeCodeBase, _NativeSysBase, _compile_kwargs
pyodeint = import_('pyodeint')
class NativeOdeintCode(_NativeCodeBase):
wrapper_name = '_odeint_wrapper'
def __init__(self, *args, **kwargs):
self.compile_kwargs = copy.deepcopy(_compile_kwargs)
self.compile_kwargs['include_dirs'].append(pyodeint.get_include())
self.compile_kwargs['libraries'].extend(['m'])
super(NativeOdeintCode, self).__init__(*args, **kwargs)
class NativeOdeintSys(_NativeSysBase):
_NativeCode = NativeOdeintCode
_native_name = 'odeint'