Skip to content

Commit 9424993

Browse files
Packaging updates (#986)
* Packaging updates - Use pyproject.toml, hatch, hatch-vcs - Use ruff Closes #984 * restore env * ignore _version
1 parent b3954e9 commit 9424993

File tree

19 files changed

+171
-202
lines changed

19 files changed

+171
-202
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,5 @@ docs/source/auto_examples/
125125
docs/source/examples/mydask.png
126126

127127
dask-worker-space
128+
.direnv
129+
dask_ml/_version.py

.pre-commit-config.yaml

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
repos:
2-
- repo: https://github.com/psf/black
3-
rev: 23.12.1
4-
hooks:
5-
- id: black
6-
language_version: python3
7-
args:
8-
- --target-version=py39
9-
- repo: https://github.com/pycqa/flake8
10-
rev: 7.0.0
11-
hooks:
12-
- id: flake8
13-
language_version: python3
14-
args: ["--ignore=E501,W503,E203,E741,E731"]
15-
- repo: https://github.com/pycqa/isort
16-
rev: 5.13.2
17-
hooks:
18-
- id: isort
19-
language_version: python3
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
# Ruff version.
4+
rev: v0.3.4
5+
hooks:
6+
# Run the linter.
7+
- id: ruff
8+
args: [ --fix ]
9+
# Run the formatter.
10+
- id: ruff-format

dask_ml/__init__.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
1-
from pkg_resources import DistributionNotFound, get_distribution
2-
31
# Ensure we always register tokenizers
4-
from dask_ml.model_selection import _normalize
5-
6-
__all__ = []
7-
8-
try:
9-
__version__ = get_distribution(__name__).version
10-
__all__.append("__version__")
11-
except DistributionNotFound:
12-
# package is not installed
13-
pass
2+
from dask_ml.model_selection import _normalize # noqa: F401
143

4+
from ._version import __version__
155

16-
del DistributionNotFound
17-
del get_distribution
18-
del _normalize
6+
__all__ = ["__version__"]

dask_ml/cluster/spectral.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
2-
"""Algorithms for spectral clustering
3-
"""
2+
"""Algorithms for spectral clustering"""
3+
44
import logging
55

66
import dask.array as da
@@ -272,9 +272,7 @@ def fit(self, X, y=None):
272272
# Eq 16. This is OK when V2 is orthogonal
273273
V2 = da.sqrt(float(n_components) / n) * da.vstack([A2, B2.T]).dot(
274274
U_A[:, :n_clusters]
275-
).dot(
276-
da.diag(1.0 / da.sqrt(S_A[:n_clusters]))
277-
) # (n, k)
275+
).dot(da.diag(1.0 / da.sqrt(S_A[:n_clusters]))) # (n, k)
278276
_log_array(logger, V2, "V2.1")
279277

280278
if isinstance(B2, da.Array):
@@ -366,9 +364,9 @@ def _slice_mostly_sorted(array, keep, rest, ind=None):
366364
slices.append([keep[0]])
367365
windows = zip(keep[:-1], keep[1:])
368366

369-
for l, r in windows:
370-
if r > l + 1: # avoid creating empty slices
371-
slices.append(slice(l + 1, r))
367+
for left, r in windows:
368+
if r > left + 1: # avoid creating empty slices
369+
slices.append(slice(left + 1, r))
372370
slices.append([r])
373371

374372
if keep[-1] < len(array) - 1: # avoid creating empty slices

dask_ml/decomposition/truncated_svd.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,9 @@ def fit(self, X, y=None):
148148
def _check_array(self, X):
149149
if self.n_components >= X.shape[1]:
150150
raise ValueError(
151-
"n_components must be < n_features; "
152-
"got {} >= {}".format(self.n_components, X.shape[1])
151+
"n_components must be < n_features; " "got {} >= {}".format(
152+
self.n_components, X.shape[1]
153+
)
153154
)
154155
return X
155156

dask_ml/ensemble/_blockwise.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def fit(self, X, y, **kwargs):
4141
]
4242
results = [
4343
estimator_.fit(X_, y_, **kwargs)
44-
for estimator_, X_, y_, in zip(estimators, Xs, ys)
44+
for estimator_, X_, y_ in zip(estimators, Xs, ys)
4545
]
4646
results = list(dask.compute(*results))
4747
self.estimators_ = results

dask_ml/impute.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ def fit(self, X, y=None):
3535
allowed_strategies = ["mean", "median", "most_frequent", "constant"]
3636
if self.strategy not in allowed_strategies:
3737
raise ValueError(
38-
"Can only use these strategies: {0} "
39-
" got strategy={1}".format(allowed_strategies, self.strategy)
38+
"Can only use these strategies: {0} " " got strategy={1}".format(
39+
allowed_strategies, self.strategy
40+
)
4041
)
4142

4243
if not (pd.isna(self.missing_values) or self.strategy == "constant"):

dask_ml/linear_model/glm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22
"""Generalized Linear Models for large datasets."""
3+
34
import textwrap
45

56
from dask_glm import algorithms, families

dask_ml/linear_model/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
"""
1+
""" """
32

43
import dask.array as da
54
import dask.dataframe as dd

dask_ml/metrics/scorer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ def get_scorer(scoring: Union[str, Callable], compute: bool = True) -> Callable:
3939
scorer, kwargs = SCORERS[scoring]
4040
except KeyError:
4141
raise ValueError(
42-
"{} is not a valid scoring value. "
43-
"Valid options are {}".format(scoring, sorted(SCORERS))
42+
"{} is not a valid scoring value. " "Valid options are {}".format(
43+
scoring, sorted(SCORERS)
44+
)
4445
)
4546
else:
4647
scorer = scoring

0 commit comments

Comments
 (0)