mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
changed function name
This commit is contained in:
parent
bec5c4f3c3
commit
35fea20fc7
2 changed files with 9 additions and 10 deletions
|
|
@ -18,7 +18,7 @@ from backend.utils.addressMatch import (
|
||||||
AddressMatch,
|
AddressMatch,
|
||||||
get_uprn_candidates,
|
get_uprn_candidates,
|
||||||
)
|
)
|
||||||
from backend.address2UPRN.scoring import df_has_single_uprn
|
from backend.address2UPRN.scoring import all_uprns_match
|
||||||
from datatypes.epc.domain.historic_epc_matching import (
|
from datatypes.epc.domain.historic_epc_matching import (
|
||||||
match_addresses_for_postcode,
|
match_addresses_for_postcode,
|
||||||
)
|
)
|
||||||
|
|
@ -98,7 +98,7 @@ def get_uprn_with_epc_df(
|
||||||
top_rank_df = scored_df[scored_df["lexirank"] == 1]
|
top_rank_df = scored_df[scored_df["lexirank"] == 1]
|
||||||
|
|
||||||
# If rank-1 rows do not agree on a single UPRN → ambiguous
|
# If rank-1 rows do not agree on a single UPRN → ambiguous
|
||||||
if not df_has_single_uprn(top_rank_df, uprn=top_rank_df.iloc[0]["uprn"]):
|
if not all_uprns_match(top_rank_df, target_uprn=top_rank_df.iloc[0]["uprn"]):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
address = top_rank_df["address"].values[0]
|
address = top_rank_df["address"].values[0]
|
||||||
|
|
@ -207,7 +207,7 @@ def resolve_uprns_for_postcode_group(
|
||||||
|
|
||||||
top_rank_df = scored_df[scored_df["lexirank"] == 1]
|
top_rank_df = scored_df[scored_df["lexirank"] == 1]
|
||||||
|
|
||||||
if not df_has_single_uprn(top_rank_df, top_rank_df.iloc[0]["uprn"]):
|
if not all_uprns_match(top_rank_df, top_rank_df.iloc[0]["uprn"]):
|
||||||
results.append(
|
results.append(
|
||||||
{
|
{
|
||||||
"found_uprn": None,
|
"found_uprn": None,
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,11 @@ import pandas as pd
|
||||||
from backend.utils.addressMatch import AddressMatch
|
from backend.utils.addressMatch import AddressMatch
|
||||||
|
|
||||||
|
|
||||||
def df_has_single_uprn(df: pd.DataFrame, uprn: str, column: str = "uprn") -> bool:
|
def all_uprns_match(
|
||||||
"""
|
df: pd.DataFrame,
|
||||||
Returns True if all non-null UPRNs in df match the given uprn.
|
target_uprn: str,
|
||||||
Returns False otherwise.
|
column: str = "uprn",
|
||||||
"""
|
) -> bool:
|
||||||
|
|
||||||
if column not in df.columns:
|
if column not in df.columns:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
@ -17,7 +16,7 @@ def df_has_single_uprn(df: pd.DataFrame, uprn: str, column: str = "uprn") -> boo
|
||||||
if len(uprns) == 0:
|
if len(uprns) == 0:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return len(uprns) == 1 and uprns[0] == str(uprn)
|
return len(uprns) == 1 and uprns[0] == str(target_uprn)
|
||||||
|
|
||||||
|
|
||||||
def get_uprn_candidates(
|
def get_uprn_candidates(
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue