Skip to content

Commit 38b2471

Browse files
committed
rules for ruff and formatting.
1 parent a8b67c6 commit 38b2471

File tree

3 files changed

+70
-9
lines changed

3 files changed

+70
-9
lines changed

pyproject.toml

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,61 @@ doc = [
7171
[tool.setuptools]
7272
packages = ["radius_clustering"]
7373

74+
[tool.ruff]
75+
# Exclude a variety of commonly ignored directories.
76+
exclude = [
77+
".git",
78+
".git-rewrite",
79+
".pytest_cache",
80+
".ruff_cache",
81+
".venv",
82+
".vscode",
83+
"__pypackages__",
84+
"_build",
85+
"buck-out",
86+
"build",
87+
"dist",
88+
"site-packages",
89+
"venv",
90+
"**.egg-info",
91+
"tests",
92+
"examples",
93+
]
94+
95+
# Same as Black.
96+
line-length = 88
97+
indent-width = 4
98+
7499
[tool.ruff.lint]
75-
select = ["NPY201"]
100+
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
101+
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
102+
# McCabe complexity (`C901`) by default.
103+
select = ["E", "F"]
104+
ignore = []
105+
106+
# Allow fix for all enabled rules (when `--fix`) is provided.
107+
fixable = ["ALL"]
108+
unfixable = []
109+
110+
# Allow unused variables when underscore-prefixed.
111+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
112+
113+
[tool.ruff.format]
114+
# Like Black, use double quotes for strings.
115+
quote-style = "double"
116+
117+
# Like Black, indent with spaces, rather than tabs.
118+
indent-style = "space"
119+
120+
# Like Black, respect magic trailing commas.
121+
skip-magic-trailing-comma = false
122+
123+
# Like Black, automatically detect the appropriate line ending.
124+
line-ending = "auto"
125+
126+
# Enable auto-formatting of code examples in docstrings.
127+
docstring-code-format = true
128+
129+
# Set the line length limit used when formatting code snippets in
130+
# docstrings.
131+
docstring-code-line-length = "dynamic"

radius_clustering/radius_clustering.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
Radius Clustering
33
44
This module provides functionality for Minimum Dominating Set (MDS) based clustering.
5-
It includes methods for solving MDS problems and applying the solutions to clustering tasks.
5+
It includes methods for solving MDS problems and applying the solutions to
6+
clustering tasks.
67
78
This module serves as the main interface for the Radius clustering library.
89
"""
@@ -71,14 +72,17 @@ def fit(self, X, y=None):
7172
>>> from radius_clustering import RadiusClustering
7273
>>> from sklearn import datasets
7374
>>> # Load the Iris dataset
74-
>>> iris = datasets.fetch_openml(name='iris', version=1, parser='auto')
75-
>>> X = iris['data'] # Use dictionary-style access instead of attribute access
76-
>>> rad = RadiusClustering(manner="exact", threshold=1.43).fit(X) #Threshold set to 1.43 because it is the optimal
77-
... #threshold for the Iris dataset
75+
>>> iris = datasets.fetch_openml(name="iris", version=1, parser="auto")
76+
>>> X = iris["data"] # Use dictionary-style access instead of attribute access
77+
>>> rad = RadiusClustering(manner="exact", threshold=1.43).fit(
78+
... X
79+
... ) # Threshold set to 1.43 because it is the optimal
80+
... # threshold for the Iris dataset
7881
>>> rad.centers_
7982
[96, 49, 102]
8083
81-
For examples on common datasets and differences with kmeans, see :ref:`sphx_glr_auto_examples_plot_iris_example.py`
84+
For examples on common datasets and differences with kmeans,
85+
see :ref:`sphx_glr_auto_examples_plot_iris_example.py`
8286
"""
8387
self.X = check_array(X)
8488

@@ -164,7 +168,8 @@ def _compute_effective_radius(self):
164168
"""
165169
Compute the effective radius of the clustering.
166170
167-
The effective radius is the maximum radius among all clusters. That means EffRad = max(R(C_i)) for all i.
171+
The effective radius is the maximum radius among all clusters.
172+
That means EffRad = max(R(C_i)) for all i.
168173
"""
169174
self.effective_radius = np.min(self.dist_mat[:, self.centers_], axis=1).max()
170175

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
if not CPU:
1414
CPU = platform.machine()
1515

16-
if (SYSTEM != "Darwin") and (CPU not in 'arm64'):
16+
if (SYSTEM != "Darwin") and (CPU not in "arm64"):
1717
C_COMPILE_ARGS.append("-march=native")
1818
CXX_COMPILE_ARGS.append("-march=native")
1919
CXX_LINK_ARGS.append("-fopenmp")

0 commit comments

Comments
 (0)