Browse Source

!194 Fix dataset parameter check

Merge pull request !194 from pengyanjun/fix_dataset_para_validator_check
tags/v0.2.0-alpha
mindspore-ci-bot Gitee 5 years ago
parent
commit
7f8c9ebf10
3 changed files with 9 additions and 1 deletions
  1. +0
    -1
      mindspore/dataset/engine/samplers.py
  2. +5
    -0
      mindspore/dataset/engine/validators.py
  3. +4
    -0
      mindspore/dataset/transforms/vision/validators.py

+ 0
- 1
mindspore/dataset/engine/samplers.py View File

@@ -127,7 +127,6 @@ class RandomSampler():

Raises:
ValueError: If replacement is not boolean.
ValueError: If num_samples is not None and replacement is false.
ValueError: If num_samples is not positive.
"""



+ 5
- 0
mindspore/dataset/engine/validators.py View File

@@ -556,6 +556,11 @@ def check_generatordataset(method):
if column_names is None:
raise ValueError("column_names is not provided.")

# check prefetch_size range
prefetch_size = param_dict.get('prefetch_size')
if prefetch_size is not None and (prefetch_size <= 0 or prefetch_size > 1024):
raise ValueError("prefetch_size exceeds the boundary.")

check_param_type(nreq_param_int, param_dict, int)

check_param_type(nreq_param_list, param_dict, list)


+ 4
- 0
mindspore/dataset/transforms/vision/validators.py View File

@@ -104,6 +104,10 @@ def check_padding(padding):
raise ValueError("The size of the padding list or tuple should be 2 or 4.")
else:
raise TypeError("Padding can be any of: a number, a tuple or list of size 2 or 4.")
if not (isinstance(left, int) and isinstance(top, int) and isinstance(right, int) and isinstance(bottom, int)):
raise TypeError("Padding value should be integer.")
if left < 0 or top < 0 or right < 0 or bottom < 0:
raise ValueError("Padding value could not be negative.")
return left, top, right, bottom




Loading…
Cancel
Save