• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript jupyter-js-services.IKernel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中jupyter-js-services.IKernel的典型用法代码示例。如果您正苦于以下问题:TypeScript IKernel类的具体用法?TypeScript IKernel怎么用?TypeScript IKernel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了IKernel类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: updateKernelNameItem

/**
 * Update the text of the kernel name item.
 */
function updateKernelNameItem(widget: Widget, kernel: IKernel): void {
  widget.node.textContent = 'No Kernel!';
  if (!kernel) {
    return;
  }
  if (kernel.spec) {
    widget.node.textContent = kernel.spec.display_name;
  } else {
    kernel.getKernelSpec().then(spec => {
      widget.node.textContent = kernel.spec.display_name;
    });
  }
}
开发者ID:matt-bowers,项目名称:jupyterlab,代码行数:16,代码来源:kernel.ts


示例2: describe

    describe('#execute()', () => {

      let kernel: IKernel;

      beforeEach((done) => {
        Kernel.startNew().then(k => {
          kernel = k;
          return kernel.kernelInfo();
        }).then(() => {
          done();
        }).catch(done);
      });

      it('should execute code on a kernel and send outputs to the model', (done) => {
        let model = new OutputAreaModel();
        expect(model.length).to.be(0);
        model.execute('print("hello")', kernel).then(reply => {
          expect(reply.content.execution_count).to.be(1);
          expect(reply.content.status).to.be('ok');
          expect(model.length).to.be(1);
          kernel.shutdown();
          done();
        }).catch(done);
      });

      it('should clear existing outputs', (done) => {
        let model = new OutputAreaModel();
        for (let output of DEFAULT_OUTPUTS) {
          model.add(output);
        }
        return model.execute('print("hello")', kernel).then(reply => {
          expect(reply.content.execution_count).to.be(1);
          expect(model.length).to.be(1);
          kernel.shutdown();
          done();
        }).catch(done);
      });

    });
开发者ID:aggFTW,项目名称:jupyterlab,代码行数:39,代码来源:model.spec.ts


示例3: describe

