Skip to content

Commit

Permalink
sort entities when serializing BiasConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
mdekstrand committed Jan 11, 2025
1 parent 36cbb60 commit d7316c9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lenskit/lenskit/basic/bias.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
import logging
from collections.abc import Container
from dataclasses import dataclass
from typing import Literal
from typing import Annotated, Literal

import numpy as np
import torch
from pydantic import BaseModel, NonNegativeFloat
from pydantic import BaseModel, NonNegativeFloat, PlainSerializer
from typing_extensions import Self, TypeAlias, overload

from lenskit.data import ID, Dataset, ItemList, QueryInput, RecQuery, Vocabulary
Expand Down Expand Up @@ -256,7 +256,9 @@ class BiasConfig(BaseModel, extra="forbid"):
Configuration for :class:`BiasScorer`.
"""

entities: set[Literal["user", "item"]] = {"user", "item"}
entities: Annotated[
set[Literal["user", "item"]], PlainSerializer(lambda s: sorted(s), return_type=list[str])
] = {"user", "item"}
"""
The entities to compute biases for, in addition to global bais. Defaults to
users and items.
Expand Down

0 comments on commit d7316c9

Please sign in to comment.