Commit d31160f4 authored by Stefan Behnel's avatar Stefan Behnel

Fix test output of Pythran test and give a better name to a test function.

parent bb27a47f
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
import numpy as np import numpy as np
cimport numpy as cnp cimport numpy as cnp
def test(): def diffuse():
""" """
>>> u = test() >>> u = diffuse()
>>> count_non_zero = np.sum(u > 0) >>> count_non_zero = np.sum(u > 0)
>>> 15000 < count_non_zero < (2**7) * (2**7) or count_non_zero >>> 15000 < count_non_zero < (2**7) * (2**7) or count_non_zero
True True
...@@ -15,11 +15,11 @@ def test(): ...@@ -15,11 +15,11 @@ def test():
lx, ly = (2**7, 2**7) lx, ly = (2**7, 2**7)
u = np.zeros([lx, ly], dtype=np.double) u = np.zeros([lx, ly], dtype=np.double)
u[lx // 2, ly // 2] = 1000.0 u[lx // 2, ly // 2] = 1000.0
diffuse_numpy(u, 500) _diffuse_numpy(u, 500)
return u return u
def diffuse_numpy(cnp.ndarray[double, ndim=2] u, int N): def _diffuse_numpy(cnp.ndarray[double, ndim=2] u, int N):
""" """
Apply Numpy matrix for the Forward-Euler Approximation Apply Numpy matrix for the Forward-Euler Approximation
""" """
...@@ -41,6 +41,7 @@ def calculate_tax(cnp.ndarray[double, ndim=1] d): ...@@ -41,6 +41,7 @@ def calculate_tax(cnp.ndarray[double, ndim=1] d):
>>> d = np.random.lognormal(mu, sigma, 10000) >>> d = np.random.lognormal(mu, sigma, 10000)
>>> avg = calculate_tax(d) >>> avg = calculate_tax(d)
>>> 0.243 < avg < 0.244 or avg # 0.24342652180085891 >>> 0.243 < avg < 0.244 or avg # 0.24342652180085891
True
""" """
tax_seg1 = d[(d > 256303)] * 0.45 - 16164.53 tax_seg1 = d[(d > 256303)] * 0.45 - 16164.53
tax_seg2 = d[(d > 54057) & (d <= 256303)] * 0.42 - 8475.44 tax_seg2 = d[(d > 54057) & (d <= 256303)] * 0.42 - 8475.44
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment