copy() and deepcopy() tests for PartialShape. (#14190)

* Added tests of copy() and deepcopy() for PartialShape.

* Code reformat.
This commit is contained in:
Anastasiia Pnevskaia
2022-11-24 10:28:20 +01:00
committed by GitHub
parent b7d4deb2d8
commit 8f17bd6f21

View File

@@ -2,6 +2,8 @@
# Copyright (C) 2018-2022 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import copy
import numpy as np
import pytest
@@ -217,6 +219,30 @@ def test_partial_shape():
shape = Shape()
assert len(shape) == 0
shape = PartialShape("[?, 3, ..224, 28..224, 25..]")
copied_shape = copy.copy(shape)
assert shape == copied_shape, "Copied shape {0} is not equal to original shape {1}.".format(copied_shape, shape)
shape = PartialShape("[...]")
copied_shape = copy.copy(shape)
assert shape == copied_shape, "Copied shape {0} is not equal to original shape {1}.".format(copied_shape, shape)
shape = PartialShape([Dimension(-1, 100), 25, -1])
copied_shape = copy.copy(shape)
assert shape == copied_shape, "Copied shape {0} is not equal to original shape {1}.".format(copied_shape, shape)
shape = PartialShape("[?, 3, ..224, 28..224, 25..]")
copied_shape = copy.deepcopy(shape)
assert shape == copied_shape, "Copied shape {0} is not equal to original shape {1}.".format(copied_shape, shape)
shape = PartialShape("[...]")
copied_shape = copy.deepcopy(shape)
assert shape == copied_shape, "Copied shape {0} is not equal to original shape {1}.".format(copied_shape, shape)
shape = PartialShape([Dimension(-1, 100), 25, -1])
copied_shape = copy.deepcopy(shape)
assert shape == copied_shape, "Copied shape {0} is not equal to original shape {1}.".format(copied_shape, shape)
def test_partial_shape_compatible():
ps1 = PartialShape.dynamic()