Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎨 Enable default field for .inspect and .validate #275

Merged
merged 1 commit into from
Aug 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lnschema_core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ValidationMixin:
def inspect(
cls,
values: ListLike,
field: StrField,
field: Optional[Union[str, StrField]] = None,
*,
mute: bool = False,
**kwargs,
Expand Down Expand Up @@ -95,7 +95,14 @@ def inspect(
pass

@classmethod
def validate(cls, values: ListLike, field: StrField, *, mute: bool = False, **kwargs) -> "np.ndarray":
def validate(
cls,
values: ListLike,
field: Optional[Union[str, StrField]] = None,
*,
mute: bool = False,
**kwargs,
) -> "np.ndarray":
"""Validate values against existing values of a string field.

Note this is strict validation, only asserts exact matches.
Expand Down Expand Up @@ -129,14 +136,14 @@ def validate(cls, values: ListLike, field: StrField, *, mute: bool = False, **kw
def standardize(
cls,
values: Iterable,
field: Optional[Union[str, StrField]] = None,
*,
return_mapper: bool = False,
case_sensitive: bool = False,
mute: bool = False,
bionty_aware: bool = True,
keep: Literal["first", "last", False] = "first",
synonyms_field: str = "synonyms",
field: Optional[str] = None,
**kwargs,
) -> Union[List[str], Dict[str, str]]:
"""Maps input synonyms to standardized names.
Expand Down
Loading