• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2020 Huawei Technologies Co., Ltd
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14# ==============================================================================
15"""
16Test Input Indexes
17"""
18
19import mindspore.dataset as ds
20from mindspore import log as logger
21
22def test_basics_input_indexes():
23    """
24    Test basic cases for input indexes.
25    """
26    logger.info("test_basics_input_indexes")
27    data = ds.NumpySlicesDataset([1, 2, 3], column_names=["col_1"])
28    assert data.input_indexs == ()
29    data.input_indexs = 10
30    assert data.input_indexs == 10
31    data = data.shuffle(2)
32    assert data.input_indexs == 10
33    data = data.project(["col_1"])
34    assert data.input_indexs == 10
35
36    data2 = ds.NumpySlicesDataset([1, 2, 3], column_names=["col_1"])
37    assert data2.input_indexs == ()
38    data2 = data2.shuffle(2)
39    assert data2.input_indexs == ()
40    data2 = data2.project(["col_1"])
41    assert data2.input_indexs == ()
42    data2.input_indexs = 20
43    assert data2.input_indexs == 20
44
45    data3 = data + data2
46    assert data3.input_indexs == 10
47
48if __name__ == '__main__':
49    test_basics_input_indexes()
50