8000 MAINT Parameters validation for datasets.make_moons (#25971) · Veghit/scikit-learn@dd6e210 · GitHub
[go: up one dir, main page]

< 10000 a href="#start-of-content" data-skip-target-assigned="false" class="px-2 py-4 color-bg-accent-emphasis color-fg-on-emphasis show-on-focus js-skip-to-content">Skip to content

Commit dd6e210

Browse files
Théophile BarangerItay
authored andcommitted
MAINT Parameters validation for datasets.make_moons (scikit-learn#25971)
1 parent 1b81168 commit dd6e210

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

sklearn/datasets/_samples_generator.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,14 @@ def make_circles(
778778
return X, y
779779

780780

781+
@validate_params(
782+
{
783+
"n_samples": [Interval(Integral, 1, None, closed="left"), tuple],
784+
"shuffle": ["boolean"],
785+
"noise": [Interval(Real, 0, None, closed="left"), None],
786+
"random_state": ["random_state"],
787+
}
788+
)
781789
def make_moons(n_samples=100, *, shuffle=True, noise=None, random_state=None):
782790
"""Make two interleaving half circles.
783791

sklearn/datasets/tests/test_samples_generator.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -636,12 +636,6 @@ def test_make_moons_unbalanced():
636636
assert X.shape == (12, 2), "X shape mismatch"
637637
assert y.shape == (12,), "y shape mismatch"
638638

639-
with pytest.raises(
640-
ValueError,
641-
match=r"`n_samples` can be either an int " r"or a two-element tuple.",
642-
):
643-
make_moons(n_samples=[1, 2, 3])
644-
645639
with pytest.raises(
646640
ValueError,
647641
match=r"`n_samples` can be either an int " r"or a two-element tuple.",

sklearn/tests/test_public_functions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ def _check_function_param_validation(
137137
"sklearn.datasets.make_gaussian_quantiles",
138138
"sklearn.datasets.make_hastie_10_2",
139139
"sklearn.datasets.make_low_rank_matrix",
140+
"sklearn.datasets.make_moons",
140141
"sklearn.datasets.make_multilabel_classification",
141142
"sklearn.datasets.make_regression",
142143
"sklearn.datasets.make_sparse_coded_signal",

0 commit comments

Comments
 (0)
0