Skip to content

Commit

Permalink
Merge branch 'bokeh:branch-3.6' into branch-3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulrahman305 authored Aug 17, 2024
2 parents fe7b600 + 42435cd commit 06e7c45
Show file tree
Hide file tree
Showing 156 changed files with 1,446 additions and 10,806 deletions.
54 changes: 0 additions & 54 deletions .github/workflows/bokeh-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,36 +179,6 @@ jobs:
name: examples-report
path: examples-report

integration-tests:
if: ${{ false }} # disable for now
needs: build
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Prepare Environment
uses: ./.github/workflows/composite/test-setup
with:
test-env: '3.11'
source-tree: 'delete'

- name: List installed software
run: |
conda info
conda list
echo "node $(node --version)"
echo "npm $(npm --version)"
- name: Run tests
run: pytest -v --cov=bokeh --cov-report=xml --tb=short --driver chrome --color=yes tests/integration

- name: Upload code coverage
uses: codecov/codecov-action@v4
with:
flags: integration
verbose: true

unit-test:
needs: build
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -351,27 +321,3 @@ jobs:
- name: Run tests
run: bash scripts/ci/run_downstream_tests.sh

docker_from_wheel:
if: ${{ false }} # temporarily disable
needs: build
runs-on: ubuntu-latest
env:
IMAGE_TAG: bokeh/bokeh-dev:branch-3.1

steps:
- uses: actions/checkout@v4

- name: Download wheel package
id: download
uses: actions/download-artifact@v4
with:
name: wheel-package
path: dist/

- name: Start Docker container, install Bokeh from wheel and run Python tests.
env:
BOKEH_DOCKER_FROM_WHEEL: 1
BOKEH_DOCKER_INTERACTIVE: 0
run: |
scripts/docker/docker_run.sh $IMAGE_TAG
72 changes: 0 additions & 72 deletions .github/workflows/bokeh-docker-build.yml

This file was deleted.

48 changes: 0 additions & 48 deletions .github/workflows/bokeh-docker-test.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
.sw[nop]
*.tmp
.vscode
.idea

# compressed / binary files
*.bz2
Expand Down
8 changes: 5 additions & 3 deletions bokehjs/src/lib/core/util/text.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {assert} from "./assert"
import {canvas} from "../dom"

