Skip to content

Commit 1994f15

Browse files
committed
Merging main, but with two test failures
Signed-off-by: Adam Li <adam2392@gmail.com>
2 parents 1c1ec8c + 9cbcc1f commit 1994f15

File tree

823 files changed

+7737
-6460
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

823 files changed

+7737
-6460
lines changed

.binder/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
--find-links https://pypi.anaconda.org/scipy-wheels-nightly/simple/scikit-learn
1+
--find-links https://pypi.anaconda.org/scientific-python-nightly-wheels/simple/scikit-learn
22
--pre
33
matplotlib
44
scikit-image

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
command: |
1212
source build_tools/shared.sh
1313
# Include pytest compatibility with mypy
14-
pip install pytest flake8 $(get_dep mypy min) $(get_dep black min) cython-lint
14+
pip install pytest ruff $(get_dep mypy min) $(get_dep black min) cython-lint
1515
- run:
1616
name: linting
1717
command: ./build_tools/linting.sh

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ d4aad64b1eb2e42e76f49db2ccfbe4b4660d092b
2828

2929
# PR 26110: Update black to 23.3.0
3030
893d5accaf9d16f447645e704f85a216187564f7
31+
32+
# PR 26649: Add isort and ruff rules
33+
42173fdb34b5aded79664e045cada719dfbe39dc

.github/scripts/label_title_regex.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
"""Labels PRs based on title. Must be run in a github action with the
22
pull_request_target event."""
3-
from github import Github
4-
import os
53
import json
4+
import os
65
import re
76

7+
from github import Github
8+
89
context_dict = json.loads(os.getenv("CONTEXT_GITHUB"))
910

1011
repo = context_dict["repository"]

.github/workflows/lint.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# This linter job on GH actions is used to trigger the commenter bot
2+
# in bot-lint-comment.yml file. It stores the output of the linter to be used
3+
# by the commenter bot.
4+
name: linter
5+
6+
on:
7+
- pull_request_target
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
lint:
15+
runs-on: ubuntu-latest
16+
17+
# setting any permission will set everything else to none for GITHUB_TOKEN
18+
permissions:
19+
pull-requests: none
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v3
24+
with:
25+
ref: ${{ github.event.pull_request.head.sha }}
26+
27+
- name: Set up Python
28+
uses: actions/setup-python@v3
29+
with:
30+
python-version: 3.11
31+
32+
- name: Install dependencies
33+
run: |
34+
source build_tools/shared.sh
35+
# Include pytest compatibility with mypy
36+
pip install pytest ruff $(get_dep mypy min) $(get_dep black min) cython-lint
37+
# we save the versions of the linters to be used in the error message later.
38+
python -c "from importlib.metadata import version; print(f\"ruff={version('ruff')}\")" >> /tmp/versions.txt
39+
python -c "from importlib.metadata import version; print(f\"mypy={version('mypy')}\")" >> /tmp/versions.txt
40+
python -c "from importlib.metadata import version; print(f\"black={version('black')}\")" >> /tmp/versions.txt
41+
python -c "from importlib.metadata import version; print(f\"cython-lint={version('cython-lint')}\")" >> /tmp/versions.txt
42+
43+
- name: Run linting
44+
id: lint-script
45+
# We download the linting script from main, since this workflow is run
46+
# from main itself.
47+
run: |
48+
curl https://raw.githubusercontent.com/${{ github.repository }}/main/build_tools/linting.sh --retry 5 -o ./build_tools/linting.sh
49+
set +e
50+
./build_tools/linting.sh &> /tmp/linting_output.txt
51+
cat /tmp/linting_output.txt
52+
53+
- name: Upload Artifact
54+
if: always()
55+
uses: actions/upload-artifact@v3
56+
with:
57+
name: lint-log
58+
path: |
59+
/tmp/linting_output.txt
60+
/tmp/versions.txt
61+
retention-days: 1
62+
63+
comment:
64+
needs: lint
65+
if: always()
66+
runs-on: ubuntu-latest
67+
68+
# We need these permissions to be able to post / update comments
69+
permissions:
70+
pull-requests: write
71+
issues: write
72+
73+
steps:
74+
- name: Checkout code
75+
uses: actions/checkout@v3
76+
77+
- name: Set up Python
78+
uses: actions/setup-python@v3
79+
with:
80+
python-version: 3.11
81+
82+
- name: Install dependencies
83+
run: python -m pip install requests
84+
85+
- name: Download artifact
86+
id: download-artifact
87+
uses: actions/download-artifact@v3
88+
with:
89+
name: lint-log
90+
91+
- name: Print log
92+
run: cat linting_output.txt
93+
94+
- name: Process Comments
95+
id: process-comments
96+
env:
97+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98+
PR_NUMBER: ${{ github.event.pull_request.number }}
99+
BRANCH_SHA: ${{ github.event.pull_request.head.sha }}
100+
RUN_ID: ${{ github.run_id }}
101+
LOG_FILE: linting_output.txt
102+
VERSIONS_FILE: versions.txt
103+
run: python ./build_tools/get_comment.py

