Browse Source

!417 fix parse_columns help format error in web

Merge pull request !417 from anzhengqi/fix-commit-format-error
tags/v0.2.0-alpha
mindspore-ci-bot Gitee 6 years ago
parent
commit
0f7535171e
1 changed files with 12 additions and 7 deletions
  1. +12
    -7
      mindspore/dataset/engine/datasets.py

+ 12
- 7
mindspore/dataset/engine/datasets.py View File

@@ -2597,19 +2597,24 @@ class Schema:

Args:
columns (dict or list[dict]): dataset attribution information, decoded from schema file.
if list: columns element must be dict, 'name' and 'type' must be in keys, 'shape' optional.
if dict: columns.keys() as name, element in columns.values() is dict, and 'type' inside, 'shape' optional.
example 1)
[{'name': 'image', 'type': 'int8', 'shape': [3, 3]},
{'name': 'label', 'type': 'int8', 'shape': [1]}]
example 2)
{'image': {'shape': [3, 3], 'type': 'int8'}, 'label': {'shape': [1], 'type': 'int8'}}

- list[dict], 'name' and 'type' must be in keys, 'shape' optional.

- dict, columns.keys() as name, columns.values() is dict, and 'type' inside, 'shape' optional.

Raises:
RuntimeError: If failed to parse columns.
RuntimeError: If unknown items in columns.
RuntimeError: If column's name field is missing.
RuntimeError: If column's type field is missing.

Example:
>>> schema = Schema()
>>> columns1 = [{'name': 'image', 'type': 'int8', 'shape': [3, 3]},
>>> {'name': 'label', 'type': 'int8', 'shape': [1]}]
>>> schema.parse_columns(columns1)
>>> columns2 = {'image': {'shape': [3, 3], 'type': 'int8'}, 'label': {'shape': [1], 'type': 'int8'}}
>>> schema.parse_columns(columns2)
"""
self.columns = []
if isinstance(columns, list):


Loading…
Cancel
Save