Skip to content

Resolve custom-labelled dimensions by name in GeoPandasInterface#843

Open
gaoflow wants to merge 1 commit into
holoviz:mainfrom
gaoflow:fix/840-resolve-custom-label-dim
Open

Resolve custom-labelled dimensions by name in GeoPandasInterface#843
gaoflow wants to merge 1 commit into
holoviz:mainfrom
gaoflow:fix/840-resolve-custom-label-dim

Conversation

@gaoflow

@gaoflow gaoflow commented Jun 9, 2026

Copy link
Copy Markdown

Fixes #840.

A dim('status') expression builds a Dimension whose label is the column name. Dimension.__eq__ compares labels, so when the element declares that dimension with a custom label — vdims=[('status', 'Conservation Status')]dataset.get_dimension(dim) returns None, and GeoPandasInterface.isscalar crashes with AttributeError: 'NoneType' object has no attribute 'name' during bokeh range computation. values and range fail the same way with the same probe.

This adds a _resolve_dimension helper that falls back to looking the dimension up by name — the string lookup path already matches both names and labels via its name_map — and uses it in isscalar, range and values. Also drops a leftover duplicate get_dimension call in isscalar.

The regression test covers the three interface methods plus the render path from the issue.

gdf = gpd.GeoDataFrame({'status': ['safe', 'endangered', 'safe'],
                        'geometry': [Point(0,0), Point(1,1), Point(2,2)]}, crs='EPSG:4326')
points = gv.Points(gdf, vdims=[('status', 'Conservation Status')])
points.opts(color=dim('status').categorize({'safe': 'green', 'endangered': 'red'}))
hv.render(points)  # AttributeError before, renders after

A dim() expression referencing a column builds a Dimension whose label
is the column name. Dimension equality compares labels, so
get_dimension() returned None when the element declared that dimension
with a custom label, and isscalar/values/range crashed with
AttributeError: 'NoneType' object has no attribute 'name' during
rendering.

Fall back to looking the dimension up by name, which matches names and
labels, mirroring the string lookup path.

Fixes holoviz#840
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttributeError in GeoPandasInterface.isscalar when a vdim has a custom label and a dim() expression references it by column name

1 participant