Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@cython.inline
def cdef_inline(x) -> cython.double:
return x + 1
@cython.inline
@cython.returns(cython.double)
def cdef_inline(x):
return x + 1
include_package_data=True,
scripts=['scripts/pyou', ],
install_requires=requirements,
include_dirs=[],
extras_require={'full': full_requirements}
)
if build_cmd != 'clean' and not PYPY: # skip cython in pypy
try:
from Cython.Build import cythonize
from Cython.Distutils import build_ext
import cython
# detect if cython works
if sys.platform == 'win32':
cython.inline('return a + b', a=1, b=1)
extension_kw = dict(language='c++', include_dirs=[])
if 'MSC' in sys.version:
extension_kw['extra_compile_args'] = ['/Ot', '/I' + os.path.join(repo_root, 'misc')]
else:
extension_kw['extra_compile_args'] = ['-O3']
extensions = [
Extension('odps.src.types_c', ['odps/src/types_c.pyx'], **extension_kw),
Extension('odps.src.crc32c_c', ['odps/src/crc32c_c.pyx'], **extension_kw),
Extension('odps.tunnel.pb.encoder_c', ['odps/tunnel/pb/encoder_c.pyx'], **extension_kw),
Extension('odps.tunnel.pb.decoder_c', ['odps/tunnel/pb/decoder_c.pyx'], **extension_kw),
Extension('odps.tunnel.pb.util_c', ['odps/tunnel/pb/util_c.pyx'], **extension_kw),
Extension('odps.tunnel.io.writer_c', ['odps/tunnel/io/writer_c.pyx'], **extension_kw),
Extension('odps.tunnel.io.reader_c', ['odps/tunnel/io/reader_c.pyx'], **extension_kw),
Extension('odps.tunnel.checksum_c', ['odps/tunnel/checksum_c.pyx'], **extension_kw),
lomb_code_A = """
for (unsigned long j=0;j
cn -= coef[i+1]*f
wth[i+1,:] = f
vcn += (f/wth0)**2
chi0 = dot(cn,cn)
varcn = chi0/(numt-1-dord)
psdmin *= 2*varcn
Tr = array(0.,dtype='float64')
ifreq = array(0,dtype='int32')
lambda0 = array(lambda0/s0,dtype='float64')
lambda0_range = 10**array(lambda0_range,dtype='float64')/s0
vars=['numt','numf','nharm','detrend_order','psd','cn','wth','sinx','cosx','sinx_step','cosx_step','sinx_back','cosx_back','sinx_smallstep','cosx_smallstep','hat_matr','hat_hat','hat0','soln','chi0','freq_zoom','psdmin','tone_control','lambda0','lambda0_range','Tr','ifreq']
cython.inline(lomb_code, vars, support_code = eigs_code + lomb_scargle_support,force=0)
hat_hat /= s0
ii = arange(nharm,dtype='int32')
soln[0:nharm] /= (1.+ii)**2; soln[nharm:] /= (1.+ii)**2
if (detrend_order>=0):
hat_matr0 = outer(hat0[:,0],wth0)
for i in range(detrend_order):
hat_matr0 += outer(hat0[:,i+1],wth[i+1,:])
modl = dot(hat_matr.T,soln); modl0 = dot(hat_matr0.T,soln)
coef0 = dot(soln,hat0)
coef -= coef0
if (detrend_order>=0):
hat_matr -= hat_matr0
def timefunc_cython_inline():
cython.inline(code, locals=ns)
}
"""
lomb_code_B = """
for (unsigned long j=0;j
from brian2 import *
from brian2.memory.dynamicarray import *
from cython import inline
from brian2.codegen.runtime.cython_rt.modified_inline import modified_cython_inline as inline
x = DynamicArray1D(10)
code = '''
print 'hi'
for i in xrange(len(x)):
print x[i]
'''
ns = {'x': x}
a, b = inline(code, locals=ns, globals={})
print dir(a)
print b
a.__invoke(*b)
return x + two
"""
if not _can_cython_inline():
return obj
elif has_async_gen_fun and inspect.isasyncgenfunction(obj):
raise TypeError("Async generator funcions are not supported.")
source = _get_source_code(obj)
frame = inspect.currentframe().f_back
if inspect.isclass(obj):
locals_ = frame.f_locals
else:
locals_ = _get_outer_variables(obj)
with warnings.catch_warnings():
warnings.simplefilter("ignore")
compiled = cython.inline(source, locals=locals_,
globals=frame.f_globals, quiet=True)
return compiled[obj.__name__]