Skip to content

Quentin patch buffers #11

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 2 commits into from
Feb 26, 2025
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
9 changes: 8 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,14 @@ doc = [
]

[tool.setuptools]
packages = ["radius_clustering"]
packages.find = {where = ["src"], include = ["radius_clustering", "radius_clustering.*"]}

[tool.pytest.ini_options]
pythonpath = "src"
testpaths = ["tests"]
addopts = [
"--import-mode=importlib",
]

[tool.ruff]
# Exclude a variety of commonly ignored directories.
Expand Down
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@
extensions = [
Extension(
"radius_clustering.utils._emos",
["radius_clustering/utils/emos.pyx", "radius_clustering/utils/main-emos.c"],
include_dirs=[np.get_include(), "radius_clustering/utils"],
["src/radius_clustering/utils/emos.pyx", "src/radius_clustering/utils/main-emos.c"],
include_dirs=[np.get_include(), "src/radius_clustering/utils"],
extra_compile_args=C_COMPILE_ARGS,
),
Extension(
"radius_clustering.utils._mds_approx",
[
"radius_clustering/utils/mds.pyx",
"radius_clustering/utils/mds_core.cpp",
"radius_clustering/utils/random_manager.cpp",
"src/radius_clustering/utils/mds.pyx",
"src/radius_clustering/utils/mds_core.cpp",
"src/radius_clustering/utils/random_manager.cpp",
],
include_dirs=[np.get_include(), "radius_clustering/utils"],
include_dirs=[np.get_include(), "src/radius_clustering/utils"],
language="c++",
extra_compile_args=CXX_COMPILE_ARGS,
extra_link_args=CXX_LINK_ARGS,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def __init__(self, manner="approx", threshold=0.5):
self.threshold = threshold

def _check_symmetric(self, a, tol=1e-8):
if a.ndim != 2:
raise ValueError("Input must be a 2D array.")
if a.shape[0] != a.shape[1]:
return False
return np.allclose(a, a.T, atol=tol)

def fit(self, X, y=None):
Expand Down Expand Up @@ -172,7 +176,7 @@ def _clustering_approx(self, n):
This function uses the approximation method to solve the MDS problem.
See [casado]_ for more details.
"""
result = solve_mds(n, self.edges.flatten(), self.nb_edges, "test")
result = solve_mds(n, self.edges.flatten().astype(np.int32), self.nb_edges, "test")
self.centers_ = [x for x in result["solution_set"]]
self._mds_exec_time = result["Time"]

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ cdef extern from "mds_core.cpp":

cdef Result iterated_greedy_wrapper(int numNodes, const vector[int]& edges_list, int nb_edges, string name) nogil

def solve_mds(int num_nodes, np.ndarray[int, ndim=1, mode="c"] edges not None, int nb_edges, str name):
def solve_mds(int num_nodes, np.ndarray[np.uint32_t, ndim=1, mode="c"] edges not None, int nb_edges, str name):
"""
Solve the Minimum Dominating Set problem for a given graph.

Expand Down
3 changes: 3 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import sys
from pathlib import Path

Loading