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 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)
kleavor added 2 commits Nov 6, 2019
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 added 2 commits Nov 8, 2019
@philippjfr

This comment has been minimized.

Copy link
Contributor

philippjfr commented Nov 8, 2019

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

@philippjfr philippjfr merged commit 9bb2499 into pyviz:master Nov 8, 2019
1 of 2 checks passed
1 of 2 checks passed
continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.