@qiskit/devs-ibm
Advanced tools
Comparing version 0.3.0 to 0.4.0
56
index.js
/** | ||
* @license | ||
* | ||
* Copyright (c) 2017-present, IBM Research. | ||
* Copyright (c) 2017, IBM. | ||
* | ||
* This source code is licensed under the Apache license found in the | ||
* LICENSE.txt file in the root directory of this source tree. | ||
* This source code is licensed under the Apache License, Version 2.0 found in | ||
* the LICENSE.txt file in the root directory of this source tree. | ||
*/ | ||
@@ -12,10 +12,6 @@ | ||
const Cloud = require('@qiskit/cloud'); | ||
const utils = require('./lib/utils'); | ||
const genBin = require('./lib/genBin'); | ||
const { version } = require('./package'); | ||
const { backends } = require('./cfg'); | ||
const backendNames = Object.keys(backends); | ||
const dbg = utils.dbg(__filename); | ||
@@ -25,12 +21,13 @@ | ||
module.exports.random = async (token, userId, opts = {}) => { | ||
module.exports.random = async (opts = {}) => { | ||
dbg('Passed opts:', opts); | ||
if (!token || typeof token !== 'string') { | ||
throw new TypeError('The "token" parameter is mandatory (string)'); | ||
// We use opts being required to respect the qiskit-devs methods signature. | ||
if (!opts.custom || typeof opts.custom !== 'object') { | ||
throw new Error( | ||
'The "opts.custom" option is mandatory (a "@qiskit/cloud" logged instance)', | ||
); | ||
} | ||
if (!userId || typeof userId !== 'string') { | ||
throw new TypeError('The "userId" parameter is mandatory (string)'); | ||
} | ||
const cloud = opts.custom; | ||
@@ -58,10 +55,4 @@ if (opts.length) { | ||
if (opts.backend) { | ||
if (typeof opts.backend !== 'string') { | ||
throw new TypeError('A string expected in "backend" option'); | ||
} | ||
if (!utils.includes(backendNames, opts.backend.toLowerCase())) { | ||
throw new Error(`Not valid "backend", allowed: ${backendNames}`); | ||
} | ||
if (opts.backend && typeof opts.backend !== 'string') { | ||
throw new TypeError('A string expected in "backend" option'); | ||
} | ||
@@ -72,3 +63,3 @@ const backend = opts.backend || 'simulator'; | ||
return genBin(token, userId, { | ||
return genBin(cloud, { | ||
length, | ||
@@ -81,19 +72,14 @@ backend, | ||
module.exports.result = async (token, userId, jobId) => { | ||
const cloud = new Cloud(); | ||
cloud.token = token; | ||
cloud.userId = token; | ||
if (!token || typeof token !== 'string') { | ||
throw new TypeError('The "token" parameter is mandatory (string)'); | ||
module.exports.result = async (jobId, opts = {}) => { | ||
// We use opts being required to respect the qiskit-devs methods signature. | ||
if (!opts.custom || typeof opts.custom !== 'object') { | ||
throw new Error( | ||
'The "opts.custom" option is mandatory (a "@qiskit/cloud" logged instance)', | ||
); | ||
} | ||
if (!userId || typeof userId !== 'string') { | ||
throw new TypeError('The "userId" parameter is mandatory (string)'); | ||
} | ||
if (!jobId || typeof jobId !== 'string') { | ||
throw new TypeError('The "jobId" parameter is mandatory (string)'); | ||
} | ||
const cloud = opts.custom; | ||
@@ -131,3 +117,3 @@ const res = await cloud.job(jobId); | ||
// To return a value between 0 and 1 (similar to "Math.floor"). | ||
// To return a value between 0 and 1 (similar to "Math.floor") | ||
result.data = decimal / 10 ** decimal.toString().length; | ||
@@ -134,0 +120,0 @@ |
/** | ||
* @license | ||
* | ||
* Copyright (c) 2017-present, IBM Research. | ||
* Copyright (c) 2017, IBM. | ||
* | ||
* This source code is licensed under the Apache license found in the | ||
* LICENSE.txt file in the root directory of this source tree. | ||
* This source code is licensed under the Apache License, Version 2.0 found in | ||
* the LICENSE.txt file in the root directory of this source tree. | ||
*/ | ||
@@ -13,9 +13,9 @@ | ||
const utils = require('./utils'); | ||
const { name, version } = require('../package'); | ||
const { version } = require('../package'); | ||
const dbg = utils.debug(name); | ||
const dbg = utils.debug(__filename); | ||
module.exports = (neededQubits = 4) => { | ||
let circuit = | ||
`// Cirtuit generated by QISKit.js, version: ${version}\n\n` + | ||
`// Cirtuit generated by Qiskit.js, version: ${version}\n\n` + | ||
// Includes. | ||
@@ -22,0 +22,0 @@ 'include "qelib1.inc";\n\n' + |
/** | ||
* @license | ||
* | ||
* Copyright (c) 2017-present, IBM Research. | ||
* Copyright (c) 2017, IBM. | ||
* | ||
* This source code is licensed under the Apache license found in the | ||
* LICENSE.txt file in the root directory of this source tree. | ||
* This source code is licensed under the Apache License, Version 2.0 found in | ||
* the LICENSE.txt file in the root directory of this source tree. | ||
*/ | ||
@@ -13,6 +13,5 @@ | ||
const utils = require('./utils'); | ||
const { name } = require('../package'); | ||
const buildCircuit = require('./buildCircuit'); | ||
const dbg = utils.debug(name); | ||
const dbg = utils.debug(__filename); | ||
@@ -19,0 +18,0 @@ module.exports = (len = 16, backendQubits = 4) => { |
/** | ||
* @license | ||
* | ||
* Copyright (c) 2017-present, IBM Research. | ||
* Copyright (c) 2017, IBM. | ||
* | ||
* This source code is licensed under the Apache license found in the | ||
* LICENSE.txt file in the root directory of this source tree. | ||
* This source code is licensed under the Apache License, Version 2.0 found in | ||
* the LICENSE.txt file in the root directory of this source tree. | ||
*/ | ||
@@ -12,10 +12,6 @@ | ||
const Cloud = require('@qiskit/cloud'); | ||
const utils = require('./utils'); | ||
const { name } = require('../package'); | ||
const { backends } = require('../cfg'); | ||
const buildCircuits = require('./buildCircuits'); | ||
const dbg = utils.debug(name); | ||
const dbg = utils.debug(__filename); | ||
@@ -27,11 +23,7 @@ function buildParam(circuit) { | ||
// TODO: Reuse "utils.genRandom" like in the other "qiskit-devs=*" packages. | ||
module.exports = async (token, userId, opts = {}) => { | ||
module.exports = async (cloud, opts = {}) => { | ||
const len = opts.length || 16; | ||
const backend = opts.backend || 'ibmqx4'; | ||
const cloud = new Cloud(); | ||
const backendName = opts.backend || 'ibmqx4'; | ||
cloud.token = token; | ||
cloud.userId = token; | ||
const backendQubits = backends[backend].nQubits; | ||
const backendQubits = (await cloud.backend(backendName)).nQubits; | ||
const circuits = buildCircuits(len, backendQubits); | ||
@@ -38,0 +30,0 @@ const circuitsMassaged = utils.map(circuits, buildParam); |
/** | ||
* @license | ||
* | ||
* Copyright (c) 2017-present, IBM Research. | ||
* Copyright (c) 2017, IBM. | ||
* | ||
* This source code is licensed under the Apache license found in the | ||
* LICENSE.txt file in the root directory of this source tree. | ||
* This source code is licensed under the Apache License, Version 2.0 found in | ||
* the LICENSE.txt file in the root directory of this source tree. | ||
*/ | ||
@@ -9,0 +9,0 @@ |
{ | ||
"name": "@qiskit/devs-ibm", | ||
"version": "0.3.0", | ||
"description": "IBM Q engine for QISKit for developers", | ||
"version": "0.4.0", | ||
"description": "IBM Q engine for Qiskit for developers", | ||
"author": { | ||
@@ -9,13 +9,13 @@ "name": "IBM RESEARCH", | ||
}, | ||
"homepage": "https://github.com/QISKit/qiskit-sdk-js", | ||
"homepage": "https://github.com/Qiskit/qiskit-js", | ||
"contributors": [ | ||
"https://github.com/QISKit/qiskit-sdk-js/graphs/contributors" | ||
"https://github.com/Qiskit/qiskit-js/graphs/contributors" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/QISKit/qiskit-sdk-js" | ||
"url": "https://github.com/Qiskit/qiskit-js" | ||
}, | ||
"scripts": { | ||
"dep-check": "depcheck", | ||
"test": "mocha --recursive test --timeout 20000" | ||
"test": "mocha --recursive test --timeout 20000 --color" | ||
}, | ||
@@ -34,8 +34,10 @@ "keywords": [ | ||
"bugs": { | ||
"url": "https://github.com/QISKit/qiskit-sdk-js/issues" | ||
"url": "https://github.com/Qiskit/qiskit-js/issues" | ||
}, | ||
"dependencies": { | ||
"@qiskit/cloud": "^0.3.0", | ||
"@qiskit/utils": "^0.3.0" | ||
"@qiskit/utils": "^0.4.0" | ||
}, | ||
"devDependencies": { | ||
"@qiskit/cloud": "^0.4.0" | ||
}, | ||
"engines": { | ||
@@ -42,0 +44,0 @@ "node": ">=8", |
@@ -1,4 +0,4 @@ | ||
# QISKit.js algorithms (IBM Q) | ||
# Qiskit.js devs (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-devs). | ||
[IBM Q](https://www.research.ibm.com/ibm-q) engine (chip and remote simulator) for the [Qiskit devs package](https://github.com/Qiskit/qiskit-js/tree/master/packages/qiskit-devs). | ||
@@ -28,5 +28,8 @@ ## Install | ||
* 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. | ||
- As expected, the `engine` parameter is omitted here. | ||
- All algorithms need a background job, so a `jobId` is returned. | ||
- About the options: | ||
- `custom` (object): Mandatory here, it should be a logged [qiskit-cloud](../qiskit-cloud) instance. | ||
- `backend` (string): Name of the backend to use. (default: simulator) | ||
- `shots` (number): Number of times to run the circuit. (default: 1) | ||
- `maxCredits` (number): Max number of the credits to run this job. The task will be cancelled if it needs more. |
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
1
1
1
35
9521
1
7
225
+ Added@qiskit/utils@0.4.0(transitive)
- Removed@qiskit/cloud@^0.3.0
- Removed@qiskit/cloud@0.3.0(transitive)
- Removed@qiskit/utils@0.3.0(transitive)
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.15.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedrequest-promise-core@1.1.4(transitive)
- Removedrequest-promise-native@1.0.9(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedstealthy-require@1.1.1(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)
Updated@qiskit/utils@^0.4.0