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

Use uv to install minimum dependencies #362

Merged
merged 8 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 2 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,8 @@ jobs:
- name: Set up Python deps
run: |
set -e
python -m pip install -U pip wheel
python -m pip install -c min-constraints.txt .[test]
python -m pip install pytest-cov
python -m pip install -U 'uv>=0.1.13'
uv pip install --system --resolution=lowest-direct -e '.[test]'

- name: Inspect environment
run: |
Expand Down
106 changes: 100 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,136 @@

import os
import sys
from importlib import import_module # noqa: F401

sys.path.insert(0, os.path.abspath(".."))

import sphinx_rtd_theme # noqa: F401

import lenskit

# -- Project information -----------------------------------------------------

project = "LensKit"
copyright = "2023 Michael Ekstrand"
copyright = "2018–2024 Drexel University, Boise State University, and collaborators"
author = "Michael D. Ekstrand"

# The short X.Y version
version = ".".join(lenskit.__version__.split(".")[:2])
# The full version, including alpha/beta/rc tags
release = lenskit.__version__


extensions = [
"myst_nb",
"sphinx.ext.napoleon",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.intersphinx",
"sphinx.ext.mathjax",
"sphinxext.opengraph",
"sphinxcontrib.bibtex",
"sphinx_rtd_theme",
]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = ".rst"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path .
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = "sphinx"
highlight_language = "python3"

html_theme = "furo"

html_theme = "sphinx_rtd_theme"
html_theme_options = {
# 'github_user': 'lenskit',
# 'github_repo': 'lkpy',
# 'travis_button': False,
# 'canonical_url': 'https://lkpy.lenskit.org/',
# 'font_family': 'Charter, serif'
# 'font_family': '"Source Sans Pro", "Georgia Pro", Georgia, serif',
# 'font_size': '15px',
# 'head_font_family': '"Merriweather Sans", "Arial", sans-serif',
# 'code_font_size': '1em',
# 'code_font_family': '"Source Code Pro", "Consolas", "Menlo", sans-serif'
}

templates_path = ["_templates"]
html_static_path = ["_static"]

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}


# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = "LensKitdoc"


# -- Options for LaTeX output ------------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}

# -- Extension configuration -------------------------------------------------

# -- Options for intersphinx extension ---------------------------------------

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
"python": ("https://docs.python.org/3/", None),
"pandas": ("http://pandas.pydata.org/pandas-docs/stable/", None),
"numpy": ("https://docs.scipy.org/doc/numpy/", None),
"scipy": ("https://docs.scipy.org/doc/scipy/reference/", None),
"scikit": ("https://scikit-learn.org/stable/", None),
"sklearn": ("https://scikit-learn.org/stable/", None),
"binpickle": ("https://binpickle.lenskit.org/en/stable/", None),
"csr": ("https://csr.lenskit.org/en/latest/", None),
"seedbank": ("https://seedbank.lenskit.org/en/latest/", None),
}

autodoc_default_options = {
"members": True,
"member-order": "bysource"
}
autodoc_default_options = {"members": True, "member-order": "bysource", "show-inheritance": True}
autodoc_typehints = "description"

bibtex_bibfiles = ["lenskit.bib"]
jupyter_execute_notebooks = "off"

# -- Module Canonicalization ------------------------------------------------

# cleanups = {
# 'lenskit': ['Algorithm', 'Recommender', 'Predictor', 'CandidateSelector']
# }

# for module, objects in cleanups.items():
# mod = import_module(module)
# for name in objects:
# obj = getattr(mod, name)
# obj.__module__ = module
1 change: 0 additions & 1 deletion lenskit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
Toolkit for recommender systems research, teaching, and more.
"""


from importlib.metadata import PackageNotFoundError, version

from lenskit.algorithms import * # noqa: F401,F403
Expand Down
4 changes: 2 additions & 2 deletions lenskit/algorithms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
classes (:py:mod:`abc`) representing different algorithm capabilities.
"""

from abc import ABCMeta, abstractmethod
import inspect
from abc import ABCMeta, abstractmethod

__all__ = ["Algorithm", "Recommender", "Predictor", "CandidateSelector"]

Expand Down Expand Up @@ -217,8 +217,8 @@ def rated_items(ratings):
Utility function for converting a series or array into an array of item
IDs. Useful in implementations of :py:meth:`candidates`.
"""
import pandas as pd
import numpy as np
import pandas as pd

if isinstance(ratings, pd.Series):
return ratings.index.values
Expand Down
29 changes: 16 additions & 13 deletions lenskit/algorithms/als.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@
from collections import namedtuple

import numpy as np
from numba import njit, prange

from csr import CSR
from numba import njit, prange
from seedbank import numpy_rng

from .bias import Bias
from .mf_common import MFPredictor
from ..data import sparse_ratings
from .. import util
from ..data import sparse_ratings
from ..math.solve import _dposv
from .bias import Bias
from .mf_common import MFPredictor

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -563,22 +562,26 @@ class ImplicitMF(MFPredictor):
initially defaulted to ``True``, but with a warning. In 0.14 it defaults to ``False``.

Args:
features(int): the number of features to train
iterations(int): the number of iterations to train
reg(float): the regularization factor
weight(float): the scaling weight for positive samples (:math:`\\alpha` in :cite:p:`Hu2008-li`).
features(int):
The number of features to train
iterations(int):
The number of iterations to train
reg(float):
The regularization factor
weight(float):
The scaling weight for positive samples (:math:`\\alpha` in :cite:p:`Hu2008-li`).
use_ratings(bool):
Whether to use the `rating` column, if present. Defaults to ``False``; when ``True``,
the values from the ``rating`` column are used, and multipled by ``weight``; if ``False``,
ImplicitMF treats every rated user-item pair as having a rating of 1.
the values from the ``rating`` column are used, and multipled by ``weight``; if
``False``, ImplicitMF treats every rated user-item pair as having a rating of 1.
method(str):
the training method.

``'cg'`` (the default)
Conjugate gradient method :cite:p:`Takacs2011-ix`.
``'lu'``
A direct implementation of the original implicit-feedback ALS concept :cite:p:`Hu2008-li`
using LU-decomposition to solve for the optimized matrices.
A direct implementation of the original implicit-feedback ALS concept
:cite:p:`Hu2008-li` using LU-decomposition to solve for the optimized matrices.

rng_spec:
Random number generator or state (see :func:`lenskit.util.random.rng`).
Expand Down
5 changes: 2 additions & 3 deletions lenskit/algorithms/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@
import logging
from collections.abc import Iterable, Sequence

import pandas as pd
import numpy as np
import pandas as pd

from ..data import sparse_ratings
from . import Predictor, Recommender, CandidateSelector
from ..util import derivable_rng

from . import CandidateSelector, Predictor, Recommender
from .bias import Bias # noqa: F401
from .ranking import TopN # noqa: F401

Expand Down
6 changes: 3 additions & 3 deletions lenskit/algorithms/funksvd.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
import logging
import time

import pandas as pd
import numpy as np
import numba as n
import numpy as np
import pandas as pd
from seedbank import numpy_rng

try:
from numba.experimental import jitclass
except ImportError:
from numba import jitclass

from .. import util
from .bias import Bias
from .mf_common import MFPredictor
from .. import util

_logger = logging.getLogger(__name__)

Expand Down
Loading
Loading