Skip to content

Commit

Permalink
Removed class, added polars to the table, str.head and str.tail are a…
Browse files Browse the repository at this point in the history
…lways checked.
  • Loading branch information
marvinl803 committed Jan 12, 2025
1 parent fbe29a6 commit eba3723
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions utils/generate_backend_completeness.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("_")]
Expand All @@ -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_ = []

Expand All @@ -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(
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit eba3723

Please sign in to comment.