consistency check for numeric ranges
| 726 | } |
| 727 | // consistency check for numeric ranges |
| 728 | virtual void Check(void *head) const { |
| 729 | FieldEntryBase<TEntry, DType>::Check(head); |
| 730 | DType v = this->Get(head); |
| 731 | if (has_begin_ && has_end_) { |
| 732 | if (v < begin_ || v > end_) { |
| 733 | std::ostringstream os; |
| 734 | os << "value " << v << " for Parameter " << this->key_ |
| 735 | << " exceed bound [" << begin_ << ',' << end_ <<']' << '\n'; |
| 736 | os << this->key_ << ": " << this->description_; |
| 737 | throw dmlc::ParamError(os.str()); |
| 738 | } |
| 739 | } else if (has_begin_ && v < begin_) { |
| 740 | std::ostringstream os; |
| 741 | os << "value " << v << " for Parameter " << this->key_ |
| 742 | << " should be greater equal to " << begin_ << '\n'; |
| 743 | os << this->key_ << ": " << this->description_; |
| 744 | throw dmlc::ParamError(os.str()); |
| 745 | } else if (has_end_ && v > end_) { |
| 746 | std::ostringstream os; |
| 747 | os << "value " << v << " for Parameter " << this->key_ |
| 748 | << " should be smaller equal to " << end_ << '\n'; |
| 749 | os << this->key_ << ": " << this->description_; |
| 750 | throw dmlc::ParamError(os.str()); |
| 751 | } |
| 752 | } |
| 753 | |
| 754 | protected: |
| 755 | // whether it have begin and end range |
nothing calls this directly
no test coverage detected