Skip to content

Change project layout #12

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

Merged
merged 3 commits into from
Jul 3, 2023
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
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# Caches
__pycache__/
/*cache/
docs/_build/
activate.sh

# IDEs
# Build artifacts
/dist/
/docs/_build/

# IDEs and dev files
activate.sh
.vscode/
10 changes: 10 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ sphinx-issues = "^1.2.0"
numpydoc = "^1.1.0"
matplotlib = "^3.3.3"

[tool.pytest.ini_options]
addopts = [
"--import-mode=importlib",
]
# Flaky tests should be marked as xfail(strict=False),
# this will notify us when a test considered broken starts succeeding.
xfail_strict = true

[tool.ruff]
# TODO: remove `target-version` when switching to PEP 621
target-version = "py39"
Expand All @@ -63,6 +71,8 @@ ignore = [
]
[tool.ruff.per-file-ignores]
"examples/*.py" = ["E402"]
[tool.ruff.isort]
known-first-party = ["sklearn_ann"]

[build-system]
requires = ["setuptools", "poetry-core>=1.0.0"]
Expand Down
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from enum import Enum
from importlib.util import find_spec

import pytest


def assert_row_close(sp_mat, actual_pdist, row=42, thresh=0.01):
row_mat = sp_mat.getrow(row)
Expand Down Expand Up @@ -30,6 +28,8 @@ class needs(Enum):
pynndescent = ("pynndescent",)

def __call__(self, fn=None):
import pytest

what = (
f"package {self.value[0]}"
if len(self.value) == 1
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import numpy as np
import pytest

from .utils import assert_row_close, needs
from sklearn_ann.test_utils import assert_row_close, needs

try:
from ..annoy import AnnoyTransformer
from sklearn_ann.kneighbors.annoy import AnnoyTransformer
except ImportError:
pass

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest
from sklearn.utils.estimator_checks import check_estimator

from .utils import needs
from sklearn_ann.test_utils import needs

try:
from sklearn_ann.kneighbors.annoy import AnnoyTransformer
Expand Down Expand Up @@ -70,6 +70,7 @@ def test_all_estimators(Estimator):


def mark_diagonal_0_xfail(est):
"""Mark flaky tests as xfail(strict=False)."""
# Should probably postprocess these...
reasons = {
PyNNDescentTransformer: "sometimes doesn't return diagonal==0",
Expand All @@ -78,7 +79,7 @@ def mark_diagonal_0_xfail(est):
[val] = est.values
name = val.__name__ if isinstance(val, type) else val
if reason := reasons.get(val):
return add_mark(est, pytest.mark.xfail(reason=f"{name} {reason}"))
return add_mark(est, pytest.mark.xfail(reason=f"{name} {reason}", strict=False))
return est


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from .utils import assert_row_close, needs
from sklearn_ann.test_utils import assert_row_close, needs

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from .utils import assert_row_close, needs
from sklearn_ann.test_utils import assert_row_close, needs

try:
from ..nmslib import NMSlibTransformer
from sklearn_ann.kneighbors.nmslib import NMSlibTransformer
except ImportError:
pass

Expand Down