Package mvpa :: Package clfs :: Package libsmlrc
[hide private]
[frames] | no frames]

Source Code for Package mvpa.clfs.libsmlrc

 1  # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- 
 2  # vi: set ft=python sts=4 ts=4 sw=4 et: 
 3  ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 
 4  # 
 5  #   See COPYING file distributed along with the PyMVPA package for the 
 6  #   copyright and license terms. 
 7  # 
 8  ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 
 9  """Wraper for the stepwise_regression function for SMLR.""" 
10   
11  if __debug__: 
12      from mvpa.base import debug 
13      debug('INIT', 'mvpa.clfs.libsmlrc') 
14   
15  import numpy as N 
16  import ctypes as C 
17  import os 
18  import sys 
19   
20  from mvpa.clfs.libsmlrc.ctypes_helper import extend_args, c_darray 
21   
22  # connect to library that's in this directory 
23  if sys.platform == 'win32': 
24      # on windows things get tricky as we compile this lib as an extension 
25      # so it get a .pyd name suffix instead of .dll 
26      smlrlib = C.cdll[os.path.join(os.path.dirname(__file__), 'smlrc.pyd')] 
27  elif sys.platform == 'darwin': 
28      # look for .so extension on Mac (not .dylib this time) 
29      smlrlib = C.cdll[os.path.join(os.path.dirname(__file__), 'smlrc.so')] 
30  else: 
31      smlrlib = N.ctypeslib.load_library('smlrc', os.path.dirname(__file__)) 
32   
33  # wrap the stepwise function 
34 -def stepwise_regression(*args):
35 func = smlrlib.stepwise_regression 36 func.argtypes = [C.c_int, C.c_int, c_darray, 37 C.c_int, C.c_int, c_darray, 38 C.c_int, C.c_int, c_darray, 39 C.c_int, C.c_int, c_darray, 40 C.c_int, C.c_int, c_darray, 41 C.c_int, c_darray, 42 C.c_int, c_darray, 43 C.c_int, c_darray, 44 C.c_int, 45 C.c_int, 46 C.c_double, 47 C.c_float, 48 C.c_float, 49 C.c_int64] 50 func.restype = C.c_long 51 52 # get the new arglist 53 arglist = extend_args(*args) 54 return func(*arglist)
55 56 if __debug__: 57 debug('INIT', 'mvpa.clfs.libsmlrc end') 58