qiskit_classroom.input_model

moudle for input data classes

 1"""moudle for input data classes"""
 2
 3#  Licensed to the Apache Software Foundation (ASF) under one
 4#  or more contributor license agreements.  See the NOTICE file
 5#  distributed with this work for additional information
 6#  regarding copyright ownership.  The ASF licenses this file
 7#  to you under the Apache License, Version 2.0 (the
 8#  "License"); you may not use this file except in compliance
 9#  with the License.  You may obtain a copy of the License at
10#
11#    http://www.apache.org/licenses/LICENSE-2.0
12#
13#  Unless required by applicable law or agreed to in writing,
14#  software distributed under the License is distributed on an
15#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16#  KIND, either express or implied.  See the License for the
17#  specific language governing permissions and limitations
18#  under the License.
19
20import random
21import string
22
23
24# pylint: disable=too-few-public-methods
25class Input:
26    """contain user input value"""
27
28    def __init__(self) -> None:
29        pass
30
31    def __str__(self) -> str:
32        """return contents
33
34        Returns:
35            str: contents
36        """
37        return ""
38
39
40# pylint: disable=too-few-public-methods
41class QuantumCircuitInput(Input):
42    """user input value for QuantumCircuit"""
43
44    def __init__(self, value_name: str) -> None:
45        super().__init__()
46        self.value_name = value_name
47
48    def __str__(self) -> str:
49        return "value_name : " + self.value_name
50
51
52# pylint: disable=too-few-public-methods
53class DiracInput(Input):
54    """user input value for Dirac notation"""
55
56
57# pylint: disable=too-few-public-methods
58class MatrixInput(Input):
59    """user input value for Matrix"""
60
61    def __init__(self, num_qubits: int, do_measure: bool) -> None:
62        super().__init__()
63        self.value_name = "".join(
64            random.choice(string.ascii_letters) for _ in range(10)
65        )
66        self.num_qubits = num_qubits
67        self.do_measure = do_measure
class Input:
26class Input:
27    """contain user input value"""
28
29    def __init__(self) -> None:
30        pass
31
32    def __str__(self) -> str:
33        """return contents
34
35        Returns:
36            str: contents
37        """
38        return ""

contain user input value

class QuantumCircuitInput(Input):
42class QuantumCircuitInput(Input):
43    """user input value for QuantumCircuit"""
44
45    def __init__(self, value_name: str) -> None:
46        super().__init__()
47        self.value_name = value_name
48
49    def __str__(self) -> str:
50        return "value_name : " + self.value_name

user input value for QuantumCircuit

QuantumCircuitInput(value_name: str)
45    def __init__(self, value_name: str) -> None:
46        super().__init__()
47        self.value_name = value_name
value_name
class DiracInput(Input):
54class DiracInput(Input):
55    """user input value for Dirac notation"""

user input value for Dirac notation

class MatrixInput(Input):
59class MatrixInput(Input):
60    """user input value for Matrix"""
61
62    def __init__(self, num_qubits: int, do_measure: bool) -> None:
63        super().__init__()
64        self.value_name = "".join(
65            random.choice(string.ascii_letters) for _ in range(10)
66        )
67        self.num_qubits = num_qubits
68        self.do_measure = do_measure

user input value for Matrix

MatrixInput(num_qubits: int, do_measure: bool)
62    def __init__(self, num_qubits: int, do_measure: bool) -> None:
63        super().__init__()
64        self.value_name = "".join(
65            random.choice(string.ascii_letters) for _ in range(10)
66        )
67        self.num_qubits = num_qubits
68        self.do_measure = do_measure
value_name
num_qubits
do_measure