-
Notifications
You must be signed in to change notification settings - Fork 7
feat: make finalise non-interactive by default #309
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
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #309 +/- ##
==========================================
+ Coverage 99.11% 99.75% +0.64%
==========================================
Files 9 9
Lines 1237 1244 +7
==========================================
+ Hits 1226 1241 +15
+ Misses 11 3 -8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
need this because old-style interactive finalise() doesn't;t play nice with Stata and won't work when sent as workflow job in container for federated analytics. |
|
Also adds exception when suppress=True, implementing the proposed solution to issue #254 |
Signed-off-by: Jim-smith <[email protected]>
for more information, see https://pre-commit.ci
|
Addresses #297 |
rpreen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor suggested clean up.
| ) | ||
| if self.suppress: | ||
| justadded = f"output_{self.results.output_id - 1}" | ||
| self.results.add_exception( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That this is duplicated in another function (lines 407--411) makes me wonder if this should be refactored or placed elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but this is part of a wider refactor we will have to do when we introduce rounding and make the code output meta statements in the omntology about what happened
Co-authored-by: Richard Preen <[email protected]> Signed-off-by: Jim-smith <[email protected]>
|
There's one missing line in create_dataframe that has never been covered and I can't work out how to cover. try:
if isinstance(index, list):
index_df = pd.concat(index, axis=1)
elif isinstance(index, pd.Series):
index_df = pd.DataFrame({index.name: index})
except (ValueError, TypeError):
index_df = empty_dataframe
columns_df = empty_dataframe
try:
if isinstance(columns, list):
columns_df = pd.concat(columns, axis=1)
elif isinstance(columns, pd.Series):
columns_df = pd.DataFrame({columns.name: columns})
except (ValueError, TypeError):
columns_df = empty_dataframe
try:
data = pd.concat([index_df, columns_df], axis=1)
except (ValueError, TypeError):
data = empty_dataframeNot sure if we should remove the try..except around the final concat as whatever gets fed into it by the two clauses above should be valid operands to pd.concat() |
|
Why does I think it could also be refactored to something like this: def create_dataframe(index, columns) -> DataFrame:
"""Combine the index and columns in a dataframe and return the dataframe.
Parameters
----------
index : array-like, Series, or list of arrays/Series
Values to group by in the rows.
columns : array-like, Series, or list of arrays/Series
Values to group by in the columns.
Returns
-------
DataFrame
Table of the index and columns combined.
"""
def to_df(obj) -> DataFrame:
"""Convert an object to DataFrame."""
if isinstance(obj, Series):
return pd.DataFrame({obj.name: obj})
if isinstance(obj, list):
return pd.concat(obj, axis=1)
return pd.DataFrame()
index_df = to_df(index)
columns_df = to_df(columns)
return pd.concat([index_df, columns_df], axis=1)[Edit] I'm not sure the docstrings are exactly correct for this (but I left it as it was.) |
Not sure: it's not my code, and is only used in one place (cross tab_with_totals), to create a table that queries run on - I think.
|
No description provided.