Skip to content

Commit 57e2440

Browse files
committed
Make test fail more clear
1 parent 9ff8141 commit 57e2440

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

README.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@ perform competitively in high dimensional spaces.
5353
Development
5454
===========
5555

56-
This project is managed using Hatch_ and pre-commit_. To get started, run ``pre-commit
57-
install`` and ``hatch env create``. Run all commands using ``hatch run python
58-
<command>`` which will ensure the environment is kept up to date. pre-commit_ comes into
59-
play on every `git commit` after installation.
56+
This project is managed using Hatch_ and pre-commit_.
57+
To get started, run ``pre-commit install``.
58+
pre-commit_ comes into play on every `git commit` after installation.
59+
60+
Use the commands `hatch test` and `hatch run docs:build` to
61+
run the tests and build the documentation, respectively.
6062

6163
Consult ``pyproject.toml`` for which dependency groups and extras exist,
6264
and the Hatch help or user guide for more info on what they are.

docs/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# https://www.sphinx-doc.org/en/master/usage/configuration.html
66

77
import os
8+
from pathlib import PurePosixPath
89

910
# -- Path setup --------------------------------------------------------------
1011

@@ -61,6 +62,6 @@
6162
repository_url="https://github.com/frankier/sklearn-ann",
6263
repository_branch=os.environ.get("READTHEDOCS_GIT_IDENTIFIER", "main"),
6364
)
64-
rtd_links_prefix = "src"
65+
rtd_links_prefix = PurePosixPath("src")
6566

6667
autodoc_mock_imports = ["annoy", "faiss", "pynndescent", "nmslib"]

pyproject.toml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ content-type = "text/x-rst"
5454
path = "README.rst"
5555
start-after = ".. inclusion-marker-do-not-remove\n\n"
5656

57+
[tool.hatch.build.targets.wheel]
58+
packages = ["src/sklearn_ann"]
59+
5760
[tool.pytest.ini_options]
5861
addopts = [
5962
"--import-mode=importlib",
@@ -84,19 +87,14 @@ ignore = [
8487
[tool.ruff.lint.isort]
8588
known-first-party = ["sklearn_ann"]
8689

87-
[tool.hatch.envs.default]
88-
features = [
89-
"tests",
90-
"docs",
91-
"annlibs",
92-
]
90+
[tool.hatch.envs.hatch-test]
91+
features = ["tests", "annlibs"]
92+
default-args = []
9393

94-
[tool.hatch.envs.default.scripts]
95-
test = "pytest {args:tests}"
96-
build-docs = "sphinx-build -M html docs docs/_build"
97-
98-
[tool.hatch.build.targets.wheel]
99-
packages = ["src/sklearn_ann"]
94+
[tool.hatch.envs.docs]
95+
features = ["docs"]
96+
[tool.hatch.envs.docs.scripts]
97+
build = "sphinx-build -M html docs docs/_build"
10098

10199
[build-system]
102100
requires = ["hatchling", "hatch-vcs", "hatch-fancy-pypi-readme"]

tests/test_faiss.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
from sklearn_ann.test_utils import assert_row_close, needs
22

3-
try:
4-
from sklearn_ann.kneighbors.faiss import FAISSTransformer
5-
except ImportError:
6-
pass
7-
83

94
@needs.faiss
105
def test_euclidean(random_small, random_small_pdists):
6+
from sklearn_ann.kneighbors.faiss import FAISSTransformer
7+
118
trans = FAISSTransformer(metric="euclidean")
129
mat = trans.fit_transform(random_small)
1310
euclidean_dist = random_small_pdists["euclidean"]
@@ -16,6 +13,8 @@ def test_euclidean(random_small, random_small_pdists):
1613

1714
@needs.faiss
1815
def test_cosine(random_small, random_small_pdists):
16+
from sklearn_ann.kneighbors.faiss import FAISSTransformer
17+
1918
trans = FAISSTransformer(metric="cosine")
2019
mat = trans.fit_transform(random_small)
2120
cosine_dist = random_small_pdists["cosine"]

0 commit comments

Comments
 (0)