# This code is part of Qiskit.## (C) Copyright IBM 2017, 2020## This code is licensed under the Apache License, Version 2.0. You may# obtain a copy of this license in the LICENSE.txt file in the root directory# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.## Any modifications or derivative works of this code must retain this# copyright notice, and modified files need to carry a notice indicating# that they have been altered from the originals."""Module for Vertex"""fromtypingimportList,Unionfromqiskit_qec.geometry.model.shape_objectimportShapeObject
[docs]classVertex(ShapeObject):""" "Vertex" inherits from "ShapeObject" """def__init__(self,pos:List[Union[float,int]])->None:"""Inits Vertex Args: pos (List[Union[float, int]]): position of vertex """self.pos=possuper().__init__()def__repr__(self)->str:returnself.__str__()def__str__(self)->str:returnself.pos.__str__()
[docs]defset_position(self,pos:List[Union[float,int]]):"""Sets global position of Vertex Args: pos (List[Union[float, int]]): global position """self.pos=pos
@propertydefposition(self)->List[Union[float,int]]:"""Return position of vertex"""returnself.pos
[docs]defshallowcopy(self)->"Vertex":"""Returns a shallow copy of the Vertex. A shallow copy creates a new Vertex with only the position being copied Returns: Vertex: Shallow copy of vertex """returnVertex(self.pos)