quantum-viz.js
quantum-viz.js copied to clipboard
Improve API
Our current API for the package looks like this:
const sampleCircuit = {
qubits: [
// ...
],
operations: [
// ...
],
};
const sampleDiv = document.getElementById('sample');
qviz.draw(sampleCircuit, sampleDiv, qviz.STYLES['Default']);
A few things that would make for a good interface are:
- Easy to use
- Customizable (i.e. style, interactivity, custom augmentations)
- Easy to read
A good example of an interface that we can draw inspiration from is d3.js:
d3.select("body")
.selectAll("p")
.data([4, 8, 15, 16, 23, 42])
.enter().append("p")
.text(function(d) { return "I’m number " + d + "!"; });
We can select a DOM element, add data to it, and customize it. A similar API for Sqore would work really well.
A couple more things the API should allow:
- It should be easy to add custom visualizations of gates. Right now the logic to select a gate formatter (say
X) is hardcoded, should be easier to register a new formatter that takes precedence over the built-in ones. - It should be easy to change the state of the circuit/sqore programmatically. For example, we should be able to easily change what operations are expanded/collapsed.
- The data-schema should be cleaned-up/simplified. For example:
- having
numChildrento indicate classical bits it's really odd - the way we define
Measuregates is very complicated - it should be possible to specify initial qubit states other than |0>
- having