Skip to content

Commit

Permalink
rename user_row to user_profile
Browse files Browse the repository at this point in the history
  • Loading branch information
mdekstrand committed Aug 7, 2024
1 parent 24b8955 commit 5b23d2d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
12 changes: 6 additions & 6 deletions lenskit/lenskit/data/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,12 +372,12 @@ def interaction_matrix(

@abstractmethod
@overload
def user_row(self, user_id: EntityId) -> UserProfile | None: ...
def user_profile(self, user_id: EntityId) -> UserProfile | None: ...
@abstractmethod
@overload
def user_row(self, *, user_num: int) -> UserProfile: ...
def user_profile(self, *, user_num: int) -> UserProfile: ...
@abstractmethod
def user_row(
def user_profile(
self, user_id: EntityId | None = None, *, user_num: int | None = None
) -> UserProfile | None:
"""
Expand Down Expand Up @@ -742,7 +742,7 @@ def _int_log_torch(self, fields: list[str]) -> TorchUserItemTable:
return tbl

@override
def user_row(
def user_profile(
self, user_id: EntityId | None = None, *, user_num: int | None = None
) -> UserProfile | None:
if user_num is None:
Expand Down Expand Up @@ -819,8 +819,8 @@ def interaction_log(self, *args, **kwargs) -> Any:
return self.delegate().interaction_log(*args, **kwargs)

@override
def user_row(self, *args, **kwargs) -> UserProfile | None:
return self.delegate().user_row(*args, **kwargs)
def user_profile(self, *args, **kwargs) -> UserProfile | None:
return self.delegate().user_profile(*args, **kwargs)


def from_interactions_df(
Expand Down
2 changes: 1 addition & 1 deletion lenskit/lenskit/splitting/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def _make_split(
test = {}

for u in test_us:
profile = data.user_row(u)
profile = data.user_profile(u)
assert profile is not None
row = profile.item_list()
assert row is not None
Expand Down
4 changes: 2 additions & 2 deletions lenskit/tests/test_dataset_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def test_matrix_rows_by_id(rng: np.random.Generator, ml_ratings: pd.DataFrame, m
users = rng.choice(ml_ds.users.ids(), 50)

for user in users:
profile = ml_ds.user_row(user)
profile = ml_ds.user_profile(user)
assert profile is not None
row = profile.item_list()
assert row is not None
Expand Down Expand Up @@ -382,7 +382,7 @@ def test_matrix_rows_by_num(rng: np.random.Generator, ml_ratings: pd.DataFrame,

for user in users:
uid = ml_ds.users.id(user)
profile = ml_ds.user_row(user_num=user)
profile = ml_ds.user_profile(user_num=user)
assert profile is not None
row = profile.item_list()
assert row is not None
Expand Down
8 changes: 4 additions & 4 deletions lenskit/tests/test_itemlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def test_item_list_pickle_compact(ml_ds: Dataset):


def test_item_list_pickle_fields(ml_ds: Dataset):
row = ml_ds.user_row(user_num=400).item_list()
row = ml_ds.user_profile(user_num=400).item_list()
assert row is not None
data = pickle.dumps(row)
r2 = pickle.loads(data)
Expand All @@ -238,7 +238,7 @@ def test_item_list_pickle_fields(ml_ds: Dataset):


def test_subset_mask(ml_ds: Dataset):
row = ml_ds.user_row(user_num=400).item_list()
row = ml_ds.user_profile(user_num=400).item_list()
assert row is not None
ratings = row.field("rating")
assert ratings is not None
Expand All @@ -258,7 +258,7 @@ def test_subset_mask(ml_ds: Dataset):


def test_subset_idx(ml_ds: Dataset):
row = ml_ds.user_row(user_num=400).item_list()
row = ml_ds.user_profile(user_num=400).item_list()
assert row is not None
ratings = row.field("rating")
assert ratings is not None
Expand All @@ -275,7 +275,7 @@ def test_subset_idx(ml_ds: Dataset):


def test_subset_slice(ml_ds: Dataset):
row = ml_ds.user_row(user_num=400).item_list()
row = ml_ds.user_profile(user_num=400).item_list()
assert row is not None
ratings = row.field("rating")
assert ratings is not None
Expand Down
16 changes: 8 additions & 8 deletions lenskit/tests/test_split_holdout.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_sample_n(ml_ds: Dataset):

s5 = SampleN(5)
for u in users:
profile = ml_ds.user_row(u)
profile = ml_ds.user_profile(u)
assert profile is not None
row = profile.item_list()
assert row is not None
Expand All @@ -34,7 +34,7 @@ def test_sample_n(ml_ds: Dataset):

s10 = SampleN(10)
for u in users:
profile = ml_ds.user_row(u)
profile = ml_ds.user_profile(u)
assert profile is not None
row = profile.item_list()
assert row is not None
Expand All @@ -50,7 +50,7 @@ def test_sample_frac(ml_ds: Dataset):

samp = SampleFrac(0.2)
for u in users:
profile = ml_ds.user_row(u)
profile = ml_ds.user_profile(u)
assert profile is not None
row = profile.item_list()
assert row is not None
Expand All @@ -63,7 +63,7 @@ def test_sample_frac(ml_ds: Dataset):

samp = SampleFrac(0.5)
for u in users:
profile = ml_ds.user_row(u)
profile = ml_ds.user_profile(u)
assert profile is not None
row = profile.item_list()
assert row is not None
Expand All @@ -80,7 +80,7 @@ def test_last_n(ml_ds: Dataset):

samp = LastN(5)
for u in users:
profile = ml_ds.user_row(u)
profile = ml_ds.user_profile(u)
assert profile is not None
row = profile.item_list()
assert row is not None
Expand All @@ -93,7 +93,7 @@ def test_last_n(ml_ds: Dataset):

samp = LastN(7)
for u in users:
profile = ml_ds.user_row(u)
profile = ml_ds.user_profile(u)
assert profile is not None
row = profile.item_list()
assert row is not None
Expand All @@ -110,7 +110,7 @@ def test_last_frac(ml_ds: Dataset):

samp = LastFrac(0.2, "timestamp")
for u in users:
profile = ml_ds.user_row(u)
profile = ml_ds.user_profile(u)
assert profile is not None
row = profile.item_list()
assert row is not None
Expand All @@ -124,7 +124,7 @@ def test_last_frac(ml_ds: Dataset):

samp = LastFrac(0.5, "timestamp")
for u in users:
profile = ml_ds.user_row(u)
profile = ml_ds.user_profile(u)
assert profile is not None
row = profile.item_list()
assert row is not None
Expand Down
2 changes: 1 addition & 1 deletion lenskit/tests/test_split_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_crossfold_may_skip_train(ml_ratings: pd.DataFrame):
for train, test in splits:
for u in ucounts[ucounts == 1].index:
if u in test:
row = train.user_row(u)
row = train.user_profile(u)
assert row is not None
items = row.item_list()
assert items is not None
Expand Down

0 comments on commit 5b23d2d

Please sign in to comment.