Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
a7253603
Unverified
Commit
a7253603
authored
Apr 24, 2025
by
Nick Miller
Committed by
GitHub
Apr 24, 2025
Browse files
[python-package] Add specific error messages to some `test_basic` tests (#6887)
Co-authored-by:
Nikita Titov
<
nekit94-08@mail.ru
>
parent
06e94ada
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
tests/python_package_test/test_basic.py
tests/python_package_test/test_basic.py
+7
-4
No files found.
tests/python_package_test/test_basic.py
View file @
a7253603
...
...
@@ -271,22 +271,25 @@ def test_add_features_throws_if_num_data_unequal(rng):
X2
=
rng
.
uniform
(
size
=
(
10
,
1
))
d1
=
lgb
.
Dataset
(
X1
).
construct
()
d2
=
lgb
.
Dataset
(
X2
).
construct
()
with
pytest
.
raises
(
lgb
.
basic
.
LightGBMError
):
with
pytest
.
raises
(
lgb
.
basic
.
LightGBMError
,
match
=
"Cannot add features from other Dataset with a different number of rows"
):
d1
.
add_features_from
(
d2
)
def
test_add_features_throws_if_datasets_unconstructed
(
rng
):
X1
=
rng
.
uniform
(
size
=
(
100
,
1
))
X2
=
rng
.
uniform
(
size
=
(
100
,
1
))
with
pytest
.
raises
(
ValueError
):
err_msg
=
"Both source and target Datasets must be constructed before adding features"
with
pytest
.
raises
(
ValueError
,
match
=
err_msg
):
d1
=
lgb
.
Dataset
(
X1
)
d2
=
lgb
.
Dataset
(
X2
)
d1
.
add_features_from
(
d2
)
with
pytest
.
raises
(
ValueError
):
with
pytest
.
raises
(
ValueError
,
match
=
err_msg
):
d1
=
lgb
.
Dataset
(
X1
).
construct
()
d2
=
lgb
.
Dataset
(
X2
)
d1
.
add_features_from
(
d2
)
with
pytest
.
raises
(
ValueError
):
with
pytest
.
raises
(
ValueError
,
match
=
err_msg
):
d1
=
lgb
.
Dataset
(
X1
)
d2
=
lgb
.
Dataset
(
X2
).
construct
()
d1
.
add_features_from
(
d2
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment