Skip to content

Commit

Permalink
apply fixes to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mdekstrand committed Jul 30, 2024
1 parent 629200f commit 28fa380
Show file tree
Hide file tree
Showing 23 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion lenskit-funksvd/tests/test_funksvd.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

from pytest import approx, mark

from lenskit.data.dataset import Dataset, from_interactions_df
import lenskit.funksvd as svd
import lenskit.util.test as lktu
from lenskit.data.dataset import Dataset, from_interactions_df

_log = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion lenskit-hpf/tests/test_hpf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

from pytest import importorskip, mark

from lenskit.data.dataset import from_interactions_df
import lenskit.util.test as lktu
from lenskit.algorithms import basic
from lenskit.data.dataset import from_interactions_df

hpf = importorskip("lenskit.hpf")

Expand Down
2 changes: 1 addition & 1 deletion lenskit-implicit/tests/test_implicit.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

from pytest import mark

from lenskit.data.dataset import from_interactions_df
import lenskit.util.test as lktu
from lenskit import util
from lenskit.data.dataset import from_interactions_df
from lenskit.implicit import ALS, BPR

_log = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions lenskit/tests/test_als_explicit.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

from pytest import approx, mark

from lenskit.data.dataset import Dataset, from_interactions_df
from lenskit.data.movielens import load_movielens_df
import lenskit.util.test as lktu
from lenskit import batch
from lenskit.algorithms import als
from lenskit.data.dataset import Dataset, from_interactions_df
from lenskit.data.movielens import load_movielens_df

_log = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions lenskit/tests/test_als_implicit.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

from pytest import approx, mark

from lenskit.data.dataset import Dataset, from_interactions_df
from lenskit.data.movielens import load_movielens_df
import lenskit.util.test as lktu
from lenskit.algorithms import Recommender, als
from lenskit.data.dataset import Dataset, from_interactions_df
from lenskit.data.movielens import load_movielens_df

_log = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions lenskit/tests/test_batch_predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
import pytest

import lenskit.batch as lkb
from lenskit.data.dataset import Dataset, from_interactions_df
import lenskit.util.test as lktu
from lenskit.util.test import ml_ratings, ml_ds # noqa: F401
from lenskit.algorithms.bias import Bias
from lenskit.data.dataset import Dataset, from_interactions_df
from lenskit.util.test import ml_ds, ml_ratings # noqa: F401

_log = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion lenskit/tests/test_batch_recommend.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
import pytest

import lenskit.crossfold as xf
from lenskit.data.dataset import Dataset, from_interactions_df
import lenskit.util.test as lktu
from lenskit import batch, topn
from lenskit.algorithms import Recommender
from lenskit.algorithms.basic import PopScore, TopN
from lenskit.algorithms.bias import Bias
from lenskit.data.dataset import Dataset, from_interactions_df

_log = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion lenskit/tests/test_bias.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

import numpy as np
import pandas as pd
import torch

from pytest import approx, mark, raises
import torch

from lenskit import util as lku
from lenskit.algorithms.bias import Bias
Expand Down
2 changes: 1 addition & 1 deletion lenskit/tests/test_candidate_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import numpy as np
import pandas as pd

from lenskit.data.dataset import Dataset, from_interactions_df
import lenskit.util.test as lktu
from lenskit.algorithms import basic
from lenskit.data.dataset import Dataset, from_interactions_df

