qiskit-community/qiskit-js

qiskit-sim not working

Closed this issue · 3 comments

Environment (please complete the following information):

  • Qiskit.js version:
    0.7.1
  • Node.js version:
    10.15.3
  • Operating system:
    mac os mojave

What is the current behavior?

the first time I run it

Input randomized (as string):
0:|0>
1:|0>

Input randomized:
[ false, false ]

Running the circuit now ...

Done, internal state:
[ { re: 0.7071067811865475, im: 0 },
  { re: 0, im: 0 },
  { re: 0, im: 0 },
  { re: 0.7071067811865475, im: 0 } ]

Internal state (as string):
0.70710678+0i|00>50%
0+0i|01>0%
0+0i|10>0%
0.70710678+0i|11>50%

Saved IR:
{ nQubits: 2,
  gates:
   [ [ { id: 'nu8FAAIALbxRuQMn5K',
         name: 'h',
         connector: 0,
         wires: [ 0 ] },
       { id: 'hwUglvXbpfqqMwPJ0r',
         name: 'cx',
         connector: 0,
         wires: [ 0, 1 ] } ],
     [ null,
       { id: 'hwUglvXbpfqqMwPJ0r',
         name: 'cx',
         connector: 1,
         wires: [ 0, 1 ] } ] ],
  customGates: {} }

the second time I run it

Input randomized (as string):
0:|1>
1:|0>

Input randomized:
[ true, false ]

Running the circuit now ...
/Users/omar/Documents/RESEARCH/Experiments/qiskit@0.7.0/node_modules/@qiskit/sim/lib/Circuit.js:237
    const gate = gates.get(gateName.toLowerCase());
                                    ^

TypeError: gateName.toLowerCase is not a function
    at Circuit.applyGate (/Users/omar/Documents/RESEARCH/Experiments/qiskit@0.7.0/node_modules/@qiskit/sim/lib/Circuit.js:237:37)
    at Circuit.run (/Users/omar/Documents/RESEARCH/Experiments/qiskit@0.7.0/node_modules/@qiskit/sim/lib/Circuit.js:298:16)
    at Object.<anonymous> (/Users/omar/Documents/RESEARCH/Experiments/qiskit@0.7.0/app_02.js:30:9)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
    at startup (internal/bootstrap/node.js:283:19)

it always gives me this error unless I get lucky enough for the input randomized to be [false, false].
Seems like it is not the way it is supposed to work, right?

Steps to reproduce the problem

I'm running the first bell state example that appears both on the readme page of qiskit-sim and the example folder.

What is the expected behavior?

not throw this error.

Suggested solutions

@omarcostahamido Sorry about this. I believe I introduced this bug. Would you be able to try out #52 and see if that fixes the issue for you?

@danbev thank you for looking into this so quickly.
If you don't mind my newbie question: how can I try your pull request before it gets accepted and released?

@danbev ok I just followed the description of your commits and manually changes the files on my installation.
it Works! 🎉
thank you very much :)