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

docs: Removed class, added polars to the table, str.head and str.tail are a… #1801

Merged
merged 4 commits into from
Jan 14, 2025
Merged
Changes from 1 commit
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
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),
Copy link
Member

Choose a reason for hiding this comment

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

I assume you are referring to #1789 comment. However, this would not render as expected since our polars implementation mostly call polars methods dynamically. Since we follow a subset of the polars API, everything should be flagged as green for a potential polars column in each table.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assume you are referring to #1789 comment. However, this would not render as expected since our polars implementation mostly call polars methods dynamically. Since we follow a subset of the polars API, everything should be flagged as green for a potential polars column in each table.

I've added a dummy column for Polars, as we discussed. Let me know if this approach works or if further adjustments are needed.

]

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
Loading