export type BoxMetrics = {
width: number
Expand All @@ -16,8 +17,9 @@ export type FontMetrics = {
}

const _offscreen_context = (() => {
const canvas = new OffscreenCanvas(0, 0)
const ctx = canvas.getContext("2d")
// Support Firefox ESR, etc., see https://github.com/bokeh/bokeh/issues/14006.
const canvas_el = typeof OffscreenCanvas !== "undefined" ? new OffscreenCanvas(0, 0) : canvas({width: 0, height: 0})
const ctx = canvas_el.getContext("2d")
assert(ctx != null, "can't obtain 2d context")
return ctx
})()
Expand All @@ -30,7 +32,7 @@ function _font_metrics(font: string): FontMetrics {
const x_metrics = ctx.measureText("x")
const metrics = ctx.measureText("ÅŚg|")

// Support Firefox ESR, see https://github.com/bokeh/bokeh/issues/13969.
// Support Firefox ESR, etc., see https://github.com/bokeh/bokeh/issues/13969.
const ascent = typeof metrics.fontBoundingBoxAscent !== "undefined" ? metrics.fontBoundingBoxAscent : metrics.actualBoundingBoxAscent
const descent = typeof metrics.fontBoundingBoxDescent !== "undefined" ? metrics.fontBoundingBoxDescent : metrics.actualBoundingBoxDescent

Expand Down
23 changes: 20 additions & 3 deletions bokehjs/src/lib/embed/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import type {EmbedTarget} from "./dom"

// @internal
export function _get_ws_url(app_path: string | undefined, absolute_url: string | undefined): string {
let protocol = "ws:"
if (window.location.protocol == "https:") {
protocol = "wss:"
// if in an `srcdoc` iframe, try to get the absolute URL
// from the `data-absolute-url` attribute if not passed explicitly
if (absolute_url === undefined && _is_frame_HTMLElement(frameElement) && frameElement.dataset.absoluteUrl !== undefined) {
absolute_url = frameElement.dataset.absoluteUrl
}

let loc: HTMLAnchorElement | Location
Expand All @@ -21,6 +22,7 @@ export function _get_ws_url(app_path: string | undefined, absolute_url: string |
loc = window.location
}

const protocol = loc.protocol == "https:" ? "wss:" : "ws:"
if (app_path != null) {
if (app_path == "/") {
app_path = ""
Expand All @@ -32,6 +34,21 @@ export function _get_ws_url(app_path: string | undefined, absolute_url: string |
return `${protocol}//${loc.host}${app_path}/ws`
}

function _is_frame_HTMLElement(frame: Element | null): frame is HTMLIFrameElement {
// `frameElement` is a delicate construct; it allows the document inside the frame to access
// some (but not all) properties of the parent element in which the frame document is embedded.
// Because it lives in a different DOM context than the frame's `window`, we cannot just use
// `frameElement instanceof HTMLIFrameElement`; we could use `window.parent.HTMLIFrameElement`
// but this can be blocked by CORS policy and throw an exception.
if (frame === null) {
return false
}
if (frame.tagName.toUpperCase() === "IFRAME") {
return true
}
return false
}

type WebSocketURL = string
type SessionID = string

Expand Down
20 changes: 20 additions & 0 deletions bokehjs/src/lib/models/comparisons/comparison.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {Model} from "../../model"
import type * as p from "core/properties"

export namespace Comparison {
export type Attrs = p.AttrsOf<Props>

export type Props = Model.Props
}

export interface Comparison extends Comparison.Attrs {}

export abstract class Comparison extends Model {
declare properties: Comparison.Props

constructor(attrs?: Partial<Comparison.Attrs>) {
super(attrs)
}

abstract compute(x: unknown, y: unknown): -1 | 0 | 1
}
49 changes: 49 additions & 0 deletions bokehjs/src/lib/models/comparisons/customjs_compare.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import {Comparison} from "./comparison"
import type * as p from "core/properties"
import type {Dict} from "core/types"
import {keys, values} from "core/util/object"
import {use_strict} from "core/util/string"

export namespace CustomJSCompare {
export type Attrs = p.AttrsOf<Props>

export type Props = Comparison.Props & {
args: p.Property<Dict<unknown>>
code: p.Property<string>
}
}

export interface CustomJSCompare extends CustomJSCompare.Attrs {}

export class CustomJSCompare extends Comparison {
declare properties: CustomJSCompare.Props

constructor(attrs?: Partial<CustomJSCompare.Attrs>) {
super(attrs)
}

static {
this.define<CustomJSCompare.Props>(({Unknown, Str, Dict}) => ({
args: [ Dict(Unknown), {} ],
code: [ Str, "" ],
}))
}

get names(): string[] {
return keys(this.args)
}

get values(): unknown[] {
return values(this.args)
}

private _make_func(): Function {
const code = use_strict(this.code)
return new Function("x", "y", ...this.names, code)
}

compute(x: unknown, y: unknown): 0 | 1 | -1 {
const func = this._make_func()
return func(x, y, this.values)
}
}
3 changes: 3 additions & 0 deletions bokehjs/src/lib/models/comparisons/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export {Comparison} from "./comparison"
export {CustomJSCompare} from "./customjs_compare"
export {NanCompare} from "./nan_compare"
40 changes: 40 additions & 0 deletions bokehjs/src/lib/models/comparisons/nan_compare.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import {Comparison} from "./comparison"
import {isNumber} from "core/util/types"
import type * as p from "core/properties"

export namespace NanCompare {
export type Attrs = p.AttrsOf<Props>

export type Props = Comparison.Props & {
ascending_first: p.Property<boolean>
}
}

export interface NanCompare extends NanCompare.Attrs {}

export class NanCompare extends Comparison {
declare properties: NanCompare.Props

constructor(attrs?: Partial<NanCompare.Attrs>) {
super(attrs)
}

static {
this.define<NanCompare.Props>(({Bool}) => ({
ascending_first: [ Bool, false ],
}))
}

compute(x: unknown, y: unknown): 0 | 1 | -1 {
if (isNumber(x) && isNaN(x)) {
return this.ascending_first ? -1 : 1
}
if (isNumber(y) && isNaN(y)) {
return this.ascending_first ? 1 : -1
}
if (isNumber(x) && isNumber(y)) {
return x==y ? 0 : x < y ? -1 : 1
}
return 0
}
}
6 changes: 3 additions & 3 deletions bokehjs/src/lib/models/glyphs/multi_polygons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ export class MultiPolygonsView extends GlyphView {
}

protected override _mask_data(): Indices {
const {x_range, y_range} = this.renderer.plot_view.frame
const {x_source, y_source} = this.renderer.coordinates
return this.index.indices({
x0: x_range.min, x1: x_range.max,
y0: y_range.min, y1: y_range.max,
x0: x_source.min, x1: x_source.max,
y0: y_source.min, y1: y_source.max,
})
}

Expand Down
Loading

0 comments on commit 06e7c45

Please sign in to comment.