David Campbell avatar David Campbell committed cf31abf

Conform to PEP8 and alias types aliased in header.

Comments (0)

Files changed (1)

svmlight/svmlight.py

 VERSION = "V6.02"
 VERSION_DATE = "14.08.08"
 
+CFLOAT = c_float
+FNUM   = c_long
+FVAL   = c_float
+
 MAXFEATNUM = 99999999
 
 LINEAR  = 0
 
 
 class WORD(Structure):
-	_fields_ = [("wnum",   c_long),
-		    ("weight", c_float)]
+	_fields_ = [("wnum",   FNUM),
+                ("weight", FVAL)]
+
 
 class SVECTOR(Structure):
 	_fields_ = [("words",       POINTER(WORD)),
-		    ("twonorm_sq",  c_double),
-		    ("userdefined", POINTER(c_char)),
-		    ("kernel_id",   c_long),
-		    ("next",        POINTER(SVECTOR),
-		    ("factor",      c_double)]
-                 
-                 
+                ("twonorm_sq",  c_double),
+                ("userdefined", POINTER(c_char)),
+                ("kernel_id",   c_long),
+                ("next",        POINTER(SVECTOR),
+                ("factor",      c_double)]
+
+
 class DOC(Structure):
     _fields_ = [("docnum",     c_long),
                 ("queryid",    c_long),
                 ("fvec",       POINTER(SVECTOR))]
 
 class LEARN_PARM(Structure):
-    _fields_ = [("type",                c_long),
-                ("svm_c",               c_double),
-                ("eps",                 c_double),
-                ("svm_costratio",       c_double ),
-                ("transduction_posratio", c_double ),
-                
-                ("biased_hyperplane",   c_long),
-                ("sharedslack",         c_long),
-                ("svm_maxqpsize",       c_long),
-                ("svm_newvarsinqp",     c_long),
-                ("kernel_cache_size",   c_long),
-                
-                ("epsilon_crit",        c_double ),
-                ("epsilon_shrink",      c_double ),
-                
-                ("svm_iter_to_shrink",  c_long),
-                ("maxiter",             c_long),
-                ("remove_inconsistent", c_long),
-                ("skip_final_opt_check", c_long),
-                ("compute_loo",         c_long),
-                
-                ("rho",                 c_double ),
-                
-                ("xa_depth",            c_long),
-                
-                ("predfile",            (c_char * 200)() ),
-                ("alphafile",           (c_char * 200)() ),
-                
-                ("epsilon_const",       c_double ),
-                ("epsilon_a",           c_double ),
-                ("opt_precision",       c_double ),
-                
-                ("svm_c_steps",         c_long ),
-                
-                ("svm_c_factor",        c_double ),
-                ("svm_costratio_unlab", c_double ),
-                ("svm_unlabbound",      c_double ),
-                ("svm_cost",            POINTER(c_double) ),
-                
-                ("totwords",            c_long ) ]
+    _fields_ = [("type",                  c_long),
+                ("svm_c",                 c_double),
+                ("eps",                   c_double),
+                ("svm_costratio",         c_double),
+                ("transduction_posratio", c_double),
+                ("biased_hyperplane",     c_long),
+                ("sharedslack",           c_long),
+                ("svm_maxqpsize",         c_long),
+                ("svm_newvarsinqp",       c_long),
+                ("kernel_cache_size",     c_long),
+                ("epsilon_crit",          c_double),
+                ("epsilon_shrink",        c_double),
+                ("svm_iter_to_shrink",    c_long),
+                ("maxiter",               c_long),
+                ("remove_inconsistent",   c_long),
+                ("skip_final_opt_check",  c_long),
+                ("compute_loo",           c_long),
+                ("rho",                   c_double),
+                ("xa_depth",              c_long),
+                ("predfile",              (c_char * 200)()),
+                ("alphafile",             (c_char * 200)()),
+                ("epsilon_const",         c_double),
+                ("epsilon_a",             c_double),
+                ("opt_precision",         c_double),
+                ("svm_c_steps",           c_long),
+                ("svm_c_factor",          c_double),
+                ("svm_costratio_unlab",   c_double),
+                ("svm_unlabbound",        c_double),
+                ("svm_cost",              POINTER(c_double)),
+                ("totwords",              c_long)]
 
 class KERNEL_PARM(Structure):
     _fields_ = [("kernel_type",     c_long),
                 ("poly_degree",     c_long),
                 ("rbf_gamma",       c_double),
                 ("coef_lin",        c_double),
-                ("coef_const",      c_double ),
-                ("custom",          (c_char * 50)() ) ]
+                ("coef_const",      c_double),
+                ("custom",          (c_char * 50)())]
 
 class MODEL(Structure):
     _fields_ = [("sv_num",          c_long),
                 ("at_upper_bound",  c_long),
                 ("b",               c_double),
-                ("supvec",          POINTER( POINTER( DOC ) ) ),
-                ("alpha",           POINTER( c_double ) ),
-                ("index",           POINTER( c_long ) ),
+                ("supvec",          POINTER(POINTER(DOC))),
+                ("alpha",           POINTER(c_double)),
+                ("index",           POINTER(c_long)),
                 ("totwords",        c_long),
                 ("totdoc",          c_long),
                 ("kernel_parm",     KERNEL_PARM),
                 ("xa_error",        c_double),
                 ("xa_recall",       c_double),
                 ("xa_precision",    c_double),
-                ("lin_weights",     POINTER( c_double) ),
-                ("maxdiff",         c_double)   ]
+                ("lin_weights",     POINTER(c_double)),
+                ("maxdiff",         c_double)]
 
 class QP(Structure):
 	_fields_ = [("opt_n",     c_long),
 
 class KERNEL_CACHE(Structure):
   _fields_ = [("index",         POINTER(c_long)),
-              ("buffer",        POINTER(c_float)),
+              ("buffer",        POINTER(CFLOAT)),
               ("invindex",      POINTER(c_long)),
               ("active2totdoc", POINTER(c_long)),
               ("totdoc2active", POINTER(c_long)),
                 ("time_update",     c_long),
                 ("time_model",      c_long),
                 ("time_check",      c_long),
-                ("time_select",     c_long) ]
+                ("time_select",     c_long)]
 
 class SHRINK_STATE(Structure):
-    _fields_ = [("active",          POINTER( c_long ) ),
-                ("inactive_since",  POINTER( c_long ) ),
+    _fields_ = [("active",          POINTER(c_long)),
+                ("inactive_since",  POINTER(c_long)),
                 ("deactnum",        c_long),
-                ("a_history",       POINTER( POINTER( c_double ) ) ),
+                ("a_history",       POINTER(POINTER(c_double))),
                 ("maxhistory",      c_long),
-                ("last_a",          POINTER( c_double ) ),
-                ("last_lin",        POINTER( c_double ) ) ]
+                ("last_a",          POINTER(c_double)),
+                ("last_lin",        POINTER(c_double))]
 
 
 if __name__ == "__main__":
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.