.pre-commit-config.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ repos:
99
rev: 23.3.0
1010
hooks:
1111
- id: black
12-
- repo: https://github.com/pycqa/flake8
13-
rev: 4.0.1
12+
- repo: https://github.com/astral-sh/ruff-pre-commit
13+
# Ruff version.
14+
rev: v0.0.272
1415
hooks:
15-
- id: flake8
16-
types: [file, python]
16+
- id: ruff
17+
args: ["--fix", "--show-source"]
1718
- repo: https://github.com/pre-commit/mirrors-mypy
18-
rev: v0.961
19+
rev: v1.3.0
1920
hooks:
2021
- id: mypy
2122
files: sklearn/

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ doc-noplot: inplace
6161
$(MAKE) -C doc html-noplot
6262

6363
code-analysis:
64-
flake8 sklearn | grep -v __init__ | grep -v external
65-
pylint -E -i y sklearn/ -d E1103,E0611,E1101
64+
build_tools/linting.sh
6665

6766
build-dev:
6867
pip install --verbose --no-build-isolation --editable .

asv_benchmarks/benchmarks/cluster.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from sklearn.cluster import KMeans, MiniBatchKMeans
22

33
from .common import Benchmark, Estimator, Predictor, Transformer
4-
from .datasets import _blobs_dataset, _20newsgroups_highdim_dataset
4+
from .datasets import _20newsgroups_highdim_dataset, _blobs_dataset
55
from .utils import neg_mean_inertia
66

77

asv_benchmarks/benchmarks/common.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import os
1+
import itertools
22
import json
3-
import timeit
3+
import os
44
import pickle
5-
import itertools
5+
import timeit
66
from abc import ABC, abstractmethod
7-
from pathlib import Path
87
from multiprocessing import cpu_count
8+
from pathlib import Path
99

1010
import numpy as np
1111

asv_benchmarks/benchmarks/datasets.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1+
from pathlib import Path
2+
13
import numpy as np
24
import scipy.sparse as sp
35
from joblib import Memory
4-
from pathlib import Path
56

6-
from sklearn.decomposition import TruncatedSVD
77
from sklearn.datasets import (
8-
make_blobs,
98
fetch_20newsgroups,
9+
fetch_olivetti_faces,
1010
fetch_openml,
1111
load_digits,
12-
make_regression,
12+
make_blobs,
1313
make_classification,
14-
fetch_olivetti_faces,
14+
make_regression,
1515
)
16-
from sklearn.preprocessing import MaxAbsScaler, StandardScaler
16+
from sklearn.decomposition import TruncatedSVD
1717
from sklearn.feature_extraction.text import TfidfVectorizer
1818
from sklearn.model_selection import train_test_split
19+
from sklearn.preprocessing import MaxAbsScaler, StandardScaler
1920

2021
# memory location for caching datasets
2122
M = Memory(location=str(Path(__file__).resolve().parent / "cache"))

0 commit comments

Comments
 (0)