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
8bd5e897
Unverified
Commit
8bd5e897
authored
Oct 11, 2022
by
Madnex
Committed by
GitHub
Oct 11, 2022
Browse files
[python-package] prefix is_numpy_column_array with _ (#5531)
parent
c35ecfbf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
python-package/lightgbm/basic.py
python-package/lightgbm/basic.py
+3
-3
No files found.
python-package/lightgbm/basic.py
View file @
8bd5e897
...
@@ -182,7 +182,7 @@ def _is_numpy_1d_array(data: Any) -> bool:
...
@@ -182,7 +182,7 @@ def _is_numpy_1d_array(data: Any) -> bool:
return
isinstance
(
data
,
np
.
ndarray
)
and
len
(
data
.
shape
)
==
1
return
isinstance
(
data
,
np
.
ndarray
)
and
len
(
data
.
shape
)
==
1
def
is_numpy_column_array
(
data
:
Any
)
->
bool
:
def
_
is_numpy_column_array
(
data
:
Any
)
->
bool
:
"""Check whether data is a column numpy array."""
"""Check whether data is a column numpy array."""
if
not
isinstance
(
data
,
np
.
ndarray
):
if
not
isinstance
(
data
,
np
.
ndarray
):
return
False
return
False
...
@@ -206,7 +206,7 @@ def _is_1d_collection(data: Any) -> bool:
...
@@ -206,7 +206,7 @@ def _is_1d_collection(data: Any) -> bool:
"""Check whether data is a 1-D collection."""
"""Check whether data is a 1-D collection."""
return
(
return
(
_is_numpy_1d_array
(
data
)
_is_numpy_1d_array
(
data
)
or
is_numpy_column_array
(
data
)
or
_
is_numpy_column_array
(
data
)
or
is_1d_list
(
data
)
or
is_1d_list
(
data
)
or
isinstance
(
data
,
pd_Series
)
or
isinstance
(
data
,
pd_Series
)
)
)
...
@@ -216,7 +216,7 @@ def list_to_1d_numpy(data, dtype=np.float32, name='list'):
...
@@ -216,7 +216,7 @@ def list_to_1d_numpy(data, dtype=np.float32, name='list'):
"""Convert data to numpy 1-D array."""
"""Convert data to numpy 1-D array."""
if
_is_numpy_1d_array
(
data
):
if
_is_numpy_1d_array
(
data
):
return
_cast_numpy_array_to_dtype
(
data
,
dtype
)
return
_cast_numpy_array_to_dtype
(
data
,
dtype
)
elif
is_numpy_column_array
(
data
):
elif
_
is_numpy_column_array
(
data
):
_log_warning
(
'Converting column-vector to 1d array'
)
_log_warning
(
'Converting column-vector to 1d array'
)
array
=
data
.
ravel
()
array
=
data
.
ravel
()
return
_cast_numpy_array_to_dtype
(
array
,
dtype
)
return
_cast_numpy_array_to_dtype
(
array
,
dtype
)
...
...
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