Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define Comparator equality functions for more types #902

Open
philippjfr opened this issue Jan 11, 2024 · 1 comment
Open

Define Comparator equality functions for more types #902

philippjfr opened this issue Jan 11, 2024 · 1 comment
Labels
good first issue Guidance available, not on critical path, help welcome :) type-feature Feature request

Comments

@philippjfr
Copy link
Member

The Comparator in Param is used to check if a Parameter value has changed and therefore needs to trigger all watchers to inform them of this change. The Comparator was designed to be extended to support different object types and should cover at least the basic types that Param supports. There is also a tradeoff though, if a comparison is more expensive than the computations that could be triggered by the parameter value change then it's not worth it. For that reason we initially did not implement comparisons for things like arrays, however we should consider implementing some kind of size based cut-off where the comparator just gives up.

Here's a list of objects that we should definitely implement comparisons for:

  • pathlib.Path

and here's some objects that we should at least consider:

  • np.ndarray
  • pd.Series
  • pd.DataFrame

There's probably many I've missed.

@philippjfr philippjfr added type-feature Feature request TRIAGE User-submitted issue that hasn't been triaged yet. good first issue Guidance available, not on critical path, help welcome :) and removed TRIAGE User-submitted issue that hasn't been triaged yet. labels Jan 11, 2024
@bertcoerver
Copy link

Hi, for my own purposes I added a "custom" equality function for pd.Dataframe like this:

import param.parameterized
param.parameterized.Comparator.equalities.update(
    {pd.DataFrame: lambda obj1, obj2: obj1.equals(obj2)}
    )

More info here:
https://discourse.holoviz.org/t/param-watch-and-onlychanged-true-unexpected-behaviour-on-param-dataframe/6871

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Guidance available, not on critical path, help welcome :) type-feature Feature request
Projects
None yet
Development

No branches or pull requests

2 participants