refactor(code): Rename validity module

From strength of findings to the more general validity module, which can then
in turn contain the 'add_to_findings' function which unsurprisingly adds
validities to findings. Makes more sense to me.
This commit is contained in:
Marty Oehme 2024-02-16 10:03:10 +01:00
parent 5f9f3a1370
commit 8333bbe9be
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
2 changed files with 8 additions and 8 deletions

View file

@ -634,10 +634,10 @@ g = sns.PairGrid(validities[["internal_validity", "external_validity", "identifi
```{python}
#| label: tbl-findings-institutional
from src.model import strength_of_findings as findings
from src.model import validity
findings_institutional = pd.read_csv("02-data/supplementary/findings-institutional.csv")
fd_df = findings.add_validities(findings_institutional, by_intervention)
fd_df = validity.add_to_findings(findings_institutional, by_intervention)
md(tabulate(fd_df[["area of policy", "internal_validity", "external_validity", "findings", "channels"]].fillna(""), showindex=False, headers="keys", tablefmt="grid"))
```
@ -865,10 +865,10 @@ One limitation of the study is the modelling assumption that workers will have t
```{python}
#| label: tbl-findings-structural
from src.model import strength_of_findings as findings
from src.model import validity
findings_structural = pd.read_csv("02-data/supplementary/findings-structural.csv")
fd_df = findings.add_validities(findings_structural, by_intervention)
fd_df = validity.add_to_findings(findings_structural, by_intervention)
md(tabulate(fd_df[["area of policy", "internal_validity", "external_validity", "findings", "channels"]].fillna(""), showindex=False, headers="keys", tablefmt="grid"))
```
@ -1100,10 +1100,10 @@ Though the intervention clearly aims at strengthening some aspect of individual
```{python}
#| label: tbl-findings-agency
from src.model import strength_of_findings as findings
from src.model import validity
findings_agency = pd.read_csv("02-data/supplementary/findings-agency.csv")
fd_df = findings.add_validities(findings_agency, by_intervention)
fd_df = validity.add_to_findings(findings_agency, by_intervention)
md(tabulate(fd_df[["area of policy", "internal_validity", "external_validity", "findings", "channels"]].fillna(""), showindex=False, headers="keys", tablefmt="grid"))
```

View file

@ -28,7 +28,7 @@ def _combined_validities(
return r"\-"
def add_validities(
def add_to_findings(
findings_df: DataFrame, studies_by_intervention: DataFrame
) -> DataFrame:
valid_subset = (
@ -36,7 +36,7 @@ def add_validities(
["internal_validity", "external_validity", "citation"]
]
.fillna(1.0)
.drop_duplicates(subset=["citation"])
.drop_duplicates(subset=["citation"]) # type: ignore
.sort_values("internal_validity")
)