From eba3723e320570039c077c27fc70c3730beec804 Mon Sep 17 00:00:00 2001 From: Marvin Lopez Date: Sun, 12 Jan 2025 18:06:51 +0000 Subject: [PATCH] Removed class, added polars to the table, str.head and str.tail are always checked. --- utils/generate_backend_completeness.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/utils/generate_backend_completeness.py b/utils/generate_backend_completeness.py index fccf54f84..19994bf53 100644 --- a/utils/generate_backend_completeness.py +++ b/utils/generate_backend_completeness.py @@ -49,12 +49,15 @@ class Backend(NamedTuple): Backend(name="duckdb", module="_duckdb", type_=BackendType.LAZY), Backend(name="pandas-like", module="_pandas_like", type_=BackendType.EAGER), Backend(name="spark-like", module="_spark_like", type_=BackendType.LAZY), + Backend(name="polars", module="_polars", type_=BackendType.EAGER), ] EXCLUDE_CLASSES = {"BaseFrame", "Then", "When"} DIRECTLY_IMPLEMENTED_METHODS = ["pipe", "implementation", "to_native"] +EXPR_STR_METHODS = ["tail", "head"] + def get_class_methods(kls: type[Any]) -> list[str]: return [m[0] for m in inspect.getmembers(kls) if not m[0].startswith("_")] @@ -79,6 +82,9 @@ def parse_module(module_name: str, backend: str, nw_class_name: str) -> list[str else [] ) + if module_name == "expr_str" and class_: + methods_ += EXPR_STR_METHODS + except ModuleNotFoundError: methods_ = [] @@ -91,11 +97,11 @@ def render_table_and_write_to_output( results = ( pl.concat(results) .with_columns(supported=pl.lit(":white_check_mark:")) - .pivot(on="Backend", values="supported", index=["Class", "Method"]) + .pivot(on="Backend", values="supported", index=["Method"]) .filter(pl.col("narwhals").is_not_null()) .drop("narwhals") .fill_null(":x:") - .sort("Class", "Method") + .sort("Method") ) with pl.Config( @@ -137,14 +143,11 @@ def get_backend_completeness_table() -> None: nw_methods = get_class_methods(nw_class) - narwhals = pl.DataFrame( - {"Class": nw_class_name, "Backend": "narwhals", "Method": nw_methods} - ) + narwhals = pl.DataFrame({"Backend": "narwhals", "Method": nw_methods}) backend_methods = [ pl.DataFrame( { - "Class": nw_class_name, "Backend": backend.name, "Method": parse_module( module_name,