PennyLaneAI / pennylane

PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
https://pennylane.ai
Apache License 2.0
2.36k stars 604 forks source link

[BUG] Autoray wrongly dispatches `append` operation to `numpy` when using `pennylane.numpy.tensor` arrays #6119

Open EmilianoG-byte opened 2 months ago

EmilianoG-byte commented 2 months ago

Expected behavior

Appending two pennylane.numpy.tensor arrays using qml.math.append returns another pennylane.numpy.tensor array.

Actual behavior

Appending two pennylane.numpy arrays using qml.math.append returns a numpy.ndarray array.

Additional information

No response

Source code

import pennylane.numpy as pnp
a = pnp.array([0])
b = pnp.array([1])

type(qml.math.append(a,b))
>> numpy.ndarray

Tracebacks

No response

System information

Name: PennyLane
Version: 0.38.0.dev6
Summary: PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
Home-page: https://github.com/PennyLaneAI/pennylane
Author: 
Author-email: 
License: Apache License 2.0
Location: /Users/emiliano.godinez/.pyenv/versions/3.10.14/envs/pennylane-dev/lib/python3.10/site-packages
Editable project location: /Users/emiliano.godinez/Documents/software_development/pennylane
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, packaging, pennylane-lightning, requests, rustworkx, scipy, semantic-version, toml, typing-extensions
Required-by: PennyLane-qiskit, PennyLane_Lightning

Platform info:           macOS-14.6.1-arm64-arm-64bit
Python version:          3.10.14
Numpy version:           1.26.4
Scipy version:           1.13.1
Installed devices:
- lightning.qubit (PennyLane_Lightning-0.37.0)
- qiskit.aer (PennyLane-qiskit-0.37.0)
- qiskit.basicaer (PennyLane-qiskit-0.37.0)
- qiskit.basicsim (PennyLane-qiskit-0.37.0)
- qiskit.ibmq (PennyLane-qiskit-0.37.0)
- qiskit.ibmq.circuit_runner (PennyLane-qiskit-0.37.0)
- qiskit.ibmq.sampler (PennyLane-qiskit-0.37.0)
- qiskit.remote (PennyLane-qiskit-0.37.0)
- default.clifford (PennyLane-0.38.0.dev6)
- default.gaussian (PennyLane-0.38.0.dev6)
- default.mixed (PennyLane-0.38.0.dev6)
- default.qubit (PennyLane-0.38.0.dev6)
- default.qubit.autograd (PennyLane-0.38.0.dev6)
- default.qubit.jax (PennyLane-0.38.0.dev6)
- default.qubit.legacy (PennyLane-0.38.0.dev6)
- default.qubit.tf (PennyLane-0.38.0.dev6)
- default.qubit.torch (PennyLane-0.38.0.dev6)
- default.qutrit (PennyLane-0.38.0.dev6)
- default.qutrit.mixed (PennyLane-0.38.0.dev6)
- default.tensor (PennyLane-0.38.0.dev6)
- null.qubit (PennyLane-0.38.0.dev6)

Existing GitHub issues