E52D Fix patching a table with a DataFrame with a custom index by maximlt · Pull Request #5645 · holoviz/panel · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@maximlt
Copy link
Member
@maximlt maximlt commented Oct 16, 2023

Fixes #5554

@codecov
Copy link
codecov bot commented Oct 16, 2023

Codecov Report

Merging #5645 (159c0d1) into main (db1e9fe) will decrease coverage by 0.05%.
Report is 2 commits behind head on main.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #5645      +/-   ##
==========================================
- Coverage   83.65%   83.60%   -0.05%     
==========================================
  Files         280      280              
  Lines       41580    41635      +55     
==========================================
+ Hits        34782    34811      +29     
- Misses       6798     6824      +26     
Flag Coverage Δ
ui-tests 39.55% <29.50%> (-0.03%) ⬇️
unitexamples-tests 73.68% <100.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
panel/tests/widgets/test_tables.py 99.79% <100.00%> (+0.01%) ⬆️
panel/widgets/tables.py 88.86% <100.00%> (+0.08%) ⬆️

... and 7 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@maximlt
Copy link
Member Author
maximlt commented Oct 16, 2023

The examples tests are failing on the reference/widgets/DataFrame.ipynb notebook. .patch is exerted in this notebook in the following way:

import pandas as pd
import panel as pn

pn.extension()

df = pd.DataFrame({'int': [1, 2, 3], 'float': [3.14, 6.28, 9.42], 'str': ['A', 'B', 'C'], 'bool': [True, False, True]}, index=[1, 2, 3])
table = pn.widgets.DataFrame(df)
table.patch({
    'bool': [
        (0, False),
        (2, False)
    ],
    'int': [
        (slice(0, 2), [3, 2])
    ]
})

Note that the index of the DataFrame is [1, 2, 3] so not the default DataFrame index.

The default of .patch() is as_index=True which means that the indexes should be treated as DataFrame indexes, not as simple integer indexes. I think the example in the notebook is leveraging a bug so I'll update it.

Copy link
Member
@philippjfr philippjfr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thank you for adding the tests!

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Patching fails with DataFrame that don't have a monotonic range

3 participants

0