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

Fix the generation of the "multiindex" polars df #308

Merged
merged 2 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
ITables ChangeLog
=================

2.1.5-dev (2024-08-??)
------------------

**Fixed**
- We have adjusted the generation of the Polars sample dataframes to fix the CI ([Polars-18130](https://github.com/pola-rs/polars/issues/18130))
- The test on the Shiny app fallbacks to `ui.nav_panel` when `ui.nav` is not available


2.1.4 (2024-07-03)
------------------

Expand Down
10 changes: 8 additions & 2 deletions src/itables/sample_dfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,15 @@ def get_dict_of_test_dfs(N=100, M=100, polars=False):
import pyarrow as pa

polars_dfs = {}
for key in test_dfs:
for key, df in test_dfs.items():
if key == "multiindex":
# Since Polars 1.2, pl.from_pandas fails with this error:
# ValueError: Pandas dataframe contains non-unique indices and/or column names.
# Polars dataframes require unique string names for columns.
# See https://github.com/pola-rs/polars/issues/18130
df.index = df.index.tolist()
try:
polars_dfs[key] = pl.from_pandas(test_dfs[key])
polars_dfs[key] = pl.from_pandas(df)
except (pa.ArrowInvalid, ValueError):
pass
return polars_dfs
Expand Down
2 changes: 1 addition & 1 deletion tests/sample_python_apps/itables_in_a_shiny_app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Run this app with "shiny run file.py"
from shiny import App, ui

from itables.sample_dfs import get_countries
Expand All @@ -8,4 +9,3 @@
app_ui = ui.page_fluid(ui.HTML(DT(df)))

app = App(app_ui, server=None)
# app.run()
10 changes: 8 additions & 2 deletions tests/sample_python_apps/itables_in_a_shiny_app_with_tabs.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# Run this app with "shiny run file.py"
from shiny import App, ui

from itables.sample_dfs import get_dict_of_test_dfs
from itables.shiny import DT

try:
# This one is not available on the CI (Python 3.8)
ui_nav = ui.nav
except AttributeError:
ui_nav = ui.nav_panel

app_ui = ui.page_fluid(
# Display the different tables in different tabs
ui.navset_tab(
*[ui.nav(name, ui.HTML(DT(df))) for name, df in get_dict_of_test_dfs().items()]
*[ui_nav(name, ui.HTML(DT(df))) for name, df in get_dict_of_test_dfs().items()]
)
)

app = App(app_ui, server=None)
# app.run()
Loading