This repository has been archived by the owner on Sep 13, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c7d514c
commit 409fbc0
Showing
29 changed files
with
1,197 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
*.html | ||
*.png | ||
*.csv | ||
*.dat | ||
*.iml | ||
*.log | ||
*.out | ||
*.pid | ||
*.seed | ||
*.sublime-* | ||
*.swo | ||
*.swp | ||
*.tgz | ||
*.xml | ||
.DS_Store | ||
.idea | ||
.project | ||
.strong-pm | ||
coverage | ||
*.lock | ||
.vscode | ||
|
||
# Node.js | ||
node_modules | ||
npm-debug.log | ||
.jshintrc | ||
.jslintrc | ||
.editorconfig | ||
|
||
# Project stuff | ||
test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# QISKit.js algorithms (ANU) | ||
|
||
The [Australian National University](http://www.anu.edu.au) [Quantum Random Numbers Server](https://qrng.anu.edu.au) engine (chip) for the [QISKit algorithms package](https://github.com/QISKit/qiskit-sdk-js/tree/master/packages/qiskit-algos). | ||
|
||
## Install | ||
|
||
:coffee: Install [Node.js](https://nodejs.org/download) v8 and then: | ||
|
||
```sh | ||
npm i @qiskit/algos-anu | ||
``` | ||
|
||
## Use | ||
|
||
:pencil: You can visit the complete example [in this test](./test/functional/index.js). | ||
|
||
```js | ||
const algos = require('@qiskit/algos-anu'); | ||
|
||
console.log('Version'); | ||
console.log(algos.version); | ||
``` | ||
|
||
## API | ||
|
||
:eyes: Please check the [main doc](../../README.md#API). The methods signature is the same but: | ||
|
||
* As expected, the `engine` parameter is omitted here. | ||
* Only the `random` method is supported. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* @license | ||
* | ||
* Copyright (c) 2017-present, IBM Research. | ||
* | ||
* This source code is licensed under the Apache license found in the | ||
* LICENSE.txt file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const utils = require('@qiskit/utils'); | ||
|
||
const genHex = require('./lib/genHex'); | ||
const { version } = require('./package'); | ||
|
||
module.exports.version = version; | ||
|
||
module.exports.random = async opts => utils.genRandom(genHex, opts); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* @license | ||
* | ||
* Copyright (c) 2017-present, IBM Research. | ||
* | ||
* This source code is licensed under the Apache license found in the | ||
* LICENSE.txt file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const util = require('util'); | ||
|
||
const utils = require('@qiskit/utils'); | ||
const qrand = util.promisify(require('qrand').getRandomHexOctets); | ||
|
||
const { name } = require('../package'); | ||
|
||
const dbg = utils.debug(name); | ||
|
||
module.exports = async (len = 16) => { | ||
// "/2" The library expecst the number of octects and we ask for number of | ||
// hexadecimal digits (8 octets = 16 hex chars). | ||
|
||
const octects = await qrand(len / 2); | ||
dbg('Generated number (octects):', { octects, len: octects.length }); | ||
|
||
if (!octects || !utils.isArray(octects)) { | ||
throw new Error('Parsing the result (octects)'); | ||
} | ||
|
||
const strHex = octects.join(''); | ||
dbg('Random string (hex):', { strHex }); | ||
|
||
return strHex; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"name": "@qiskit/algos-anu", | ||
"version": "0.2.0", | ||
"description": "Australia National University engine for QISKit algorithms", | ||
"author": { | ||
"name": "IBM RESEARCH", | ||
"url": "http://research.ibm.com" | ||
}, | ||
"homepage": "https://github.com/QISKit/qiskit-sdk-js", | ||
"contributors": [ | ||
"https://github.com/QISKit/qiskit-sdk-js/graphs/contributors" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/QISKit/qiskit-sdk-js" | ||
}, | ||
"scripts": { | ||
"dep-check": "depcheck", | ||
"test": "mocha --recursive test --timeout 20000" | ||
}, | ||
"keywords": [ | ||
"quantum", | ||
"computing", | ||
"information", | ||
"algorithms", | ||
"random", | ||
"shor", | ||
"Australian National University" | ||
], | ||
"bugs": { | ||
"url": "https://github.com/QISKit/qiskit-sdk-js/issues" | ||
}, | ||
"dependencies": { | ||
"qrand": "^0.1.3", | ||
"@qiskit/utils": "^0.2.0" | ||
}, | ||
"engines": { | ||
"node": ">=8", | ||
"npm": ">=5" | ||
}, | ||
"license": "Apache-2.0", | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* @license | ||
* | ||
* Copyright (c) 2017-present, IBM Research. | ||
* | ||
* This source code is licensed under the Apache license found in the | ||
* LICENSE.txt file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
|
||
const utils = require('@qiskit/utils'); | ||
|
||
const algos = require('..'); | ||
const { name, version } = require('../package'); | ||
const genHex = require('../lib/genHex'); | ||
|
||
const dbg = utils.debug(`${name}:test`); | ||
|
||
describe('api', () => { | ||
it('should include all documented items', () => { | ||
assert.equal( | ||
utils.difference(['version', 'random'], Object.keys(algos)), | ||
0, | ||
); | ||
}); | ||
}); | ||
|
||
describe('version', () => { | ||
it('should be included', () => assert.equal(algos.version, version)); | ||
}); | ||
|
||
describe('random', () => { | ||
it('should return a number between 0 and 1 without options', async () => { | ||
const res = await algos.random(); | ||
dbg('Result', res); | ||
|
||
assert.ok(res >= 0); | ||
assert.ok(res <= 1); | ||
}); | ||
}); | ||
|
||
describe('genHex', () => { | ||
it('should return a hex string of the default length without options', async () => { | ||
const res = await genHex(); | ||
dbg('Result', res); | ||
|
||
assert.ok(typeof res === 'string'); | ||
assert.ok(res.length === 16); | ||
}); | ||
|
||
it('should return a hex string of the desired length if passed', async () => { | ||
const len = 8; | ||
const res = await genHex(len); | ||
dbg('Result', res); | ||
|
||
assert.ok(typeof res === 'string'); | ||
assert.ok(res.length === len); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
*.html | ||
*.png | ||
*.csv | ||
*.dat | ||
*.iml | ||
*.log | ||
*.out | ||
*.pid | ||
*.seed | ||
*.sublime-* | ||
*.swo | ||
*.swp | ||
*.tgz | ||
*.xml | ||
.DS_Store | ||
.idea | ||
.project | ||
.strong-pm | ||
coverage | ||
*.lock | ||
.vscode | ||
|
||
# Node.js | ||
node_modules | ||
npm-debug.log | ||
.jshintrc | ||
.jslintrc | ||
.editorconfig | ||
|
||
# Project stuff | ||
test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# QISKit.js algorithms (IBM Q) | ||
|
||
[IBM Q](https://www.research.ibm.com/ibm-q) engine (chip and remote simulator) for the [QISKit algorithms package](https://github.com/QISKit/qiskit-sdk-js/tree/master/packages/qiskit-algos). | ||
|
||
## Install | ||
|
||
:coffee: Install [Node.js](https://nodejs.org/download) v8 and then: | ||
|
||
```sh | ||
npm i @qiskit/algos-ibm | ||
``` | ||
|
||
## Use | ||
|
||
:pencil: You can visit the complete example [in this test](./test/functional/index.js). | ||
|
||
```js | ||
const algos = require('@qiskit/algos-ibm'); | ||
|
||
console.log('Version'); | ||
console.log(algos.version); | ||
``` | ||
|
||
## API | ||
|
||
:eyes: Please check the [main doc](../../README.md#API). The method signature is the same but: | ||
|
||
* As expected, the `engine` parameter is omitted here. | ||
* All algorithms need a background job, so a `jobId` is returned. | ||
* The `token` parameter is mandatory. Provided by the `login` method of the [qiskit-cloud](../qiskit-cloud) package. | ||
* An extra one `userId` is also needed, same that for the last option. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"backends": { | ||
"simulator": { | ||
"nQubits": 5 | ||
}, | ||
"ibmqx2": { | ||
"nQubits": 5 | ||
}, | ||
"ibmqx4": { | ||
"nQubits": 5 | ||
}, | ||
"ibmqx5": { | ||
"nQubits": 16 | ||
}, | ||
"qs1_1": { | ||
"nQubits": 20 | ||
} | ||
} | ||
} |
Oops, something went wrong.