feat: add warning for deduplications #3902
Open
+1,873
−1,859
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Attempt to fix #3891.
This PR now emits a warning when identical parameters are merged during concatenation to alert users to unintended linking.
With #3851, we now use a hash-based naming for parameters and views for deterministic names and thread safety, but I said in this comment #3851 (comment) that duplicate explicit names will raise an error to catch potential mistakes.
But I found that this only works for a single chart (via
add_params): hash-based duplicates are dropped; explicit duplicates raise. During concatenation (via_combine_subchart_params) all identical parameters (hash-based and explicit) are deduplicated and a warning is raised, so when using explicit names there is no raising of error.Eg. this (explicit name for interactive selection paramater, that becomes identical during concatenation):
Returns
{'config': {'view': {'continuousWidth': 300, 'continuousHeight': 300}}, 'vconcat': [{'mark': {'type': 'point'}, 'encoding': {'x': {'field': 'Horsepower', 'type': 'quantitative'}, 'y': {'field': 'Miles_per_Gallon', 'type': 'quantitative'}}, 'name': 'view_6e7cfb454e831ee6_0'}, {'mark': {'type': 'point'}, 'encoding': {'x': {'field': 'Horsepower', 'type': 'quantitative'}, 'y': {'field': 'Miles_per_Gallon', 'type': 'quantitative'}}, 'name': 'view_6e7cfb454e831ee6_1'}], 'data': {'url': 'https://cdn.jsdelivr.net/npm/[email protected]/data/cars.json'}, 'params': [{'name': 'MY_CHART', 'select': {'type': 'interval', 'encodings': ['x', 'y']}, 'bind': 'scales', 'views': ['view_6e7cfb454e831ee6_0', 'view_6e7cfb454e831ee6_1']}], '$schema': 'https://vega.github.io/schema/vega-lite/v6.1.0.json'}And this (explicit identical name for parameters):
Returns
I'm merely documenting this. I don't know what to do with it, since I'm not really sure if we can improve this situation any better.
It would be great if you could have a look to @joelostblom!