Permalink
Browse files

PY3: used six.u to fix unicode variables in svmlight

  • Loading branch information...
raulgarreta authored and larsmans committed Mar 18, 2013
1 parent 3379504 commit 71d1a7c135886a0531f633943d4967f547fea44a
Showing with 10 additions and 6 deletions.
  1. +3 −0 .gitignore
  2. +7 −6 sklearn/datasets/svmlight_format.py
View
@@ -40,3 +40,6 @@ nips2010_pdf/
examples/cluster/joblib
benchmarks/bench_covertype_data/
+
+*.prefs
+.pydevproject
@@ -28,6 +28,7 @@
from .. import __version__
from ..externals import six
from ..utils import atleast2d_or_csr
+from ..externals.six import u
def load_svmlight_file(f, n_features=None, dtype=np.float64,
@@ -229,18 +230,18 @@ def load_svmlight_files(files, n_features=None, dtype=np.float64,
def _dump_svmlight(X, y, f, one_based, comment, query_id):
is_sp = int(hasattr(X, "tocsr"))
if X.dtype == np.float64:
- value_pattern = u"%d:%0.16e"
+ value_pattern = u("%d:%0.16e")
else:
- value_pattern = u"%d:%f"
+ value_pattern = u("%d:%f")
if y.dtype.kind == 'i':
- line_pattern = u"%d"
+ line_pattern = u("%d")
else:
- line_pattern = u"%f"
+ line_pattern = u("%f")
if query_id is not None:
- line_pattern += u" qid:%d"
- line_pattern += u" %s\n"
+ line_pattern += u(" qid:%d")
+ line_pattern += u(" %s\n")
if comment:
f.write("# Generated by dump_svmlight_file from scikit-learn %s\n"

0 comments on commit 71d1a7c

Please sign in to comment.