Repository navigation
fix(orderbook): use pl.len() for trade counts (polars 2.0 compat, refs #162) - #168
Merged
Merged
Conversation
…#162) Polars 2.0 rejects argument-less pl.count(); get_statistics() swallowed the TypeError as {'error': 'Analysis failed'}. Use pl.len() and keep the output column name "count". Assert buy/sell trade counts in the existing statistics test.
Merged
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.
Unblocks Dependabot #162 (polars 1.44.2 -> 2.0.0).
pyproject.tomlallowspolars>=1.31.0with no upper bound, so fresh installs already resolve polars 2.0. Under polars 2.0,MarketAnalytics.get_statistics()(orderbook) returned{'error': 'Analysis failed'}because argument-lesspl.count()now raises:This was the single failing test on #162 (
tests/orderbook/test_orderbook_analytics.py::TestStatisticalSummaries::test_get_statistics).Changes:
src/project_x_py/orderbook/analytics.py:pl.count()->pl.len()(output column name unchanged; works on polars 1.31+ and 2.0).Verified:
uv run pytest tests/orderbookpasses with locked polars 1.44.2 and with--with polars==2.0.0(173 passed). No other argument-lesspl.count()insrc/. uv.lock unchanged.