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

TypeScript array.difference函数代码示例

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

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



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

示例1: it

  it("match between Python and bokehjs", () => {
    let fail_count = 0
    const all_view_model_names = concat([core_defaults.all_view_model_names(), widget_defaults.all_view_model_names()])
    for (const name of all_view_model_names) {
      const model = Models(name)
      const instance = new model({}, {silent: true, defer_initialization: true})
      const attrs = instance.attributes_as_json(true, deep_value_to_json)
      strip_ids(attrs)

      const python_defaults = get_defaults(name)
      const bokehjs_defaults = attrs
      if (!check_matching_defaults(name, python_defaults, bokehjs_defaults)) {
        console.log(name)
        // console.log('python defaults:')
        // console.log(python_defaults)
        // console.log('bokehjs defaults:')
        // console.log(bokehjs_defaults)
        console.log(difference(keys(python_defaults), keys(bokehjs_defaults)))
        fail_count += 1
      }
    }

    console.error(`Python/bokehjs matching defaults problems: ${fail_count}`)
    expect(fail_count).to.equal(0)
  })
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:25,代码来源:defaults.ts


示例2: build_levels

  build_levels(): void {
    const renderer_models = this.model.plot.all_renderers

    // should only bind events on NEW views
    const old_renderers = keys(this.renderer_views)
    const new_renderer_views = build_views(this.renderer_views, renderer_models, this.view_options()) as RendererView[]
    const renderers_to_remove = difference(old_renderers, renderer_models.map((model) => model.id))

    for (const id_ of renderers_to_remove) {
      delete this.levels.glyph[id_]
    }

    for (const view of new_renderer_views) {
      this.levels[view.model.level][view.model.id] = view
    }
  }
开发者ID:keyurspatel,项目名称:bokeh,代码行数:16,代码来源:plot_canvas.ts


示例3: build_levels

  build_levels() {
    const renderer_models = this.model.plot.all_renderers;

    // should only bind events on NEW views
    const old_renderers = Object.keys(this.renderer_views);
    const new_renderer_views = build_views(this.renderer_views, renderer_models, this.view_options());
    const renderers_to_remove = difference(old_renderers, renderer_models.map((model) => model.id))

    for (const id_ of renderers_to_remove) {
      delete this.levels.glyph[id_];
    }

    for (const view of new_renderer_views) {
      this.levels[view.model.level][view.model.id] = view;
    }

    return this;
  }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:18,代码来源:plot_canvas.ts


示例4: render

  render() {
    let dtrender, dtselect, glyph, nonselection_glyph, selection_glyph, trender;
    if (!this.model.visible) {
      return;
    }

    const t0 = Date.now();

    const glsupport = this.glyph.glglyph;

    this.glyph.map_data();
    const dtmap = Date.now() - t0;

    const tmask = Date.now();
    // all_indices is in full data space, indices is converted to subset space
    // either by mask_data (that uses the spatial index) or manually
    let indices = this.glyph.mask_data(this.all_indices);
    if (indices.length === this.all_indices.length) {
      indices = range(0, this.all_indices.length);
    }
    const dtmask = Date.now() - tmask;

    const { ctx } = this.plot_view.canvas_view;
    ctx.save();

    // selected is in full set space
    const {selected: _selected} = this.model.data_source;
    let selected: number[]
    if (!_selected || (_selected.length === 0)) {
      selected = [];
    } else {
      if (_selected['0d'].glyph) {
        selected = this.model.view.convert_indices_from_subset(indices);
      } else if (_selected['1d'].indices.length > 0) {
        selected = _selected['1d'].indices;
      } else {
        selected = ((() => {
          const result = [];
          for (const i of Object.keys(_selected["2d"].indices)) {
            result.push(parseInt(i));
          }
          return result;
        })());
      }
    }

    // inspected is in full set space
    let { inspected } = this.model.data_source;
    if (!inspected || (inspected.length === 0)) {
      inspected = [];
    } else {
      if (inspected['0d'].glyph) {
        inspected = this.model.view.convert_indices_from_subset(indices);
      } else if (inspected['1d'].indices.length > 0) {
        inspected = inspected['1d'].indices;
      } else {
        inspected = ((() => {
          const result = [];
          for (const i of Object.keys(inspected["2d"].indices)) {
            result.push(parseInt(i));
          }
          return result;
        })());
      }
    }

    // inspected is transformed to subset space
    inspected = ((() => {
      const result = [];
      for (const i of indices) {
        if (includes(inspected, this.all_indices[i])) {
          result.push(i);
        }
      }
      return result;
    })());

    const { lod_threshold } = this.plot_model.plot;
    if (((this.model.document != null ? this.model.document.interactive_duration() : undefined) > 0) && !glsupport && (lod_threshold != null) && (this.all_indices.length > lod_threshold)) {
      // Render decimated during interaction if too many elements and not using GL
      indices = this.decimated;
      glyph = this.decimated_glyph;
      nonselection_glyph = this.decimated_glyph;
      ({ selection_glyph } = this);
    } else {
      glyph = this.model.muted && (this.muted_glyph != null) ? this.muted_glyph : this.glyph;
      ({ nonselection_glyph } = this);
      ({ selection_glyph } = this);
    }

    if ((this.hover_glyph != null) && inspected.length) {
      indices = difference(indices, inspected);
    }

    if (!(selected.length && this.have_selection_glyphs())) {
        trender = Date.now();
        if (this.glyph instanceof LineView) {
          if (this.hover_glyph && inspected.length) {
            this.hover_glyph.render(ctx, this.model.view.convert_indices_from_subset(inspected), this.glyph);
          } else {
//.........这里部分代码省略.........
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:101,代码来源:glyph_renderer.ts


示例5: render

  render(): void {
    if (!this.model.visible)
      return

    const t0 = Date.now()

    const glsupport = this.glyph.glglyph

    this.glyph.map_data()
    const dtmap = Date.now() - t0

    const tmask = Date.now()
    // all_indices is in full data space, indices is converted to subset space
    // either by mask_data (that uses the spatial index) or manually
    let indices = this.glyph.mask_data(this.all_indices)
    if (indices.length === this.all_indices.length) {
      indices = range(0, this.all_indices.length)
    }
    const dtmask = Date.now() - tmask

    const {ctx} = this.plot_view.canvas_view
    ctx.save()

    // selected is in full set space
    const {selected} = this.model.data_source
    let selected_full_indices: number[]
    if (!selected || selected.is_empty()) {
      selected_full_indices = []
    } else {
      if (this.glyph instanceof LineView && selected.selected_glyph === this.glyph.model) {
        selected_full_indices = this.model.view.convert_indices_from_subset(indices)
      } else {
        selected_full_indices = selected.indices
      }
    }

    // inspected is in full set space
    const {inspected} = this.model.data_source
    let inspected_full_indices: number[]
    if (!inspected || (inspected.length === 0)) {
      inspected_full_indices = []
    } else {
      if (inspected['0d'].glyph) {
        inspected_full_indices = this.model.view.convert_indices_from_subset(indices)
      } else if (inspected['1d'].indices.length > 0) {
        inspected_full_indices = inspected['1d'].indices
      } else {
        inspected_full_indices = ((() => {
          const result = []
          for (const i of Object.keys(inspected["2d"].indices)) {
            result.push(parseInt(i))
          }
          return result
        })())
      }
    }

    // inspected is transformed to subset space
    const inspected_subset_indices: number[] = ((() => {
      const result = []
      for (const i of indices) {
        if (includes(inspected_full_indices, this.all_indices[i]))
          result.push(i)
      }
      return result
    })())

    const {lod_threshold} = this.plot_model
    let glyph: GlyphView
    let nonselection_glyph: GlyphView
    let selection_glyph: GlyphView
    if ((this.model.document != null ? this.model.document.interactive_duration() > 0 : false)
        && !glsupport && lod_threshold != null && this.all_indices.length > lod_threshold) {
      // Render decimated during interaction if too many elements and not using GL
      indices = this.decimated
      glyph = this.decimated_glyph
      nonselection_glyph = this.decimated_glyph
      selection_glyph = this.selection_glyph
    } else {
      glyph = this.model.muted && this.muted_glyph != null ? this.muted_glyph : this.glyph
      nonselection_glyph = this.nonselection_glyph
      selection_glyph = this.selection_glyph
    }

    if (this.hover_glyph != null && inspected_subset_indices.length)
      indices = difference(indices, inspected_subset_indices)

    // Render with no selection
    let dtselect: number | null = null
    let trender: number
    if (!(selected_full_indices.length && this.have_selection_glyphs())) {
      trender = Date.now()
      if (this.glyph instanceof LineView) {
        if (this.hover_glyph && inspected_subset_indices.length)
          this.hover_glyph.render(ctx, this.model.view.convert_indices_from_subset(inspected_subset_indices), this.glyph)
        else
          glyph.render(ctx, this.all_indices, this.glyph)
      } else {
        glyph.render(ctx, indices, this.glyph)
        if (this.hover_glyph && inspected_subset_indices.length)
//.........这里部分代码省略.........
开发者ID:jsignell,项目名称:bokeh,代码行数:101,代码来源:glyph_renderer.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript array.every函数代码示例发布时间:2022-05-24
下一篇:
TypeScript array.copy函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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