Browse Source

!2640 [MD] fix minddata error message

Merge pull request !2640 from liyong126/minddataset_fix_errmsg
tags/v0.6.0-beta
mindspore-ci-bot Gitee 5 years ago
parent
commit
db6c4bf784
2 changed files with 5 additions and 5 deletions
  1. +2
    -2
      mindspore/dataset/engine/validators.py
  2. +3
    -3
      tests/ut/python/dataset/test_split.py

+ 2
- 2
mindspore/dataset/engine/validators.py View File

@@ -1065,12 +1065,12 @@ def check_split(method):
if all_int:
all_positive = all(item > 0 for item in sizes)
if not all_positive:
raise ValueError("sizes is a list of int, but there should be no negative numbers.")
raise ValueError("sizes is a list of int, but there should be no negative or zero numbers.")

if all_float:
all_valid_percentages = all(0 < item <= 1 for item in sizes)
if not all_valid_percentages:
raise ValueError("sizes is a list of float, but there should be no numbers outside the range [0, 1].")
raise ValueError("sizes is a list of float, but there should be no numbers outside the range (0, 1].")

epsilon = 0.00001
if not abs(sum(sizes) - 1) < epsilon:


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

@@ -38,7 +38,7 @@ def split_with_invalid_inputs(d):

with pytest.raises(ValueError) as info:
_, _ = d.split([-1, 6])
assert "there should be no negative numbers" in str(info.value)
assert "there should be no negative or zero numbers" in str(info.value)

with pytest.raises(RuntimeError) as info:
_, _ = d.split([3, 1])
@@ -54,11 +54,11 @@ def split_with_invalid_inputs(d):

with pytest.raises(ValueError) as info:
_, _ = d.split([-0.5, 0.5])
assert "there should be no numbers outside the range [0, 1]" in str(info.value)
assert "there should be no numbers outside the range (0, 1]" in str(info.value)

with pytest.raises(ValueError) as info:
_, _ = d.split([1.5, 0.5])
assert "there should be no numbers outside the range [0, 1]" in str(info.value)
assert "there should be no numbers outside the range (0, 1]" in str(info.value)

with pytest.raises(ValueError) as info:
_, _ = d.split([0.5, 0.6])


Loading…
Cancel
Save