feat(expr-ir): Add linear_space#3349
Merged
dangotbanned merged 8 commits intoexpr-ir/plz-finish-arrow-exprfrom Dec 10, 2025
Merged
feat(expr-ir): Add linear_space#3349dangotbanned merged 8 commits intoexpr-ir/plz-finish-arrow-exprfrom
linear_space#3349dangotbanned merged 8 commits intoexpr-ir/plz-finish-arrow-exprfrom
Conversation
`hist` depends on it, and if it gets extended to support `nw.Time` - then we've got ourselves a pretty powerful feature
I wanna share some fixtures between these Have some more tests to add from `polars` for `linear_space`
I found this one pretty interesting The `pyarrow` version never uses `np.linspace`, but will use `np.arange` when `pyarrow<21`
Handling the specific case on equal dtypes isn't hard, but it does make the existing code messy I'd rather revisit this with the other bits I wanna change
Its nicer that this has all the `ClosedInterval` cases handled before generating the range
Realised I haven't been running the doctests, oops The change in `ByName` was a fix from #3233
1 task
937bc57
into
expr-ir/plz-finish-arrow-expr
23 of 35 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This one started as a plan to expose the
linear_spaceI adapted fromnp.linspace.I added that for use in
hist, where onmainthere is currently a dependency onnp.linspace.Show usage
narwhals/narwhals/_plan/arrow/functions.py
Lines 1579 to 1587 in f50278d
narwhals/narwhals/_plan/arrow/expr.py
Lines 742 to 749 in f50278d
narwhals/narwhals/_arrow/series.py
Lines 1161 to 1171 in c119546
However, after l'd ported the
polars.linear_spacetests and noticing the direct comparison tonp.linspace- I got ... curiousSo I did my digging and found the polars rust impl - which was a lot cleaner in handling
ClosedInterval. So, I stole that instead 😄I'm deferring support on these for now:
num_sumples: IntoExprColumnpolars.linear_spacedocs have an example withnum_samples=pl.len()which seems useful{start,end}: TemporalLiteral(and temporal expressions)Timecase will work similarly toDatein (feat(expr-ir): Adddate_range, support{date,int}_range(eager=...)#3294)DateandDatetimeI don't wanna think aboutRelated issues
ArrowExpr#3325date_range, support{date,int}_range(eager=...)#3294