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

feat(python): allow use of StringCache object as a function decorator #9309

Merged
merged 2 commits into from
Jun 9, 2023

Conversation

alexander-beedie
Copy link
Collaborator

Ref: #9307.

The same trick (upgrading our context manager to do double-duty as a decorator) works nicely here too...

import polars as pl

@pl.StringCache()
def lets_get_schwifty() -> pl.DataFrame:
    df1 = pl.LazyFrame([
        pl.Series("key", ["bar"], dtype=pl.Categorical),
        pl.Series("val", [1]),
    ])
    df2 = pl.LazyFrame([
        pl.Series("key", ["bar"], dtype=pl.Categorical),
        pl.Series("val", [2]),
    ])
    return df1.join(df2, on=["key"], how="outer").collect()

print( lets_get_schwifty() )
# shape: (1, 3)
# ┌─────┬─────┬───────────┐
# │ key ┆ val ┆ val_right │
# │ --- ┆ --- ┆ ---       │
# │ cat ┆ i64 ┆ i64       │
# ╞═════╪═════╪═══════════╡
# │ bar ┆ 1   ┆ 2         │
# └─────┴─────┴───────────┘

@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars labels Jun 8, 2023
@alexander-beedie
Copy link
Collaborator Author

alexander-beedie commented Jun 8, 2023

Hmm, that's odd - the typos linter has suddenly become very slightly stricter by upgrading itself to 1.15, though we have it pinned it at 1.14.11 in requirements-lint.txt 🤔 (Ref: the initially failing lint test).

@stinodego, any idea why CI is out of sync with requirements?
In the meantime I'll see if I can tweak what it found so we pass the updated validation.

@stinodego
Copy link
Member

@stinodego, any idea why CI is out of sync with requirements?

The CI doesn't use the Python package, it uses the typos Action. So it can be out of sync with the requirements.txt.

@ritchie46
Copy link
Member

Related to some of these fixes. Can we prevent the typos check to check parameters and data in dataframes? That's a bit too constraining IMO.

@ritchie46 ritchie46 merged commit c01d81e into pola-rs:main Jun 9, 2023
20 checks passed
@alexander-beedie
Copy link
Collaborator Author

alexander-beedie commented Jun 9, 2023

The CI doesn't use the Python package, it uses the typos Action.

Ahh, gotcha; not a big problem, it only complained about up a small handful of extra stuff.
I'll bump our requirements-lint.txt to match the latest.

@alexander-beedie alexander-beedie deleted the stringcache-as-decorator branch June 9, 2023 05:55
@stinodego
Copy link
Member

Related to some of these fixes. Can we prevent the typos check to check parameters and data in dataframes? That's a bit too constraining IMO.

I think @ghuls set it up, maybe he knows some of the settings. I could look into it sometime.

SeanTroyUWO pushed a commit to SeanTroyUWO/polars that referenced this pull request Jun 20, 2023
c-peters pushed a commit to c-peters/polars that referenced this pull request Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or an improvement of an existing feature python Related to Python Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants