Skip to content

Bugfix for drawing RandomEncodingCircuit#371

Merged
MoritzWillmann merged 3 commits intosQUlearn:developfrom
kit0kat:fix/draw-random-encoding-circuit
Jan 7, 2026
Merged

Bugfix for drawing RandomEncodingCircuit#371
MoritzWillmann merged 3 commits intosQUlearn:developfrom
kit0kat:fix/draw-random-encoding-circuit

Conversation

@kit0kat
Copy link
Contributor

@kit0kat kit0kat commented Dec 19, 2025

There seems to be a bug when drawing a RandomEncodingCircuit.

Minimal re-produceable code (run in a jupyter notebook with matplotlib installed):

  1. Passing no num_features:
from squlearn.encoding_circuit import RandomEncodingCircuit
RandomEncodingCircuit(num_qubits=4, seed=42).draw("mpl")

❌ TypeError: '>' not supported between instances of 'NoneType' and 'int'

  1. Passing num_features only to Circuit():
from squlearn.encoding_circuit import RandomEncodingCircuit
RandomEncodingCircuit(num_qubits=4, seed=42, num_features=3).draw("mpl")

❌ TypeError: '>' not supported between instances of 'NoneType' and 'int'

  1. Passing num_features only to draw():
from squlearn.encoding_circuit import RandomEncodingCircuit
RandomEncodingCircuit(num_qubits=4, seed=42).draw("mpl", num_features=3)

⚠️ no error, but drawing shows x instead of x[0...3] vector

  1. Passing num_features to Circuit() and draw():
from squlearn.encoding_circuit import RandomEncodingCircuit
RandomEncodingCircuit(num_qubits=4, seed=42, num_features=3).draw("mpl", num_features=3)

❌ ValueError: Number of features in the input data (1) does not match the number of features in the encoding circuit (3).

This PR proposes a possible fix for the draw() method that seems to work for all 4 cases.

@MoritzWillmann MoritzWillmann self-requested a review January 7, 2026 06:16
@MoritzWillmann
Copy link
Collaborator

Hey @kit0kat, thanks for catching and fixing this. I'll get this merged ASAP 😄

@MoritzWillmann MoritzWillmann self-assigned this Jan 7, 2026
@MoritzWillmann MoritzWillmann merged commit 58bb9b1 into sQUlearn:develop Jan 7, 2026
1 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments