示例#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
文件: gate.py 项目: yangle/sympy
 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
文件: grover.py 项目: msgoff/sympy
    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
文件: gate.py 项目: yangle/sympy
 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