Browse Source

!16024 dataset: modify some error msg in dataset module

From: @ms_yan
Reviewed-by: @jonyguo,@heleiwang
Signed-off-by: @jonyguo
pull/16024/MERGE
mindspore-ci-bot Gitee 5 years ago
parent
commit
eb08d2e952
4 changed files with 15 additions and 5 deletions
  1. +3
    -1
      mindspore/ccsrc/minddata/dataset/kernels/data/data_utils.cc
  2. +8
    -0
      mindspore/core/utils/status.cc
  3. +1
    -1
      mindspore/dataset/transforms/validators.py
  4. +3
    -3
      tests/ut/python/dataset/test_pad_end_op.py

+ 3
- 1
mindspore/ccsrc/minddata/dataset/kernels/data/data_utils.cc View File

@@ -386,7 +386,9 @@ Status PadEnd(const std::shared_ptr<Tensor> &src, std::shared_ptr<Tensor> *dst,
}
}
CHECK_FAIL_RETURN_UNEXPECTED(src->type().IsNumeric() == pad_val->type().IsNumeric(),
"PadEnd: Source and pad_value are not of the same type.");
"PadEnd: pad_value and item of dataset are not of the same type, type of pad_value is:" +
pad_val->type().ToString() +
", and type of dataset item is:" + src->type().ToString() + ".");
if (pad_val->type().IsNumeric()) {
std::shared_ptr<Tensor> float_pad_value;
RETURN_IF_NOT_OK(TypeCast(pad_val, &float_pad_value, DataType(DataType::DE_FLOAT32)));


+ 8
- 0
mindspore/core/utils/status.cc View File

@@ -58,7 +58,11 @@ Status::Status(enum StatusCode code, int line_of_code, const char *file_name, co

std::ostringstream ss;
#ifndef ENABLE_ANDROID
#ifdef DEBUG
ss << "Thread ID " << std::this_thread::get_id() << " " << CodeAsString(code) << ". ";
#else
ss << CodeAsString(code) << ". ";
#endif
if (!data_->err_description.empty()) {
ss << data_->err_description;
}
@@ -168,7 +172,11 @@ std::vector<char> Status::SetErrDescription(const std::vector<char> &err_descrip
data_->err_description = CharToString(err_description);
std::ostringstream ss;
#ifndef ENABLE_ANDROID
#ifdef DEBUG
ss << "Thread ID " << std::this_thread::get_id() << " " << CodeAsString(data_->status_code) << ". ";
#else
ss << CodeAsString(data_->status_code) << ". ";
#endif
if (!data_->err_description.empty()) {
ss << data_->err_description;
}


+ 1
- 1
mindspore/dataset/transforms/validators.py View File

@@ -166,7 +166,7 @@ def check_pad_end(method):

if pad_value is not None:
type_check(pad_value, (str, float, bool, int, bytes), "pad_value")
type_check(pad_shape, (list,), "pad_end")
type_check(pad_shape, (list,), "pad_shape")

for dim in pad_shape:
if dim is not None:


+ 3
- 3
tests/ut/python/dataset/test_pad_end_op.py View File

@@ -51,11 +51,11 @@ def test_pad_end_str():
def test_pad_end_exceptions():
with pytest.raises(RuntimeError) as info:
pad_compare([1, 2], [3], "-1", [])
assert "Source and pad_value are not of the same type." in str(info.value)
assert "pad_value and item of dataset are not of the same type" in str(info.value)

with pytest.raises(RuntimeError) as info:
pad_compare([b"1", b"2", b"3", b"4", b"5"], [2], 1, [])
assert "Source and pad_value are not of the same type." in str(info.value)
assert "pad_value and item of dataset are not of the same type" in str(info.value)

with pytest.raises(TypeError) as info:
pad_compare([3, 4, 5], ["2"], 1, [])
@@ -63,7 +63,7 @@ def test_pad_end_exceptions():

with pytest.raises(TypeError) as info:
pad_compare([1, 2], 3, -1, [1, 2, -1])
assert "Argument pad_end with value 3 is not of type [<class 'list'>]" in str(info.value)
assert "Argument pad_shape with value 3 is not of type [<class 'list'>]" in str(info.value)


if __name__ == "__main__":


Loading…
Cancel
Save