Skip to content

Commit 26cf5b6

Browse files
authored
scikit-learn compliant zero-weights error (#965)
* sklearn compliant error message on zero weights * Update test * Remove retired runner
1 parent 00091b4 commit 26cf5b6

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

.github/workflows/build_wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ${{ matrix.os }}
1818
strategy:
1919
matrix:
20-
os: [ubuntu-22.04, ubuntu-22.04-arm, windows-2022, macos-13, macos-14]
20+
os: [ubuntu-22.04, ubuntu-22.04-arm, windows-2022, macos-15, macos-15-intel]
2121

2222
steps:
2323
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

src/glum/_validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,6 @@ def check_weights(
212212
if np.any(sample_weight < 0): # type: ignore
213213
raise ValueError("Sample weights must be non-negative.")
214214
if np.sum(sample_weight) == 0: # type: ignore
215-
raise ValueError("Sample weights must have at least one positive element.")
215+
raise ValueError("Sample weights must not all be zero.")
216216

217217
return sample_weight # type: ignore

tests/glm/test_glm_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def test_sample_weights_validation(estimator, kwargs):
8787
sample_weight = [0, 0]
8888
X = [[0], [1]]
8989
y = [1, 2]
90-
with pytest.raises(ValueError, match="must have at least one positive element"):
90+
with pytest.raises(ValueError, match="must not all be zero"):
9191
glm.fit(X, y, sample_weight)
9292

9393
# 5. 1d but with a negative value

0 commit comments

Comments
 (0)