提交 b6ac64a3 编写于 作者: Y Yu Yang

Remove unnecessary error default value.

上级 b1ab8b56
...@@ -781,9 +781,7 @@ real PrecisionRecallEvaluator::getValue(const std::string& name, ...@@ -781,9 +781,7 @@ real PrecisionRecallEvaluator::getValue(const std::string& name,
paddle::str::split(name, '.', &buffers); paddle::str::split(name, '.', &buffers);
auto it = this->values_.find(buffers[buffers.size() - 1]); auto it = this->values_.find(buffers[buffers.size() - 1]);
if (it == this->values_.end()) { // not found if (it == this->values_.end()) { // not found
if (err != nullptr) { *err = Error("No such key %s", name.c_str());
*err = Error("No such key %s", name.c_str());
}
return .0f; return .0f;
} }
...@@ -792,10 +790,6 @@ real PrecisionRecallEvaluator::getValue(const std::string& name, ...@@ -792,10 +790,6 @@ real PrecisionRecallEvaluator::getValue(const std::string& name,
std::string PrecisionRecallEvaluator::getType(const std::string& name, std::string PrecisionRecallEvaluator::getType(const std::string& name,
Error* err) const { Error* err) const {
Error localErr;
if (err == nullptr) {
err = &localErr;
}
this->getValue(name, err); this->getValue(name, err);
if (!err->isOK()) { if (!err->isOK()) {
return ""; return "";
......
...@@ -141,16 +141,13 @@ public: ...@@ -141,16 +141,13 @@ public:
* @brief getValue will return the current evaluate value of one field. * @brief getValue will return the current evaluate value of one field.
* *
* @param name: The field name of current evaluator. * @param name: The field name of current evaluator.
* @param err [out]: The error state. nullptr means don't care. * @param err [out]: The error state.
* *
* @return The evaluate value(metric). * @return The evaluate value(metric).
*/ */
virtual real getValue(const std::string& name, virtual real getValue(const std::string& name, paddle::Error* err) const {
paddle::Error* err = nullptr) const {
if (name != config_.name()) { if (name != config_.name()) {
if (err != nullptr) { *err = paddle::Error("no such name of evaluator %s", name.c_str());
*err = paddle::Error("no such name of evaluator %s", name.c_str());
}
return .0f; return .0f;
} }
return this->getValueImpl(); return this->getValueImpl();
...@@ -168,8 +165,8 @@ public: ...@@ -168,8 +165,8 @@ public:
* @return the evaluator type string. * @return the evaluator type string.
*/ */
virtual std::string getType(const std::string& name, virtual std::string getType(const std::string& name,
paddle::Error* err = nullptr) const { paddle::Error* err) const {
if (name != config_.name() && err != nullptr) { if (name != config_.name()) {
*err = paddle::Error("no such name of evaluator %s", name.c_str()); *err = paddle::Error("no such name of evaluator %s", name.c_str());
return std::string(); return std::string();
} }
...@@ -212,15 +209,11 @@ public: ...@@ -212,15 +209,11 @@ public:
void getNames(std::vector<std::string>* names) {} void getNames(std::vector<std::string>* names) {}
real getValue(const std::string& name, Error* err) const { real getValue(const std::string& name, Error* err) const {
if (err != nullptr) { *err = Error("Not implemented");
*err = Error("Not implemented");
}
return .0f; return .0f;
} }
std::string getType(const std::string& name, Error* err) const { std::string getType(const std::string& name, Error* err) const {
if (err != nullptr) { *err = Error("Not implemented");
*err = Error("Not implemented");
}
return ""; return "";
} }
}; };
......
...@@ -391,7 +391,7 @@ private: ...@@ -391,7 +391,7 @@ private:
return callback(eval); return callback(eval);
} }
} }
if (err != nullptr) *err = Error("No such key %s", name.c_str()); *err = Error("No such key %s", name.c_str());
return T(); return T();
} }
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册