Skip to content

Commit

Permalink
Make test fail more clear
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep committed Jun 18, 2024
1 parent 9ff8141 commit 57e2440
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
10 changes: 6 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ perform competitively in high dimensional spaces.
Development
===========

This project is managed using Hatch_ and pre-commit_. To get started, run ``pre-commit
install`` and ``hatch env create``. Run all commands using ``hatch run python
<command>`` which will ensure the environment is kept up to date. pre-commit_ comes into
play on every `git commit` after installation.
This project is managed using Hatch_ and pre-commit_.
To get started, run ``pre-commit install``.
pre-commit_ comes into play on every `git commit` after installation.

Use the commands `hatch test` and `hatch run docs:build` to
run the tests and build the documentation, respectively.

Consult ``pyproject.toml`` for which dependency groups and extras exist,
and the Hatch help or user guide for more info on what they are.
Expand Down
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html

import os
from pathlib import PurePosixPath

# -- Path setup --------------------------------------------------------------

Expand Down Expand Up @@ -61,6 +62,6 @@
repository_url="https://github.com/frankier/sklearn-ann",
repository_branch=os.environ.get("READTHEDOCS_GIT_IDENTIFIER", "main"),
)
rtd_links_prefix = "src"
rtd_links_prefix = PurePosixPath("src")

autodoc_mock_imports = ["annoy", "faiss", "pynndescent", "nmslib"]
22 changes: 10 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ content-type = "text/x-rst"
path = "README.rst"
start-after = ".. inclusion-marker-do-not-remove\n\n"

[tool.hatch.build.targets.wheel]
packages = ["src/sklearn_ann"]

[tool.pytest.ini_options]
addopts = [
"--import-mode=importlib",
Expand Down Expand Up @@ -84,19 +87,14 @@ ignore = [
[tool.ruff.lint.isort]
known-first-party = ["sklearn_ann"]

[tool.hatch.envs.default]
features = [
"tests",
"docs",
"annlibs",
]
[tool.hatch.envs.hatch-test]
features = ["tests", "annlibs"]
default-args = []

[tool.hatch.envs.default.scripts]
test = "pytest {args:tests}"
build-docs = "sphinx-build -M html docs docs/_build"

[tool.hatch.build.targets.wheel]
packages = ["src/sklearn_ann"]
[tool.hatch.envs.docs]
features = ["docs"]
[tool.hatch.envs.docs.scripts]
build = "sphinx-build -M html docs docs/_build"

[build-system]
requires = ["hatchling", "hatch-vcs", "hatch-fancy-pypi-readme"]
Expand Down
9 changes: 4 additions & 5 deletions tests/test_faiss.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
from sklearn_ann.test_utils import assert_row_close, needs

try:
from sklearn_ann.kneighbors.faiss import FAISSTransformer
except ImportError:
pass


@needs.faiss
def test_euclidean(random_small, random_small_pdists):
from sklearn_ann.kneighbors.faiss import FAISSTransformer

trans = FAISSTransformer(metric="euclidean")
mat = trans.fit_transform(random_small)
euclidean_dist = random_small_pdists["euclidean"]
Expand All @@ -16,6 +13,8 @@ def test_euclidean(random_small, random_small_pdists):

@needs.faiss
def test_cosine(random_small, random_small_pdists):
from sklearn_ann.kneighbors.faiss import FAISSTransformer

trans = FAISSTransformer(metric="cosine")
mat = trans.fit_transform(random_small)
cosine_dist = random_small_pdists["cosine"]
Expand Down

0 comments on commit 57e2440

Please sign in to comment.