Пример #1
0
 def _eval_args(cls, args):
     if len(args) != 2:
         raise QuantumError(
             'Insufficient/excessive arguments to Oracle.  Please ' +
             'supply the number of qubits and an unknown function.')
     sub_args = args[0],
     sub_args = UnitaryOperator._eval_args(sub_args)
     if not sub_args[0].is_Integer:
         raise TypeError('Integer expected, got: %r' % sub_args[0])
     if not callable(args[1]):
         raise TypeError('Callable expected, got: %r' % args[1])
     sub_args = UnitaryOperator._eval_args(tuple(range(args[0])))
     return (sub_args, args[1])
Пример #2
0
 def _eval_args(cls, args):
     if len(args) != 2:
         raise QuantumError(
             'Insufficient/excessive arguments to Oracle.  Please ' +
                 'supply the number of qubits and an unknown function.'
         )
     sub_args = args[0],
     sub_args = UnitaryOperator._eval_args(sub_args)
     if not sub_args[0].is_Integer:
         raise TypeError('Integer expected, got: %r' % sub_args[0])
     if not callable(args[1]):
         raise TypeError('Callable expected, got: %r' % args[1])
     sub_args = UnitaryOperator._eval_args(tuple(range(args[0])))
     return (sub_args, args[1])
Пример #3
0
 def _eval_args(cls, args):
     # _eval_args has the right logic for the controls argument.
     controls = args[0]
     gate = args[1]
     if not is_sequence(controls):
         controls = (controls,)
     controls = UnitaryOperator._eval_args(controls)
     _validate_targets_controls(chain(controls,gate.targets))
     return (Tuple(*controls), gate)
Пример #4
0
 def _eval_args(cls, args):
     if len(args) != 1:
         raise QuantumError(
             'Insufficient/excessive arguments to W gate.  Please ' +
             'supply the number of qubits to operate on.')
     args = UnitaryOperator._eval_args(args)
     if not args[0].is_Integer:
         raise TypeError('Integer expected, got: %r' % args[0])
     return args
Пример #5
0
 def _eval_args(cls, args):
     # _eval_args has the right logic for the controls argument.
     controls = args[0]
     gate = args[1]
     if not is_sequence(controls):
         controls = (controls,)
     controls = UnitaryOperator._eval_args(controls)
     _validate_targets_controls(chain(controls, gate.targets))
     return (Tuple(*controls), gate)
Пример #6
0
Файл: gate.py Проект: fxkr/sympy
 def _eval_args(cls, args):
     # _eval_args has the right logic for the controls argument.
     controls = args[0]
     gate = args[1]
     if not ordered_iter(controls, include=Tuple):
         controls = (controls,)
     controls = UnitaryOperator._eval_args(controls)
     _validate_targets_controls(chain(controls,gate.targets))
     return (controls, gate)
Пример #7
0
 def _eval_args(cls, args):
     # _eval_args has the right logic for the controls argument.
     controls = args[0]
     gate = args[1]
     if not ordered_iter(controls):
         controls = (controls, )
     controls = UnitaryOperator._eval_args(controls)
     _validate_targets_controls(chain(controls, gate.targets))
     return (controls, gate)
Пример #8
0
 def _eval_args(cls, args):
     if len(args) != 1:
         raise QuantumError(
             'Insufficient/excessive arguments to W gate.  Please ' +
             'supply the number of qubits to operate on.'
         )
     args = UnitaryOperator._eval_args(args)
     if not args[0].is_Integer:
         raise TypeError('Integer expected, got: %r' % args[0])
     return args
Пример #9
0
    def _eval_args(cls, args):
        if len(args) != 2:
            raise QuantumError(
                'Insufficient/excessive arguments to Oracle.  Please ' +
                'supply the number of qubits and an unknown function.')
        sub_args = (args[0], )
        sub_args = UnitaryOperator._eval_args(sub_args)
        if not sub_args[0].is_Integer:
            raise TypeError('Integer expected, got: %r' % sub_args[0])

        function = args[1]
        if not isinstance(function, OracleGateFunction):
            function = OracleGateFunction(function)

        return (sub_args[0], function)
Пример #10
0
    def _eval_args(cls, args):
        # TODO: args[1] is not a subclass of Basic
        if len(args) != 2:
            raise QuantumError(
                "Insufficient/excessive arguments to Oracle.  Please "
                + "supply the number of qubits and an unknown function."
            )
        sub_args = (args[0],)
        sub_args = UnitaryOperator._eval_args(sub_args)
        if not sub_args[0].is_Integer:
            raise TypeError("Integer expected, got: %r" % sub_args[0])

        if not callable(args[1]):
            raise TypeError("Callable expected, got: %r" % args[1])
        return (sub_args[0], args[1])
Пример #11
0
 def _eval_args(cls, args):
     args = Tuple(*UnitaryOperator._eval_args(args))
     _validate_targets_controls(args)
     return args
Пример #12
0
 def _eval_args(cls, args):
     args = Tuple(*UnitaryOperator._eval_args(args))
     _validate_targets_controls(args)
     return args