Skip to content
This repository has been archived by the owner on Sep 13, 2019. It is now read-only.

Commit

Permalink
Merge pull request #2 from Qiskit/master
Browse files Browse the repository at this point in the history
updating my fork
  • Loading branch information
omarcostahamido authored May 1, 2019
2 parents a964f84 + db3b56f commit 06aa91c
Show file tree
Hide file tree
Showing 16 changed files with 71 additions and 43 deletions.
20 changes: 19 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased]

## [0.8.0] - 2019-04-25

### 🎉 Added

- `@qiskit/qiskit-sim`: Add t gate as an alias for the r4 gate
- `@qiskit/qiskit-sim`: Add Gate as option to addGate API in README

### ✏️ Changed

- `@qiskit/qiskit-sim`: Add phaseShift util function for phase gates
- `@qiskit/qiskit-sim`: Make r2 gate use the matrix of the s gate

### 🐛 Fixed

- `@qiskit/qiskit-sim`: Use Gate.x.name for initial values

## [0.7.1] - 2019-04-23

### ✏️ Changed
Expand Down Expand Up @@ -249,7 +265,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Change in lerna setup to allow markdown files in npm.
- Travis badge in the main README file.

[unreleased]: https://github.com/Qiskit/qiskit-js/compare/v0.7.0...HEAD
[unreleased]: https://github.com/Qiskit/qiskit-js/compare/v0.8.0...HEAD
[0.8.0]: https://github.com/Qiskit/qiskit-js/compare/v0.7.1...v0.8.0
[0.7.1]: https://github.com/Qiskit/qiskit-js/compare/v0.7.0...v0.7.1
[0.7.0]: https://github.com/Qiskit/qiskit-js/compare/v0.6.2...v0.7.0
[0.6.2]: https://github.com/Qiskit/qiskit-js/compare/v0.6.1...v0.6.2
[0.6.1]: https://github.com/Qiskit/qiskit-js/compare/v0.6.0...v0.6.1
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.7.1",
"version": "0.8.0",
"lerna": "2.0.0",
"packages": [
"packages/*"
Expand Down
4 changes: 2 additions & 2 deletions packages/qiskit-cloud/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@qiskit/cloud",
"version": "0.7.0",
"version": "0.8.0",
"description": "Quantum Information Science kit to connect to the Quantum Experience",
"author": {
"name": "IBM RESEARCH",
Expand Down Expand Up @@ -32,7 +32,7 @@
"url": "https://github.com/Qiskit/qiskit-js/issues"
},
"dependencies": {
"@qiskit/utils": "^0.7.0",
"@qiskit/utils": "^0.8.0",
"request": "^2.88.0",
"request-promise-native": "^1.0.7"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/qiskit-devs-anu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@qiskit/devs-anu",
"version": "0.7.0",
"version": "0.8.0",
"description": "Australia National University engine for Qiskit for developers",
"author": {
"name": "IBM RESEARCH",
Expand Down Expand Up @@ -31,7 +31,7 @@
"url": "https://github.com/Qiskit/qiskit-js/issues"
},
"dependencies": {
"@qiskit/utils": "^0.7.0",
"@qiskit/utils": "^0.8.0",
"request-promise-native": "^1.0.7"
},
"engines": {
Expand Down
6 changes: 3 additions & 3 deletions packages/qiskit-devs-ibm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@qiskit/devs-ibm",
"version": "0.7.0",
"version": "0.8.0",
"description": "IBM Q engine for Qiskit for developers",
"author": {
"name": "IBM RESEARCH",
Expand Down Expand Up @@ -33,10 +33,10 @@
"url": "https://github.com/Qiskit/qiskit-js/issues"
},
"dependencies": {
"@qiskit/utils": "^0.7.0"
"@qiskit/utils": "^0.8.0"
},
"devDependencies": {
"@qiskit/cloud": "^0.7.0"
"@qiskit/cloud": "^0.8.0"
},
"engines": {
"node": ">=10"
Expand Down
4 changes: 2 additions & 2 deletions packages/qiskit-devs-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@qiskit/devs-js",
"version": "0.7.0",
"version": "0.8.0",
"description": "Pure JavaScript engine for Qiskit for developers",
"author": {
"name": "IBM RESEARCH",
Expand Down Expand Up @@ -32,7 +32,7 @@
"url": "https://github.com/Qiskit/qiskit-js/issues"
},
"dependencies": {
"@qiskit/utils": "^0.7.0",
"@qiskit/utils": "^0.8.0",
"jsqubits": "^1.1.0"
},
"engines": {
Expand Down
10 changes: 5 additions & 5 deletions packages/qiskit-devs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@qiskit/devs",
"version": "0.7.0",
"version": "0.8.0",
"description": "Quantum Information algorithms for developers",
"author": {
"name": "IBM RESEARCH",
Expand Down Expand Up @@ -33,10 +33,10 @@
"url": "https://github.com/Qiskit/qiskit-js/issues"
},
"dependencies": {
"@qiskit/devs-anu": "^0.7.0",
"@qiskit/devs-ibm": "^0.7.0",
"@qiskit/devs-js": "^0.7.0",
"@qiskit/utils": "^0.7.0"
"@qiskit/devs-anu": "^0.8.0",
"@qiskit/devs-ibm": "^0.8.0",
"@qiskit/devs-js": "^0.8.0",
"@qiskit/utils": "^0.8.0"
},
"engines": {
"node": ">=10"
Expand Down
4 changes: 2 additions & 2 deletions packages/qiskit-qasm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@qiskit/qasm",
"version": "0.7.0",
"version": "0.8.0",
"description": "Quantum Information Science Kit OpenQASM library",
"author": {
"name": "IBM RESEARCH",
Expand Down Expand Up @@ -34,7 +34,7 @@
"url": "https://github.com/Qiskit/qiskit-js/issues"
},
"dependencies": {
"@qiskit/utils": "^0.7.0",
"@qiskit/utils": "^0.8.0",
"jison": "^0.4.18"
},
"engines": {
Expand Down
4 changes: 2 additions & 2 deletions packages/qiskit-sim/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ Gates definition.

* `stateStr` (string) - Human friendly representation of the internal state.

### `circuit.addGate(name, column, wires)`
### `circuit.addGate(gate, column, wires)`

Add a gate to the circuit.

* `name` (string) - Name of the gate, from `gates` field.
* `gate` (Gate|string) - Gate instance or name of the gate, from `gates` field.
* `colum` (number) - Qubit to connect the gate.
* `wires` (number / [number]) - Gate connections. An array is used for multi-gates.

Expand Down
2 changes: 1 addition & 1 deletion packages/qiskit-sim/lib/Circuit.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ class Circuit {
if (initialValues) {
for (let wire = 0; wire < this.nQubits; wire += 1) {
if (initialValues[wire]) {
this.applyGate(Gate.x, [wire]);
this.applyGate(Gate.x.name, [wire]);
}
}
}
Expand Down
20 changes: 8 additions & 12 deletions packages/qiskit-sim/lib/gates.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ const buildControlled = Gate => {
return C;
};

const phaseShift = shift =>
[[1, 0], [0, math.pow(math.e, math.multiply(math.i, math.PI / shift))]];

class Gate {
constructor(name, matrix) {
this.name = name;
Expand All @@ -56,18 +59,11 @@ Gate.h = new Gate('h',
Gate.srn = new Gate('srn',
[[1 / math.sqrt(2), 0 - 1 / math.sqrt(2)],
[1 / math.sqrt(2), 1 / math.sqrt(2)]]);
Gate.s = new Gate('s',
[[1, 0],
[0, math.pow(math.e, math.multiply(math.i, math.PI / 2))]]);
Gate.r2 = new Gate('r2',
[[1, 0],
[0, math.pow(math.e, math.multiply(math.i, math.PI / 2))]]);
Gate.r4 = new Gate('r4',
[[1, 0],
[0, math.pow(math.e, math.multiply(math.i, math.PI / 4))]]);
Gate.r8 = new Gate('r8',
[[1, 0],
[0, math.pow(math.e, math.multiply(math.i, math.PI / 8))]]);
Gate.s = new Gate('s', phaseShift(2));
Gate.r2 = new Gate('r2', Gate.s.matrix);
Gate.r4 = new Gate('r4', phaseShift(4));
Gate.r8 = new Gate('r8', phaseShift(8));
Gate.t = new Gate('t', Gate.r4.matrix);
Gate.swap = new Gate('swap',
[[1, 0, 0, 0], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 1]]);
Gate.srswap = new Gate('srswap',
Expand Down
4 changes: 2 additions & 2 deletions packages/qiskit-sim/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@qiskit/sim",
"version": "0.7.1",
"version": "0.8.0",
"description": "Quantum Information Science Kit simulator",
"author": {
"name": "IBM RESEARCH",
Expand Down Expand Up @@ -35,7 +35,7 @@
"url": "https://github.com/Qiskit/qiskit-js/issues"
},
"dependencies": {
"@qiskit/utils": "^0.7.0",
"@qiskit/utils": "^0.8.0",
"mathjs": "^5.9.0"
},
"engines": {
Expand Down
10 changes: 10 additions & 0 deletions packages/qiskit-sim/test/functional/Circuit.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ describe('sim:Circuit:run', () => {
]);
});

it('should not throw Error with initial values', () => {
const c = Circuit.createCircuit(2);
c.addGate(Gate.h, 0, 0);
assert.doesNotThrow( () => {
c.run([false, true]);
},
TypeError
);
});

it('should be possible execute the same circuit twice in a row', () => {
const expectedState = [
{ re: 0.9999999999999998, im: 0 },
Expand Down
6 changes: 5 additions & 1 deletion packages/qiskit-sim/test/functional/gates.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

const assert = require('assert');

const { gates } = require('../..');
const { gates, Gate } = require('../..');

describe('sim:gates', () => {
it('should include all supported ones', () =>
Expand All @@ -26,6 +26,7 @@ describe('sim:gates', () => {
'r2',
'r4',
'r8',
't',
'swap',
'srswap',
'cx',
Expand All @@ -38,4 +39,7 @@ describe('sim:gates', () => {
'cr4',
'cr8',
]));
it('t gate should have the same unitary matrix as the r4 gate', () => {
assert.deepEqual(Gate.t.matrix, Gate.r4.matrix);
});
});
2 changes: 1 addition & 1 deletion packages/qiskit-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@qiskit/utils",
"version": "0.7.0",
"version": "0.8.0",
"description": "Quantum Information Science Kit utils library",
"author": {
"name": "IBM RESEARCH",
Expand Down
12 changes: 6 additions & 6 deletions packages/qiskit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "qiskit",
"version": "0.7.1",
"version": "0.8.0",
"description": "Quantum Information Science Kit meta-package",
"author": {
"name": "IBM RESEARCH",
Expand Down Expand Up @@ -43,11 +43,11 @@
"url": "https://github.com/Qiskit/qiskit-js/issues"
},
"dependencies": {
"@qiskit/cloud": "^0.7.0",
"@qiskit/devs": "^0.7.0",
"@qiskit/qasm": "^0.7.0",
"@qiskit/sim": "^0.7.1",
"@qiskit/utils": "^0.7.0",
"@qiskit/cloud": "^0.8.0",
"@qiskit/devs": "^0.8.0",
"@qiskit/qasm": "^0.8.0",
"@qiskit/sim": "^0.8.0",
"@qiskit/utils": "^0.8.0",
"cli-color": "^1.4.0",
"home-or-tmp": "^3.0.0",
"node-emoji": "^1.10.0",
Expand Down

0 comments on commit 06aa91c

Please sign in to comment.