lenskit.testing#
LensKit test harnesses and utilities.
This package contains utility code for testing LensKit and its components, including in derived packages. It relies on PyTest and Hypothesis.
Attributes#
Classes#
Common tests for scorer components. Many of these just test that the component |
|
Functions#
|
|
|
Hypothesis generator that produces scored lists. |
|
|
|
|
A demo set of train, test, and recommendation data. |
|
|
|
|
Fixture to load the MovieLens 100K dataset (currently as a data frame). It skips |
|
Fixture to load the MovieLens test dataset. To use this, just include it as |
Fixture to load the MovieLens dataset, without checking for modifications. |
|
Fixture to load the test MovieLens ratings as a data frame. To use this, |
|
|
A demo set of train, test, and recommendation data, from most-popular. |
|
|
|
Set an environment variable & restore it. |
Package Contents#
- lenskit.testing.coo_arrays(shape=None, dtype=nph.floating_dtypes(endianness='=', sizes=[32, 64]), elements=st.floats(-1000000.0, 1000000.0, allow_nan=False, allow_infinity=False, width=32))#
- Return type:
- lenskit.testing.scored_lists(*, n=st.integers(0, 1000), scores=None)#
Hypothesis generator that produces scored lists.
- lenskit.testing.sparse_arrays(*, layout='csr', **kwargs)#
- lenskit.testing.sparse_tensors(*, layout='csr', **kwargs)#
- lenskit.testing.demo_recs()#
A demo set of train, test, and recommendation data.
- Return type:
- lenskit.testing.ml_20m()#
- Return type:
Generator[lenskit.data.Dataset, None, None]
- lenskit.testing.ml_100k()#
Fixture to load the MovieLens 100K dataset (currently as a data frame). It skips the test if the ML100K data is not available.
- Return type:
Generator[pandas.DataFrame, None, None]
- lenskit.testing.ml_100k_zip#
- lenskit.testing.ml_ds(ml_ds_unchecked)#
Fixture to load the MovieLens test dataset. To use this, just include it as a parameter in your test:
def test_thing_with_data(ml_ds: Dataset): ...
Note
This is imported in
conftest.pyso it is always available in LensKit tests.- Parameters:
ml_ds_unchecked (lenskit.data.Dataset)
- Return type:
Generator[lenskit.data.Dataset, None, None]
- lenskit.testing.ml_ds_unchecked()#
Fixture to load the MovieLens dataset, without checking for modifications.
Usually use
ml_ds()instead.- Return type:
Generator[lenskit.data.Dataset, None, None]
- lenskit.testing.ml_ratings()#
Fixture to load the test MovieLens ratings as a data frame. To use this, just include it as a parameter in your test:
def test_thing_with_data(ml_ratings: pd.DataFrame): ...
Note
This is imported in
conftest.pyso it is always available in LensKit tests.- Return type:
Generator[pandas.DataFrame, None, None]
- lenskit.testing.ml_test_dir#
- lenskit.testing.pop_recs()#
A demo set of train, test, and recommendation data, from most-popular.
- Return type:
- lenskit.testing.msweb()#
- Return type:
- lenskit.testing.set_env_var(var, val)#
Set an environment variable & restore it.