Skip to content

Commit a3cecdd

Browse files
committed
Switch to ruff, fix doc build (pickle of conf.py)
1 parent 0a31b25 commit a3cecdd

File tree

6 files changed

+21
-18
lines changed

6 files changed

+21
-18
lines changed

.pre-commit-config.yaml

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
default_language_version:
22
python: python3
33
repos:
4+
- repo: https://github.com/astral-sh/ruff-pre-commit
5+
# Ruff version.
6+
rev: v0.5.1
7+
hooks:
8+
# Run the linter.
9+
- id: ruff
410
- repo: https://github.com/ambv/black
511
rev: 24.2.0
612
hooks:
713
- id: black
8-
- repo: https://github.com/pre-commit/pre-commit-hooks
9-
rev: v2.0.0
10-
hooks:
11-
- id: flake8
1214
- repo: https://github.com/kynan/nbstripout
1315
rev: 0.7.1
1416
hooks:

CONTRIBUTING.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ Ready to contribute? Here's how to set up `data_prototype` for local development
7373

7474
Now you can make your changes locally.
7575

76-
5. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox::
76+
5. When you're done making changes, check that your changes pass linting and the tests, including testing other Python versions with tox::
7777

78-
$ flake8 data_prototype tests
78+
$ ruff check
7979
$ python setup.py test
8080
$ tox
8181

data_prototype/image.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111

1212
def _interpolate_nearest(image, x, y):
1313
magnification = 1 # TODO
14-
l, r = x
15-
width = int(((round(r) + 0.5) - (round(l) - 0.5)) * magnification)
14+
lef, rig = x
15+
width = int(((round(rig) + 0.5) - (round(lef) - 0.5)) * magnification)
1616

17-
xpix = np.digitize(np.arange(width), np.linspace(0, r - l, image.shape[1]))
17+
xpix = np.digitize(np.arange(width), np.linspace(0, rig - lef, image.shape[1]))
1818

19-
b, t = y
20-
height = int(((round(t) + 0.5) - (round(b) - 0.5)) * magnification)
21-
ypix = np.digitize(np.arange(height), np.linspace(0, t - b, image.shape[0]))
19+
bot, top = y
20+
height = int(((round(top) + 0.5) - (round(bot) - 0.5)) * magnification)
21+
ypix = np.digitize(np.arange(height), np.linspace(0, top - bot, image.shape[0]))
2222

2323
out = np.empty((height, width, 4))
2424

docs/source/conf.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
# sys.path.insert(0, os.path.abspath('.'))
2424
from pathlib import Path
2525

26+
import data_prototype
27+
2628
# are we running circle CI?
2729
CIRCLECI = "CIRCLECI" in os.environ
2830

@@ -89,7 +91,7 @@ def matplotlib_reduced_latex_scraper(block, block_vars, gallery_conf, **kwargs):
8991
"reference_url": {
9092
"matplotlib": None,
9193
},
92-
"backreferences_dir": Path("api") / Path("_as_gen"),
94+
"backreferences_dir": Path("api", "_as_gen"),
9395
"remove_config_comments": True,
9496
"min_reported_time": 1,
9597
"thumbnail_size": (320, 224),
@@ -126,7 +128,6 @@ def matplotlib_reduced_latex_scraper(block, block_vars, gallery_conf, **kwargs):
126128
# |version| and |release|, also used in various other places throughout the
127129
# built documents.
128130
#
129-
import data_prototype
130131

131132
# The short X.Y version.
132133
version = data_prototype.__version__

examples/mandelbrot.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ def mandelbrot_set(X, Y, maxiter, *, horizon=3, power=2):
2727
N = np.zeros_like(C, dtype=int)
2828
Z = np.zeros_like(C)
2929
for n in range(maxiter):
30-
I = abs(Z) < horizon
31-
N += I
32-
Z[I] = Z[I] ** power + C[I]
30+
mask = abs(Z) < horizon
31+
N += mask
32+
Z[mask] = Z[mask] ** power + C[mask]
3333
N[N == maxiter] = -1
3434
return Z, N
3535

requirements-dev.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
# the documentation) but not necessarily required for _using_ it.
33
codecov
44
coverage
5-
flake8
65
pytest
76
sphinx
87
twine
98
pre-commit
109
black
1110
nbstripout
11+
ruff
1212
# These are dependencies of various sphinx extensions for documentation.
1313
ipython
1414
matplotlib

0 commit comments

Comments
 (0)