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

Correct GridSpec override behavior #748

Merged
merged 5 commits into from
Nov 8, 2019

Conversation

kleavor
Copy link
Contributor

@kleavor kleavor commented Nov 6, 2019

Closes #514 .

Removed the 'warn' mode to keep only 'error' and 'override'.
'override' behavior now correctly removes the pre-existing Panel.

WIP since the object deletion feels like a kludge and an additional latent bug was noticed during 'error' behavior resulting from line 937-945.

https://github.com/kleavor/panel/blob/a5dff2e30cc08eee713d18ff6ac06d2f20e65c25/panel/layout.py#L937-L945

The if-statement on overlap only evaluates to true if the location of the new Panel object exactly matches the location of the conflicting Panel object. In the case of the example provided in the Issue, neither of the new panels matches the "Initial" Panel exactly, and the new object is still added despite erroring, since the error is not raised until the end of the method.

Behavior can be observed in a notebook with the following cells

pn.extension()
gs = pn.GridSpec(mode='error')
gs[0:2, 0] = pn.widgets.MultiSelect(options=[0, 1, 2, 3], name='Initial')
display(gs.objects)
gs

The following cell will raise an Exception.

gs[0:1, 0] = pn.widgets.MultiSelect(options=[5, 6, 7], name='Second')
gs[1:2, 0] = pn.widgets.MultiSelect(options=[9, 10, 11], name='Third')
display(gs.objects)

This cell will show that the state of the gs object now still contains the MultiSelect object despite erroring.

print(gs)

Removed the 'warn' mode to keep only 'error' and 'override'.
'override' behavior now correctly removes the pre-existing Panel.
panel/layout.py Outdated Show resolved Hide resolved
@philippjfr philippjfr changed the title WIP: Correct GridSpec override behavior Correct GridSpec override behavior Nov 8, 2019
@philippjfr
Copy link
Member

Thanks for helping out @kleavor! I hope you don't mind I fixed up the PR.

@philippjfr philippjfr merged commit 9bb2499 into holoviz:master Nov 8, 2019
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.

Gridspec, dynamically updating results in overlap
2 participants