MCPcopy Create free account
hub / github.com/dmlc/dmlc-core / Check

Method Check

include/dmlc/parameter.h:728–752  ·  view source on GitHub ↗

consistency check for numeric ranges

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

ParamErrorClass · 0.85
GetMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected