Open jonmmease opened 4 months ago
I think what's going on is that the extent
transform is including inf
in the extent range.
import json
import pandas as pd
import numpy as np
import vegafusion as vf
dataframe = pd.DataFrame({"col": [0, 1, 2, np.inf, 4]})
spec = json.loads(r"""
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"background": "white",
"padding": 5,
"width": 200,
"height": 200,
"style": "cell",
"data": [
{"name": "interval_intervalselection_0_store"},
{"name": "click_pointselection_0_store"},
{"name": "dataframe", "url": "vegafusion+dataset://dataframe"},
{
"name": "data_0",
"source": "dataframe",
"transform": [
{
"type": "extent",
"field": "col",
"signal": "layer_0_layer_0_bin_maxbins_50_col_extent"
},
{
"type": "formula",
"expr": "layer_0_layer_0_bin_maxbins_50_col_extent",
"as": "extent"
}
]
}
]
}
""")
vf.runtime.pre_transform_datasets(spec, ["data_0"], inline_datasets=dict(dataframe=dataframe))
([ col extent
0 0.0 [0.0, inf]
1 1.0 [0.0, inf]
2 2.0 [0.0, inf]
3 inf [0.0, inf]
4 4.0 [0.0, inf]],
[])
Huh, it looks like in Vega the extent transform returns [null, null]
when there are infinite values:
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"background": "white",
"padding": 5,
"width": 200,
"height": 200,
"style": "cell",
"data": [
{"name": "interval_intervalselection_0_store"},
{"name": "click_pointselection_0_store"},
{
"name": "dataframe",
"values": [
{"col": 0},
{"col": 1},
{"col": 2},
{"col": "Infinity"},
{"col": 4}]
},
{
"name": "data_0",
"source": "dataframe",
"transform": [
{
"type": "formula",
"expr": "+datum.col",
"as": "col"
},
{
"type": "extent",
"field": "col",
"signal": "layer_0_layer_0_bin_maxbins_50_col_extent"
},
{
"type": "formula",
"expr": "layer_0_layer_0_bin_maxbins_50_col_extent",
"as": "extent"
}
]
}
]
}
VegaFusion panics when computing a histogram on a column with
inf
values.