New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@qiskit/devs-ibm

Package Overview
Dependencies
Maintainers
5
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@qiskit/devs-ibm - npm Package Compare versions

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.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc