本文整理汇总了TypeScript中@jupyterlab/services.Kernel.startNew方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Kernel.startNew方法的具体用法?TypeScript Kernel.startNew怎么用?TypeScript Kernel.startNew使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@jupyterlab/services.Kernel
的用法示例。
在下文中一共展示了Kernel.startNew方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should test whether the kernel is ready', async () => {
const kernel = await Kernel.startNew();
expect(kernel.isReady).to.equal(false);
await kernel.ready;
expect(kernel.isReady).to.equal(true);
await kernel.shutdown();
});
示例2: it
it('should accept server settings', async () => {
const serverSettings = makeSettings();
const kernel = await Kernel.startNew({ serverSettings });
const response = await Kernel.listRunning(serverSettings);
expect(toArray(response).length).to.be.greaterThan(0);
await kernel.shutdown();
});
示例3: main
function main() {
let renderMime: RenderMime;
let model: OutputAreaModel;
let outputAreaOptions: OutputArea.IOptions;
let outputArea: OutputArea;
let testcode = [
'import numpy as np',
'import matplotlib.pyplot as plt',
'%matplotlib inline',
'x = np.linspace(-10,10)',
'y = x**2',
'print(x)',
'print(y)',
'plt.plot(x, y)'
].join('\n');
model = new OutputAreaModel();
renderMime = new RenderMime({ initialFactories: defaultRendererFactories });
outputAreaOptions = {
model: model,
rendermime: renderMime
};
outputArea = new OutputArea(outputAreaOptions);
Kernel.startNew().then(kernel => {
outputArea.future = kernel.requestExecute({ code: testcode });
document.getElementById('outputarea').appendChild(outputArea.node);
});
}
示例4: beforeEach
beforeEach((done) => {
Kernel.startNew().then(k => {
kernel = k;
return kernel.ready;
}).then(() => {
done();
}).catch(done);
});
示例5: it
it('should accept the id of the new kernel', async () => {
session = await startNew();
const previous = session.kernel;
await previous.ready;
const kernel = await Kernel.startNew();
await kernel.ready;
await session.changeKernel({ id: kernel.id });
await session.kernel.ready;
expect(session.kernel.id).to.equal(kernel.id);
expect(session.kernel).to.not.equal(previous);
expect(session.kernel).to.not.equal(kernel);
previous.dispose();
kernel.dispose();
});
示例6: main
function main() {
const code = [
'import numpy as np',
'import matplotlib.pyplot as plt',
'%matplotlib inline',
'x = np.linspace(-10,10)',
'y = x**2',
'print(x)',
'print(y)',
'plt.plot(x, y)'
].join('\n');
const model = new OutputAreaModel();
const rendermime = new RenderMimeRegistry({ initialFactories });
const outputArea = new OutputArea({ model, rendermime });
Kernel.startNew().then(kernel => {
outputArea.future = kernel.requestExecute({ code });
document.getElementById('outputarea').appendChild(outputArea.node);
});
}