nanoplot options type check incorrectly fails a list of strings
Description
Nanoplot list type validation checks only for int, preventing passing a list of str's to specify custom colors.
Reproducible example
from great_tables import GT
import polars as pl
random_numbers_df = pl.DataFrame(
{
"example": ["Row " + str(x) for x in range(1, 5)],
"numbers": [
"20 23 6",
"2.3 6.8 9.2",
"-12 -5 6",
"2 0 15",
],
}
)
GT(random_numbers_df).fmt_nanoplot(
columns="numbers",
options=nanoplot_options(
data_point_radius=5,
data_point_stroke_color=["black", "red", "black"],
show_data_area=False,
)
)
Results in the error:
ValueError: Nanoplot option must be a list of <class 'str'>s
Expected result
Expected to be able to pass a list to create a nanoplot with the stroke color as "red" for the middle point
Development environment
- Operating System: macOS
- great_tables Version: 0.9.0
Additional context
I believe the line of code https://github.com/posit-dev/great-tables/blob/main/great_tables/_helpers.py#L1143 should be updated from
if not all(isinstance(x, int) for x in nano_opt):
to something like
if not all(isinstance(x, option_type) for x in nano_opt):
Realize that there's an epic in progress for nanoplots, so apologies if this is already in progress. Please let me know if you need more context here!
@pyrobat, thanks for bringing this issue to our attention. I'll close it now, as I believe it has been addressed—thanks to @tylerriccio33.