Skip to content

Commit c31b921

Browse files
Merge pull request #49 from scikit-learn-contrib/0.3.X
DOC add random test times to mitigate inconsistent results on different OS
2 parents 80f08cd + b459004 commit c31b921

File tree

4 files changed

+103
-91
lines changed

4 files changed

+103
-91
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,64 +8,17 @@ on:
88
branches: ["main"]
99

1010
jobs:
11-
test:
12-
runs-on: ubuntu-latest
13-
14-
steps:
15-
- uses: actions/checkout@v4
16-
- uses: prefix-dev/[email protected]
17-
with:
18-
environments: default
19-
cache: true
20-
21-
- name: Re-install local
22-
run: |
23-
pixi run rebuild
24-
25-
- name: Lint with ruff
26-
run: |
27-
pixi run lint
28-
- name: Lint with cython-lint
29-
run: |
30-
pixi run cython-lint
31-
- name: Format with black
32-
run: |
33-
pixi run fmt
34-
- name: Type check with mypy
35-
run: |
36-
pixi run type
37-
- name: Test with pytest
38-
run: |
39-
pixi run test
40-
- name: Test with doctest
41-
shell: bash
42-
run: |
43-
pixi run doc
44-
CMD=doctest pixi run doc
45-
- name: Test coverage
46-
shell: bash
47-
run: |
48-
FMT=xml pixi run test-coverage
49-
- name: Upload coverage reports to Codecov
50-
uses: codecov/codecov-action@v5
51-
with:
52-
token: ${{ secrets.CODECOV_TOKEN }}
53-
- name: Build SDist
54-
run: |
55-
pixi run build-sdist
56-
- name: Store artifacts
57-
uses: actions/upload-artifact@v4
58-
with:
59-
name: cibw-sdist
60-
path: dist/*.tar.gz
11+
call-test:
12+
uses: ./.github/workflows/test.yml
13+
secrets: inherit
6114

6215
build:
6316
strategy:
6417
fail-fast: false
6518
matrix:
6619
os: [ubuntu-latest, windows-latest, macos-latest]
6720
runs-on: ${{ matrix.os }}
68-
needs: test
21+
needs: call-test
6922
steps:
7023
- uses: actions/checkout@v4
7124
- name: Build wheels

.github/workflows/test.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Test
2+
3+
on:
4+
workflow_call:
5+
push:
6+
branches: ["*.X"]
7+
pull_request:
8+
branches: ["*.X"]
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: prefix-dev/[email protected]
17+
with:
18+
environments: default
19+
cache: true
20+
21+
- name: Re-install local
22+
run: |
23+
pixi run rebuild
24+
25+
- name: Lint with ruff
26+
run: |
27+
pixi run lint
28+
- name: Lint with cython-lint
29+
run: |
30+
pixi run cython-lint
31+
- name: Format with black
32+
run: |
33+
pixi run fmt
34+
- name: Type check with mypy
35+
run: |
36+
pixi run type
37+
- name: Test with pytest
38+
run: |
39+
pixi run test
40+
- name: Test with doctest
41+
shell: bash
42+
run: |
43+
pixi run doc
44+
CMD=doctest pixi run doc
45+
- name: Test coverage
46+
shell: bash
47+
run: |
48+
FMT=xml pixi run test-coverage
49+
- name: Upload coverage reports to Codecov
50+
uses: codecov/codecov-action@v5
51+
with:
52+
token: ${{ secrets.CODECOV_TOKEN }}
53+
- name: Build SDist
54+
run: |
55+
pixi run build-sdist
56+
- name: Store artifacts
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: cibw-sdist
60+
path: dist/*.tar.gz

examples/plot_pruning.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from sklearn.linear_model import LogisticRegression
2727

2828
data, labels = load_iris(return_X_y=True)
29-
baseline_lr = LogisticRegression(max_iter=110).fit(data, labels)
29+
baseline_lr = LogisticRegression(max_iter=1000).fit(data, labels)
3030

3131
# %%
3232
# Random data pruning
@@ -40,7 +40,7 @@
4040
def _random_pruning(X, y, n_samples_to_select: int, random_state: int):
4141
rng = np.random.default_rng(random_state)
4242
ids_random = rng.choice(y.size, n_samples_to_select, replace=False)
43-
pruned_lr = LogisticRegression(max_iter=110).fit(X[ids_random], y[ids_random])
43+
pruned_lr = LogisticRegression(max_iter=1000).fit(X[ids_random], y[ids_random])
4444
return pruned_lr.coef_, pruned_lr.intercept_
4545

4646

@@ -72,9 +72,9 @@ def _fastcan_pruning(
7272
).fit(X)
7373
atoms = kmeans.cluster_centers_
7474
ids_fastcan = minibatch(
75-
X.T, atoms.T, n_samples_to_select, batch_size=batch_size, tol=1e-6, verbose=0
75+
X.T, atoms.T, n_samples_to_select, batch_size=batch_size, verbose=0
7676
)
77-
pruned_lr = LogisticRegression(max_iter=110).fit(X[ids_fastcan], y[ids_fastcan])
77+
pruned_lr = LogisticRegression(max_iter=1000).fit(X[ids_fastcan], y[ids_fastcan])
7878
return pruned_lr.coef_, pruned_lr.intercept_
7979

8080

@@ -111,4 +111,4 @@ def plot_box(X, y, baseline, n_samples_to_select: int, n_random: int):
111111
plt.show()
112112

113113

114-
plot_box(data, labels, baseline_lr, n_samples_to_select=100, n_random=10)
114+
plot_box(data, labels, baseline_lr, n_samples_to_select=100, n_random=100)

pixi.lock

Lines changed: 34 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)