# Custom gate error using basic tutorial: Type error: RXX.decomposition() missing 2 required positional arguments

**URL:** <https://discuss.pennylane.ai/t/custom-gate-error-using-basic-tutorial-type-error-rxx-decomposition-missing-2-required-positional-arguments/2559>\
**Category:** PennyLane Help\
**Created:** [February 15, 2023, 7:04pm UTC](https://discuss.pennylane.ai/t/custom-gate-error-using-basic-tutorial-type-error-rxx-decomposition-missing-2-required-positional-arguments/2559 "2023-02-15T19:04:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![omersajid9](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/omersajid9/32/1433_2.png) [@omersajid9](https://discuss.pennylane.ai/u/omersajid9)\
**Post date:** [February 15, 2023, 7:04pm UTC](https://discuss.pennylane.ai/t/custom-gate-error-using-basic-tutorial-type-error-rxx-decomposition-missing-2-required-positional-arguments/2559/1 "2023-02-15T19:04:47Z")

</div>

Hi, I have a custom parameterized ansatz which I would like to repeat in my circuit with different parameters for certain gates. I have a routine to acomplish this but I started by creating a template custom operator but am not able to do it. I am using the online tutorial for a simple custom gate but am getting the following error:

```auto
File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pennylane\qnode.py:847, in QNode. __call__ (self, *args, **kwargs)
    843 self._update_original_device()
    845 return res
--> 847 res = qml.execute(
    848 [self.tape],
    849 device=self.device,
    850 gradient_fn=self.gradient_fn,
    851 interface=self.interface,
    852 gradient_kwargs=self.gradient_kwargs,
    853 override_shots=override_shots,
    854 **self.execute_kwargs,
    855 )
    857 if old_interface == "auto":
    858 self.interface = "auto"

File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pennylane\interfaces\execution.py:724, in execute(tapes, device, gradient_fn, interface, mode, gradient_kwargs, cache, cachesize, max_diff, override_shots, expand_fn, max_expansion, device_batch_transform)
    718 except ImportError as e:
    719 raise qml.QuantumFunctionError(
    720 f"{mapped_interface} not found. Please install the latest "
    721 f"version of {mapped_interface} to enable the '{mapped_interface}' interface."
...
-> 1346 result = fn(*args, **kwargs)
   1348 qscript = QuantumScript.from_queue(q)
   1349 qscript._qfunc_output = result

TypeError: RXX.decomposition() missing 2 required positional arguments: 'theta' and 'wires'

```

I have the following code:

```auto
import pennylane as qml
from pennylane.operation import Operation
from pennylane import numpy as np

class RXX(Operation):
    num_params = 1
    num_wires = 2
    par_domain = "R"

    @staticmethod
    def decomposition(theta, wires):
        return [qml.PauliRot(theta, 'XX', wires=wires)]
       dev = qml.device('default.qubit', wires=2, shots=100)

@qml.qnode(dev)
def circuit(theta):
    RXX(theta, wires=[0, 1])
    qml.Hadamard(1)
    return qml.expval(qml.PauliZ(0) @ qml.PauliY(1))
circuit(0.1)

```

I have tried different ways by first saving the params and wires at Operation initiazation and reference that in the static decomposition but that doesn’t work. Can you kindly guide me is this is even possible or should I just directly apply my gates?

---

<div class="post-metadata">

**Author:** ![Wierichs](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/wierichs/32/1476_2.png) [@Wierichs](https://discuss.pennylane.ai/u/Wierichs)\
**Post date:** [February 16, 2023, 8:32am UTC](https://discuss.pennylane.ai/t/custom-gate-error-using-basic-tutorial-type-error-rxx-decomposition-missing-2-required-positional-arguments/2559/2 "2023-02-16T08:32:12Z")

</div>

Dear @omersajid9,  
thanks for the report, this is a “bug” in the blog post you were using. Sorry about that!  
The reason I say “bug” is because we tend to not update blog posts, as they carry a date and are intended to reflect the codebase at the time of blog release. The documentation is a more timely reference and is intended to be up to date at all times. In particular, for custom operators see [this documentation page](https://docs.pennylane.ai/en/stable/development/adding_operators.html).

The reason for the thrown error is that the operator class was modified in the meantime. Luckily, there is a _very_ simple fix for your problem 🙂

Replace the function name `decomposition` by `compute_decomposition` and you’re good to go!  
Let me know in case you run into any other issues, and happy coding! 🙂
