Reject colliding attribution semantics headers
This commit is contained in:
@@ -475,7 +475,7 @@ def _resolve_beta_semantics(row: pd.Series) -> dict[str, str]:
|
||||
parsed_mapping = {str(key): str(value) for key, value in parsed.items()}
|
||||
if set(parsed_mapping) == set(SEMANTIC_BETA_COLUMNS) and all(
|
||||
value.strip() for value in parsed_mapping.values()
|
||||
):
|
||||
) and _semantics_have_unique_headers(parsed_mapping):
|
||||
return parsed_mapping
|
||||
return canonical
|
||||
|
||||
@@ -488,6 +488,11 @@ def _beta_header_name(factor_name: str) -> str:
|
||||
return f"beta_{suffix}"
|
||||
|
||||
|
||||
def _semantics_have_unique_headers(semantics: dict[str, str]) -> bool:
|
||||
headers = [_beta_header_name(semantics[column]) for column in SEMANTIC_BETA_COLUMNS]
|
||||
return len(headers) == len(set(headers))
|
||||
|
||||
|
||||
def _section_beta_header_map(semantics: dict[str, str]) -> dict[str, str]:
|
||||
header_map: dict[str, str] = {}
|
||||
for beta_column, factor_name in semantics.items():
|
||||
|
||||
Reference in New Issue
Block a user