当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript services.Kernel类代码示例

本文整理汇总了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();
 });
开发者ID:afshin,项目名称:jupyterlab,代码行数:7,代码来源:kernel.spec.ts

示例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);
 });
开发者ID:afshin,项目名称:jupyterlab,代码行数:9,代码来源:ikernel.spec.ts

示例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);
  });
}
开发者ID:cameronoelsen,项目名称:jupyterlab,代码行数:32,代码来源:index.ts

示例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 });
    });
});
开发者ID:cameronoelsen,项目名称:ipywidgets,代码行数:33,代码来源:index.ts


注:本文中的@jupyterlab/services.Kernel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。