Skip to content

Commit

Permalink
Merge pull request #9 from mklauser/issue_123two
Browse files Browse the repository at this point in the history
Issue 123two
  • Loading branch information
ssim committed Apr 15, 2014
2 parents 1cbaf81 + cbe0a05 commit 7263413
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
19 changes: 1 addition & 18 deletions tardis/montecarlo.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ cdef extern from "math.h":



cdef extern from "randomkit/randomkit.h":
cdef extern from "randomkit.h":
ctypedef struct rk_state:
unsigned long key[624]
int pos
Expand All @@ -43,23 +43,6 @@ cdef extern from "randomkit/randomkit.h":
float_type_t rk_double(rk_state *state)
cdef rk_state mt_state

########### Test wrapper section #################
# This should be moved to an external file
def binary_search_wrapper(np.ndarray x, float_type_t x_insert, int_type_t imin, int_type_t imax):
cdef float_type_t* x_pointer
x_pointer = <float_type_t*> x.data
return binary_search(x_pointer, x_insert, imin, imax)

def line_search_wrapper(np.ndarray nu, float_type_t nu_insert,
int_type_t number_of_lines):
cdef float_type_t* nu_pointer
nu_pointer = <float_type_t*> nu.data
return line_search(nu_pointer, nu_insert, number_of_lines)


##################################################




cdef np.ndarray x
Expand Down
4 changes: 2 additions & 2 deletions tardis/setup_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

def get_extensions():
return [Extension('tardis.montecarlo',
['tardis/montecarlo.pyx'] + randomkit_files)]
['tardis/montecarlo.pyx'] + randomkit_files, include_dirs=['tardis/randomkit']), Extension('tardis.tests.montecarlo_test_wrappers', ['tardis/tests/montecarlo_test_wrappers.pyx'] + randomkit_files, include_dirs=['tardis/randomkit'])]
#return {'tardis.montecarlo_multizone':['randomkit/*.c']}

def get_package_data():
return {
'tardis.tests': ['coveragerc']}
'tardis.tests': ['coveragerc']}
13 changes: 13 additions & 0 deletions tardis/tests/montecarlo_test_wrappers.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
include "../montecarlo.pyx"


def binary_search_wrapper(np.ndarray x, float_type_t x_insert, int_type_t imin, int_type_t imax):
cdef float_type_t* x_pointer
x_pointer = <float_type_t*> x.data
return binary_search(x_pointer, x_insert, imin, imax)

def line_search_wrapper(np.ndarray nu, float_type_t nu_insert,
int_type_t number_of_lines):
cdef float_type_t* nu_pointer
nu_pointer = <float_type_t*> nu.data
return line_search(nu_pointer, nu_insert, number_of_lines)
3 changes: 2 additions & 1 deletion tardis/tests/test_montecarlo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
from tardis import montecarlo
#from tardis import montecarlo
from tardis.tests import montecarlo_test_wrappers as montecarlo
import pytest


Expand Down

0 comments on commit 7263413

Please sign in to comment.