simple_df = pd.DataFrame(
{"item": [1, 1, 2, 3], "user": [10, 12, 10, 13], "rating": [4.0, 3.0, 5.0, 2.0]}
Expand Down
5 changes: 2 additions & 3 deletions lenskit/tests/test_crossfold.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
import math

import numpy as np

import pandas as pd

import pytest

import lenskit.crossfold as xf
import lenskit.util.test as lktu


def test_partition_rows(ml_ratings: pd.DataFrame):
Expand Down Expand Up @@ -228,7 +227,7 @@ def test_partition_users(ml_ratings: pd.DataFrame):


def test_partition_may_skip_train(ml_ratings: pd.DataFrame):
"""Partitioning when users may not have enough ml_ratings to be in the train set and test set."""
"Partitioning when users may not have enough ratings to be in the train and test sets."
# make a data set where some users only have 1 rating
ml_ratings = ml_ratings.sample(frac=0.1)
users = ml_ratings.groupby("user")["rating"].count()
Expand Down
1 change: 1 addition & 0 deletions lenskit/tests/test_dataset_lazy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import numpy as np
import pandas as pd

from pytest import approx

from lenskit.data import Dataset
Expand Down
1 change: 1 addition & 0 deletions lenskit/tests/test_dataset_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import numpy as np
import pandas as pd

from pytest import approx

from lenskit.data import Dataset
Expand Down
4 changes: 2 additions & 2 deletions lenskit/tests/test_fallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

from pytest import approx

from lenskit.data.dataset import Dataset
import lenskit.util.test as lktu
from lenskit import util as lku
from lenskit.algorithms import basic
from lenskit.algorithms.bias import Bias
from lenskit.util.test import ml_ratings, ml_ds # noqa: F401
from lenskit.data.dataset import Dataset
from lenskit.util.test import ml_ds, ml_ratings # noqa: F401

simple_df = pd.DataFrame(
{"item": [1, 1, 2, 3], "user": [10, 12, 10, 13], "rating": [4.0, 3.0, 5.0, 2.0]}
Expand Down
8 changes: 4 additions & 4 deletions lenskit/tests/test_knn_item_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
from pytest import approx, fixture, mark

import lenskit.algorithms.knn.item as knn
from lenskit.algorithms.ranking import TopN
from lenskit.data.dataset import from_interactions_df
from lenskit.data.vocab import EntityId, Vocabulary
import lenskit.util.test as lktu
from lenskit import batch
from lenskit.algorithms import Recommender
from lenskit.algorithms.basic import Fallback
from lenskit.algorithms.bias import Bias
from lenskit.algorithms.ranking import TopN
from lenskit.data.dataset import from_interactions_df
from lenskit.data.vocab import EntityId, Vocabulary
from lenskit.diagnostics import ConfigWarning, DataWarning
from lenskit.util import clone
from lenskit.util.test import ml_ratings, ml_ds # noqa: F401
from lenskit.util.test import ml_ds, ml_ratings # noqa: F401

_log = logging.getLogger(__name__)

Expand Down
6 changes: 3 additions & 3 deletions lenskit/tests/test_knn_user_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
from pytest import approx, fail, mark

import lenskit.algorithms.knn.user as knn
from lenskit.algorithms.ranking import TopN
from lenskit.data.dataset import Dataset, from_interactions_df
import lenskit.util.test as lktu
from lenskit.algorithms import Recommender
from lenskit.algorithms.ranking import TopN
from lenskit.data.dataset import Dataset, from_interactions_df
from lenskit.util import clone
from lenskit.util.test import ml_ratings, ml_ds # noqa: F401
from lenskit.util.test import ml_ds, ml_ratings # noqa: F401

_log = logging.getLogger(__name__)

Expand Down
5 changes: 3 additions & 2 deletions lenskit/tests/test_load_movielens.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
# Licensed under the MIT license, see LICENSE.md for details.
# SPDX-License-Identifier: MIT

from pathlib import Path
from lenskit.data.movielens import load_movielens
import functools
from pathlib import Path

from pytest import mark

from lenskit.data.movielens import load_movielens

ML_LATEST_DIR = Path("data/ml-latest-small")
ML_100K_DIR = Path("data/ml-100k")
ML_1M_DIR = Path("data/ml-1m")
Expand Down
2 changes: 1 addition & 1 deletion lenskit/tests/test_popular.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import pandas as pd

import lenskit.util.test as lktu
from lenskit.util.test import ml_ratings, ml_ds # noqa: F401
from lenskit.algorithms import basic
from lenskit.util.test import ml_ds, ml_ratings # noqa: F401

simple_df = pd.DataFrame(
{"item": [1, 1, 2, 3], "user": [10, 12, 10, 13], "rating": [4.0, 3.0, 5.0, 2.0]}
Expand Down
2 changes: 1 addition & 1 deletion lenskit/tests/test_predict_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

from pytest import approx, mark, raises

from lenskit.data.dataset import from_interactions_df
import lenskit.metrics.predict as pm
import lenskit.util.test as lktu
from lenskit.data.dataset import from_interactions_df


def test_check_missing_empty():
Expand Down
2 changes: 1 addition & 1 deletion lenskit/tests/test_rerank.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from lenskit.algorithms.basic import PopScore
from lenskit.algorithms.bias import Bias
from lenskit.algorithms.ranking import PlackettLuce
from lenskit.util.test import ml_ratings, ml_ds # noqa: F401
from lenskit.util.test import ml_ds, ml_ratings # noqa: F401


def test_plackett_luce_rec(ml_ds):
Expand Down
3 changes: 1 addition & 2 deletions lenskit/tests/test_svd.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@

from pytest import approx, mark

from lenskit.data.dataset import Dataset, from_interactions_df
import lenskit.util.test as lktu
from lenskit.algorithms import svd
from lenskit.data.dataset import Dataset, from_interactions_df
from lenskit.util import clone

_log = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion lenskit/tests/test_topn_recs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

from pytest import approx

from lenskit.data.dataset import Dataset, from_interactions_df
import lenskit.util.test as lktu
from lenskit.algorithms import basic, bias
from lenskit.data.dataset import Dataset, from_interactions_df

simple_df = pd.DataFrame(
{"item": [1, 1, 2, 3], "user": [10, 12, 10, 13], "rating": [4.0, 3.0, 5.0, 2.0]}
Expand Down
4 changes: 2 additions & 2 deletions lenskit/tests/test_util_algos.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import numpy as np
import pandas as pd

from lenskit.data.dataset import Dataset, from_interactions_df
import lenskit.util.test as lktu
from lenskit.algorithms import basic
from lenskit.util.test import ml_ratings, ml_ds # noqa: F401
from lenskit.data.dataset import Dataset, from_interactions_df
from lenskit.util.test import ml_ds, ml_ratings # noqa: F401

simple_df = pd.DataFrame(
{"item": [1, 1, 2, 3], "user": [10, 12, 10, 13], "rating": [4.0, 3.0, 5.0, 2.0]}
Expand Down
5 changes: 2 additions & 3 deletions lenskit/tests/test_vocab.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@

from uuid import UUID

import numpy as np

import hypothesis.strategies as st
from hypothesis import assume, given
import numpy as np
from pytest import raises

from lenskit.data import Vocabulary
Expand Down Expand Up @@ -59,7 +60,6 @@ def test_create_nonunique(keys: list[int | str | UUID]):
)
)
def test_equal(keys: list[int | str | UUID]):
uq = set(keys)
vocab = Vocabulary(keys)

v2 = Vocabulary(keys)
Expand Down Expand Up @@ -210,7 +210,6 @@ def test_add_terms(initial: set[int], new: list[int]):

@given(st.one_of(st.sets(st.integers()), st.sets(st.emails())))
def test_all_terms(initial: set[int] | set[str]):
ni = len(initial)
vocab = Vocabulary(initial)

tl = sorted(initial)
Expand Down

0 comments on commit 28fa380

Please sign in to comment.