8000 Redesign "materialization" of data specs by mattpap · Pull Request #10235 · bokeh/bokeh · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits 8000
Select commit Hold shift + click to select a range
7b2c9d5
Explicitly define glyph coordinates
mattpap Jun 14, 2020
49fbf63
Add default values
mattpap Jun 26, 2020
2511c9d
Don't check for nulls in MultiLine._index_data()
mattpap Jun 26, 2020
5f03f5a
Wrap only plain object default values
mattpap Jun 26, 2020
6d12421
Make data projection explicit
mattpap Jun 26, 2020
9196019
Clean up HexTile._set_data()
mattpap Jun 26, 2020
8f3a4e0
Add support for ragged arrays
mattpap Jun 26, 2020
f267b68
Encode dimension in coordinate specs
mattpap Jun 26, 2020
1be6b51
Explicit data materialization
mattpap Jun 27, 2020
35ec95a
Update incomplete unit tests
mattpap Jun 27, 2020
e2c650c
Update graph layout providers
mattpap Jul 5, 2020
b20dfb7
Fail safe when a column is missing
mattpap Jul 5, 2020
66549c6
Use NumberArray.set() in ImageURL
mattpap Jun 24, 2020
7f79d55
Update incomplete glyph tests
mattpap Jul 5, 2020
bc46b45
Assert number arrays in corner cases
mattpap Jul 5, 2020
84a3d68
Fix glyphs' defaults
mattpap Jul 5, 2020
54d988e
Explicit defaults in {V,H}Bar glyphs
mattpap Jul 5, 2020
361686b
Respect packed colors in webgl backend
mattpap Jul 5, 2020
3569c22
Unify handling of colors and alpha
mattpap Jul 6, 2020
e059b4a
Use CoordinateSeqSeqSeqSpec for multi polygons
mattpap Jul 6, 2020
709eed9
Make toStringTag static
mattpap Jul 6, 2020
fbf4f0c
Increase pixel allowance
mattpap Jul 7, 2020
5f1c988
Respect glyph protocol in graph renderer
mattpap Jul 8, 2020
81aa324
Ignore early glyph positional defaults
mattpap Jul 9, 2020
d19f28c
Mark export selenium tests as flaky
mattpap Jul 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fail safe when a column is missing
  • Loading branch information
mattpap committed Jul 8, 2020
commit b20dfb73f6cbf63c426ebc948762c2378bc15c79
26 changes: 15 additions & 11 deletions bokehjs/src/lib/core/properties.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Signal0} from "./signaling"
import {logger} from "./logging"
import type {HasProps} from "./has_props"
import * as enums from "./enums"
import {Arrayable, NumberArray, ColorArray} from "./types"
Expand Down Expand Up @@ -368,25 +369,28 @@ export abstract class VectorSpec<T, V extends Vector<T> = Vector<T>> extends Pro
}

array(source: ColumnarDataSource): Arrayable<unknown> {
let ret: any
let array: Arrayable

const length = source.get_length() ?? 1

if (this.spec.field != null) {
ret = this.normalize(source.get_column(this.spec.field))
if (ret == null)
throw new Error(`attempted to retrieve property array for nonexistent field '${this.spec.field}'`)
const column = source.get_column(this.spec.field)
if (column != null)
array = this.normalize(column)
else {
logger.warn(`attempted to retrieve property array for nonexistent field '${this.spec.field}'`)
array = repeat(NaN, length)
}
} else if (this.spec.expr != null) {
ret = this.normalize(this.spec.expr.v_compute(source))
array = this.normalize(this.spec.expr.v_compute(source))
} else {
let length = source.get_length()
if (length == null)
length = 1
const value = this.value(false) // don't apply any spec transform
ret = repeat(value, length)
array = repeat(value, length)
}

if (this.spec.transform != null)
ret = this.spec.transform.v_compute(ret)
return ret
array = this.spec.transform.v_compute(array)
return array
}
}

Expand Down
12 changes: 5 additions & 7 deletions bokehjs/test/unit/core/properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,11 @@ describe("properties module", () => {
})

it("should throw an Error otherwise", () => {
function fn(): void {
const source = new ColumnDataSource({data: {} 600F })
const obj = new Some({number_spec: {field: "foo"}})
const prop = obj.properties.number_spec
prop.array(source)
}
expect(fn).to.throw(Error, /attempted to retrieve property array for nonexistent field 'foo'/)
const source = new ColumnDataSource({data: {bar: [1, 2, 3]}})
const obj = new Some({number_spec: {field: "foo"}})
const prop = obj.properties.number_spec
const arr = prop.array(source)
expect(arr).to.be.equal(new Float64Array([NaN, NaN, NaN]))
})

it("should apply a spec transform to a field", () => {
Expand Down
0