describe('console/history', () => {

  let kernel: IKernel;

  beforeEach((done) => {
    kernelPromise.then(k => {
      kernel = k;
      done();
    });
  });

  after(() => {
    kernel.shutdown();
  });

  describe('ConsoleHistory', () => {

    describe('#constructor()', () => {

      it('should create a new console history object', () => {
        let history = new ConsoleHistory();
        expect(history).to.be.a(ConsoleHistory);
      });

      it('should accept an options argument', () => {
        let history = new ConsoleHistory({ kernel });
        expect(history).to.be.a(ConsoleHistory);
      });

    });

    describe('#isDisposed', () => {

      it('should get whether the object is disposed', () => {
        let history = new ConsoleHistory();
        expect(history.isDisposed).to.be(false);
        history.dispose();
        expect(history.isDisposed).to.be(true);
      });

    });

    describe('#kernel', () => {

      it('should return the kernel that was passed in', () => {
        let history = new ConsoleHistory({ kernel });
        expect(history.kernel).to.be(kernel);
      });

      it('should be settable', () => {
        let history = new ConsoleHistory();
        expect(history.kernel).to.be(null);
        history.kernel = kernel;
        expect(history.kernel).to.be(kernel);
        history.kernel = null;
        expect(history.kernel).to.be(null);
      });

      it('should be safe to set multiple times', () => {
        let history = new ConsoleHistory();
        history.kernel = kernel;
        history.kernel = kernel;
        expect(history.kernel).to.be(kernel);
      });

    });

    describe('#dispose()', () => {

      it('should dispose the history object', () => {
        let history = new ConsoleHistory();
        expect(history.isDisposed).to.be(false);
        history.dispose();
        expect(history.isDisposed).to.be(true);
      });

      it('should be safe to dispose multiple times', () => {
        let history = new ConsoleHistory();
        expect(history.isDisposed).to.be(false);
        history.dispose();
        history.dispose();
        expect(history.isDisposed).to.be(true);
      });

    });

    describe('#back()', () => {

      it('should return void promise if no history exists', (done) => {
        let history = new ConsoleHistory();
        history.back('').then(result => {
          expect(result).to.be(void 0);
          done();
        });
      });

      it('should return previous items if they exist', (done) => {
        let history = new TestHistory({ kernel });
        history.onHistory(mockHistory);
        history.back('').then(result => {
//.........这里部分代码省略.........
开发者ID:aggFTW,项目名称:jupyterlab,代码行数:101,代码来源:history.spec.ts


示例4: describe

  describe('NotebookActions', () => {

    let widget: Notebook;
    let kernel: IKernel;

    beforeEach(() => {
      widget = new Notebook({ rendermime: defaultRenderMime() });
      let model = new NotebookModel();
      model.fromJSON(DEFAULT_CONTENT);
      widget.model = model;

      kernel = new MockKernel({ name: 'python' });
      widget.activeCellIndex = 0;
    });

    afterEach(() => {
      widget.dispose();
      kernel.dispose();
      clipboard.clear();
    });

    describe('#splitCell()', () => {

      it('should split the active cell into two cells', () => {
        let cell = widget.activeCell;
        let source = 'thisisasamplestringwithnospaces';
        cell.model.source = source;
        let index = widget.activeCellIndex;
        cell.editor.setCursorPosition(10);
        NotebookActions.splitCell(widget);
        let cells = widget.model.cells;
        let newSource = cells.get(index).source + cells.get(index + 1).source;
        expect(newSource).to.be(source);
      });

      it('should remove leading white space in the second cell', () => {
        let cell = widget.activeCell;
        let source = 'this\n\n   is a test';
        cell.model.source = source;
        cell.editor.setCursorPosition(4);
        NotebookActions.splitCell(widget);
        expect(widget.activeCell.model.source).to.be('is a test');
      });

      it('should clear the existing selection', () => {
        for (let i = 0; i < widget.childCount(); i++) {
          widget.select(widget.childAt(i));
        }
        NotebookActions.splitCell(widget);
        for (let i = 0; i < widget.childCount(); i++) {
          if (i === widget.activeCellIndex) {
            continue;
          }
          expect(widget.isSelected(widget.childAt(i))).to.be(false);
        }
      });

      it('should activate the second cell', () => {
        NotebookActions.splitCell(widget);
        expect(widget.activeCellIndex).to.be(1);
      });

      it('should preserve the types of each cell', () => {
        NotebookActions.changeCellType(widget, 'markdown');
        NotebookActions.splitCell(widget);
        expect(widget.activeCell).to.be.a(MarkdownCellWidget);
        let prev = widget.childAt(0);
        expect(prev).to.be.a(MarkdownCellWidget);
      });

      it('should create two empty cells if there is no content', () => {
        widget.activeCell.model.source = '';
        NotebookActions.splitCell(widget);
        expect(widget.activeCell.model.source).to.be('');
        let prev = widget.childAt(0);
        expect(prev.model.source).to.be('');
      });

      it('should be a no-op if there is no model', () => {
        widget.model = null;
        NotebookActions.splitCell(widget);
        expect(widget.activeCell).to.be(void 0);
      });

      it('should preserve the widget mode', () => {
        NotebookActions.splitCell(widget);
        expect(widget.mode).to.be('command');
        widget.mode = 'edit';
        NotebookActions.splitCell(widget);
        expect(widget.mode).to.be('edit');
      });

      it('should be undo-able', () => {
        let source = widget.activeCell.model.source;
        let count = widget.childCount();
        NotebookActions.splitCell(widget);
        NotebookActions.undo(widget);
        expect(widget.childCount()).to.be(count);
        let cell = widget.childAt(0);
        expect(cell.model.source).to.be(source);
//.........这里部分代码省略.........
开发者ID:akshaydixi,项目名称:jupyterlab,代码行数:101,代码来源:actions.spec.ts


示例5: expect

 model.execute('print("hello")', kernel).then(reply => {
   expect(reply.content.execution_count).to.be(1);
   expect(reply.content.status).to.be('ok');
   expect(model.length).to.be(1);
   kernel.shutdown();
   done();
 }).catch(done);
开发者ID:aggFTW,项目名称:jupyterlab,代码行数:7,代码来源:model.spec.ts


示例6:

 }).then(result => {
   if (result.text === 'OK') {
     return kernel.restart().then(() => { return true; });
   } else {
     return false;
   }
 });
开发者ID:ChinaQuants,项目名称:jupyterlab,代码行数:7,代码来源:kernelactions.ts


示例7: after

 after(() => {
   kernel.shutdown();
 });
开发者ID:aggFTW,项目名称:jupyterlab,代码行数:3,代码来源:history.spec.ts


示例8: afterEach

 afterEach(() => {
   widget.dispose();
   kernel.dispose();
   clipboard.clear();
 });
开发者ID:akshaydixi,项目名称:jupyterlab,代码行数:5,代码来源:actions.spec.ts


示例9:

 Kernel.startNew().then(k => {
   kernel = k;
   return kernel.kernelInfo();
 }).then(() => {
开发者ID:aggFTW,项目名称:jupyterlab,代码行数:4,代码来源:model.spec.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap