當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript array.difference函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。