Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(schema): stronger typing for belongingness_ratio
Browse files Browse the repository at this point in the history
alhayward committed Nov 14, 2024

Verified

This commit was signed with the committer’s verified signature.
1 parent 0f0dd00 commit 1d25bcd
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/recordlinker/schemas/algorithm.py
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
import typing

import pydantic
from typing_extensions import Annotated

from recordlinker.linking import matchers
from recordlinker.models.mpi import BlockingKey
@@ -78,7 +79,7 @@ class Algorithm(pydantic.BaseModel):
description: typing.Optional[str] = None
is_default: bool = False
include_multiple_matches: bool = True
belongingness_ratio: tuple[float, float]
belongingness_ratio: tuple[Annotated[float, pydantic.Field(ge=0, le=1)], Annotated[float, pydantic.Field(ge=0, le=1)]]
passes: typing.Sequence[AlgorithmPass]

@pydantic.field_validator("belongingness_ratio", mode="before")
4 changes: 3 additions & 1 deletion src/recordlinker/schemas/link.py
Original file line number Diff line number Diff line change
@@ -76,7 +76,9 @@ class LinkResponse(pydantic.BaseModel):
"all Persons with which the Patient record possibly matches."
)

@pydantic.computed_field
# mypy doesn't support decorators on properties; https://github.com/python/mypy/issues/1362
@pydantic.computed_field # type: ignore[misc]
@property
def prediction(self) -> typing.Literal["match", "possible_match", "no_match"]:
"""
Record Linkage algorithm prediction.

0 comments on commit 1d25bcd

Please sign in to comment.