chore(script): Refactor study strength bin calc

Move calculation into validity modelling to have one source of truth
which all in-text representations will use.
This commit is contained in:
Marty Oehme 2024-07-29 09:48:25 +02:00
parent 07d3efbcd7
commit 6089b64665
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
2 changed files with 20 additions and 22 deletions

View file

@ -220,29 +220,18 @@ to better identify areas of strong analytical lenses or areas of more limited an
::: {#tbl-findings-institutional}
```{python}
#| label: tbl-findings-institutional
# | label: tbl-findings-institutional
from src.model import validity
from src.model.validity import strength_for # Careful: ruff org imports will remove
study_strength_bins = {
0.0: r"\-",
5.0: r"\+",
10.0: r"\++",
}
def strength_for(val):
return list(study_strength_bins.keys())[
list(study_strength_bins.values()).index(val)
]
findings_institutional = pd.read_csv(f"{g.SUPPLEMENTARY_DATA}/findings-institutional.csv")
findings_institutional = pd.read_csv(
f"{g.SUPPLEMENTARY_DATA}/findings-institutional.csv"
)
fd_df = validity.add_to_findings(findings_institutional, df_by_intervention)
outp = Markdown(
tabulate(
validity.add_to_findings(
findings_institutional, df_by_intervention, study_strength_bins
)[
fd_df[
[
"area of policy",
"internal_validity",
@ -262,8 +251,8 @@ outp = Markdown(
tablefmt="grid",
)
)
del findings_institutional
outp
del findings_institutional, fd_df
outp # type: ignore[ReportUnusedExpression]
```
Note: Each main finding is presented with an internal strength of evidence and an external strength of evidence which describe the combined validities of the evidence base for the respective finding.