Thanks to visit codestin.com
Credit goes to github.com

Skip to content

SolaraViz: Improve Portrayal API #2923

@EwoutH

Description

@EwoutH

However, I'm wondering if we should consider improving this API in a follow-up. The current design feels a bit awkward:

  • Simple cases require writing a function wrapper that always returns the same object
  • The function --> class pattern isn't the most intuitive

Right now users must write:

def propertylayer_portrayal(layer):
    return PropertyLayerStyle(colormap="viridis", colorbar=True)

Where the function wrapper adds no value when the style is uniform across all layers.

What if we allowed the visualization to accept either:

  1. A PropertyLayerStyle instance directly (for simple uniform styling)
  2. A callable function (for conditional/per-layer styling)

Similar to how Python's sorted() accepts both key=str.lower and key=lambda x: complex_logic(x).

Originally posted by @EwoutH in #2912 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions