本文整理匯總了TypeScript中@jupyterlab/services.Kernel類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Kernel類的具體用法?TypeScript Kernel怎麽用?TypeScript Kernel使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Kernel類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: 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();
});
示例2: it
it('should dispose of all kernel instances', async () => {
const kernel0 = await Kernel.startNew();
const kernel1 = Kernel.connectTo(kernel0.model);
await kernel0.ready;
await kernel1.ready;
await kernel0.shutdown();
expect(kernel0.isDisposed).to.equal(true);
expect(kernel1.isDisposed).to.equal(true);
});
示例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: function
document.addEventListener("DOMContentLoaded", function(event) {
// Connect to the notebook webserver.
let connectionInfo = {
baseUrl: BASEURL,
wsUrl: WSURL
};
Kernel.getSpecs(connectionInfo).then(kernelSpecs => {
(connectionInfo as any).name = kernelSpecs.default;
return Kernel.startNew(connectionInfo);
}).then(kernel => {
// Create a codemirror instance
let code = require('../widget_code.json').join("\n");
let inputarea = document.getElementsByClassName("inputarea")[0] as HTMLElement;
let editor = CodeMirror(inputarea, {
value: code,
mode: "python",
tabSize: 4,
showCursorWhenSelecting: true,
viewportMargin: Infinity,
readOnly: true
});
// Create the widget area and widget manager
let widgetarea = document.getElementsByClassName("widgetarea")[0];
let manager = new WidgetManager(kernel, widgetarea);
// Run backend code to create the widgets. You could also create the
// widgets in the frontend, like the other widget examples demonstrate.
kernel.execute({ code: code });
});
});