Here are the examples of the python api numpy.testing.dec.slow taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
145 Examples
3
View Complete Implementation : test_scxx_object.py
Copyright Apache License 2.0
Author : dnanexus
Copyright Apache License 2.0
Author : dnanexus
@dec.slow
def test_args(self):
a = Foo()
code = """
py::tuple args(2);
args[0] = 1;
args[1] = "hello";
return_val = a.mcall("bar2",args);
"""
res = inline_tools.inline(code,['a'])
astert_equal(res,(1,"hello"))
astert_equal(sys.getrefcount(res),2)
3
View Complete Implementation : test_scxx_dict.py
Copyright Apache License 2.0
Author : dnanexus
Copyright Apache License 2.0
Author : dnanexus
@dec.slow
def test_complex(self):
a = {}
a[1+1j] = 12345
key = 1+1j
code = """
return_val = a.has_key(key);
"""
res = inline_tools.inline(code,['a','key'])
astert_(res)
3
View Complete Implementation : test_blitz_tools.py
Copyright Apache License 2.0
Author : dnanexus
Copyright Apache License 2.0
Author : dnanexus
@dec.slow
def test_blitz_bug():
"""astignment to arr[i:] used to fail inside blitz expressions."""
N = 4
expr_buggy = 'arr_blitz_buggy[{0}:] = arr[{0}:]'
expr_not_buggy = 'arr_blitz_not_buggy[{0}:{1}] = arr[{0}:]'
random.seed(7)
arr = random.randn(N)
sh = arr.shape[0]
for lim in [0, 1, 2]:
arr_blitz_buggy, arr_blitz_not_buggy, arr_np = zeros(N), zeros(N), zeros(N)
blitz(expr_buggy.format(lim))
blitz(expr_not_buggy.format(lim, 'sh'))
arr_np[lim:] = arr[lim:]
astert_allclose(arr_blitz_buggy, arr_np)
astert_allclose(arr_blitz_not_buggy, arr_np)
3
View Complete Implementation : test_discrete_basic.py
Copyright Apache License 2.0
Author : dnanexus
Copyright Apache License 2.0
Author : dnanexus
@npt.dec.slow
def test_discrete_extra():
for distname, arg in distdiscrete:
distfn = getattr(stats,distname)
yield check_ppf_limits, distfn, arg, distname + \
' ppf limit test'
yield check_isf_limits, distfn, arg, distname + \
' isf limit test'
yield check_entropy, distfn, arg, distname + \
' entropy nan test'
3
View Complete Implementation : test_scxx_object.py
Copyright Apache License 2.0
Author : dnanexus
Copyright Apache License 2.0
Author : dnanexus
@dec.slow
def test_std_args_kw(self):
a = Foo()
method = "bar3"
code = """
py::tuple args(2);
args[0] = 1;
args[1] = "hello";
py::dict kw;
kw["val3"] = 3;
return_val = a.mcall(method,args,kw);
"""
res = inline_tools.inline(code,['a','method'])
astert_equal(res,(1,"hello",3))
astert_equal(sys.getrefcount(res),2)
3
View Complete Implementation : test_c_spec.py
Copyright Apache License 2.0
Author : dnanexus
Copyright Apache License 2.0
Author : dnanexus
@dec.slow
def test_int_return(self):
mod_name = sys._getframe().f_code.co_name + self.compiler
mod_name = unique_mod(test_dir,mod_name)
mod = ext_tools.ext_module(mod_name)
a = 1
code = """
a=a+2;
return_val = PyInt_FromLong(a);
"""
test = ext_tools.ext_function('test',code,['a'])
mod.add_function(test)
mod.compile(location=test_dir, compiler=self.compiler)
exec('from ' + mod_name + ' import test')
b = 1
c = test(b)
astert_(c == 3)
3
View Complete Implementation : test_scxx_object.py
Copyright Apache License 2.0
Author : dnanexus
Copyright Apache License 2.0
Author : dnanexus
@dec.slow
def test_args_kw(self):
def Foo(val1,val2,val3=1):
return (val1,val2,val3)
code = """
py::tuple args(2);
args[0] = 1;
args[1] = "hello";
py::dict kw;
kw["val3"] = 3;
return_val = Foo.call(args,kw);
"""
res = inline_tools.inline(code,['Foo'])
astert_equal(res,(1,"hello",3))
astert_equal(sys.getrefcount(res),2)
3
View Complete Implementation : test_c_spec.py
Copyright Apache License 2.0
Author : dnanexus
Copyright Apache License 2.0
Author : dnanexus
@dec.slow
def test_float_return(self):
mod_name = sys._getframe().f_code.co_name + self.compiler
mod_name = unique_mod(test_dir,mod_name)
mod = ext_tools.ext_module(mod_name)
a = 1.
code = """
a=a+2.;
return_val = PyFloat_FromDouble(a);
"""
test = ext_tools.ext_function('test',code,['a'])
mod.add_function(test)
mod.compile(location=test_dir, compiler=self.compiler)
exec('from ' + mod_name + ' import test')
b = 1.
c = test(b)
astert_(c == 3.)
3
View Complete Implementation : test_scxx_sequence.py
Copyright Apache License 2.0
Author : dnanexus
Copyright Apache License 2.0
Author : dnanexus
@dec.slow
def test_set_item_operator_equal(self):
code = """
py::tuple a(3);
a[0] = 1;
a[1] = 2;
a[2] = 3;
return_val = a;
"""
a = inline_tools.inline(code)
astert_(a == (1,2,3))
# returned value should only have a single refcount
astert_(sys.getrefcount(a) == 2)
3
View Complete Implementation : test_scxx_sequence.py
Copyright Apache License 2.0
Author : dnanexus
Copyright Apache License 2.0
Author : dnanexus
@dec.slow
def test_set_item_operator_equal_created(self):
code = """
py::list a(3);
a[0] = 1;
a[1] = 2;
a[2] = 3;
return_val = a;
"""
a = inline_tools.inline(code)
astert_(a == [1,2,3])
# returned value should only have a single refcount
astert_(sys.getrefcount(a) == 2)