Jelajahi Sumber

force C++11 support for python

Summary: Fix issue https://github.com/facebookresearch/fastText/issues/1052

Reviewed By: EdouardGrave

Differential Revision: D21379335

fbshipit-source-id: 15dad95074e8be71d4c9dc797e8280da32c1ed4f
Onur Çelebi 5 tahun lalu
induk
melakukan
b96adbe148
2 mengubah file dengan 14 tambahan dan 13 penghapusan
  1. 13 12
      python/fasttext_module/fasttext/pybind/fasttext_pybind.cc
  2. 1 1
      setup.py

+ 13 - 12
python/fasttext_module/fasttext/pybind/fasttext_pybind.cc

@@ -199,28 +199,29 @@ PYBIND11_MODULE(fasttext_pybind, m) {
       .def("scoreVsTrue", &fasttext::Meter::scoreVsTrue)
       .def(
           "precisionRecallCurveLabel",
-          py::overload_cast<int32_t>(
-              &fasttext::Meter::precisionRecallCurve, py::const_))
+          (std::vector<std::pair<double, double>>(fasttext::Meter::*)(int32_t)
+               const) &
+              fasttext::Meter::precisionRecallCurve)
       .def(
           "precisionRecallCurve",
-          py::overload_cast<>(
-              &fasttext::Meter::precisionRecallCurve, py::const_))
+          (std::vector<std::pair<double, double>>(fasttext::Meter::*)() const) &
+              fasttext::Meter::precisionRecallCurve)
       .def(
           "precisionAtRecallLabel",
-          py::overload_cast<int32_t, double>(
-              &fasttext::Meter::precisionAtRecall, py::const_))
+          (double (fasttext::Meter::*)(int32_t, double) const) &
+              fasttext::Meter::precisionAtRecall)
       .def(
           "precisionAtRecall",
-          py::overload_cast<double>(
-              &fasttext::Meter::precisionAtRecall, py::const_))
+          (double (fasttext::Meter::*)(double) const) &
+              fasttext::Meter::precisionAtRecall)
       .def(
           "recallAtPrecisionLabel",
-          py::overload_cast<int32_t, double>(
-              &fasttext::Meter::recallAtPrecision, py::const_))
+          (double (fasttext::Meter::*)(int32_t, double) const) &
+              fasttext::Meter::recallAtPrecision)
       .def(
           "recallAtPrecision",
-          py::overload_cast<double>(
-              &fasttext::Meter::recallAtPrecision, py::const_));
+          (double (fasttext::Meter::*)(double) const) &
+              fasttext::Meter::recallAtPrecision);
 
   py::class_<fasttext::FastText>(m, "fasttext")
       .def(py::init<>())

+ 1 - 1
setup.py

@@ -101,7 +101,7 @@ def cpp_flag(compiler):
     """Return the -std=c++[11/14] compiler flag.
     The c++14 is preferred over c++11 (when it is available).
     """
-    standards = ['-std=c++14', '-std=c++11']
+    standards = ['-std=c++11']
     for standard in standards:
         if has_flag(compiler, [standard]):
             return standard