From 8f17bd6f216448fe2f7d6e55dfa27a10402bf8f7 Mon Sep 17 00:00:00 2001 From: Anastasiia Pnevskaia Date: Thu, 24 Nov 2022 10:28:20 +0100 Subject: [PATCH] copy() and deepcopy() tests for PartialShape. (#14190) * Added tests of copy() and deepcopy() for PartialShape. * Code reformat. --- .../python/tests/test_graph/test_core.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/bindings/python/tests/test_graph/test_core.py b/src/bindings/python/tests/test_graph/test_core.py index 935473e50ef..554e11ca9ef 100644 --- a/src/bindings/python/tests/test_graph/test_core.py +++ b/src/bindings/python/tests/test_graph/test_core.py @@ -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()