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
814a01e4
Unverified
Commit
814a01e4
authored
Feb 12, 2023
by
James Lamb
Committed by
GitHub
Feb 12, 2023
Browse files
[python-package] add more type hints (#5694)
parent
e4dc238f
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 @
814a01e4
...
@@ -199,7 +199,7 @@ def _is_numpy_column_array(data: Any) -> bool:
...
@@ -199,7 +199,7 @@ def _is_numpy_column_array(data: Any) -> bool:
return
len
(
shape
)
==
2
and
shape
[
1
]
==
1
return
len
(
shape
)
==
2
and
shape
[
1
]
==
1
def
_cast_numpy_array_to_dtype
(
array
,
dtype
)
:
def
_cast_numpy_array_to_dtype
(
array
:
np
.
ndarray
,
dtype
:
np
.
dtype
)
->
np
.
ndarray
:
"""Cast numpy array to given dtype."""
"""Cast numpy array to given dtype."""
if
array
.
dtype
==
dtype
:
if
array
.
dtype
==
dtype
:
return
array
return
array
...
@@ -514,7 +514,7 @@ _FEATURE_IMPORTANCE_TYPE_MAPPER = {
...
@@ -514,7 +514,7 @@ _FEATURE_IMPORTANCE_TYPE_MAPPER = {
}
}
def
_convert_from_sliced_object
(
data
)
:
def
_convert_from_sliced_object
(
data
:
np
.
ndarray
)
->
np
.
ndarray
:
"""Fix the memory of multi-dimensional sliced object."""
"""Fix the memory of multi-dimensional sliced object."""
if
isinstance
(
data
,
np
.
ndarray
)
and
isinstance
(
data
.
base
,
np
.
ndarray
):
if
isinstance
(
data
,
np
.
ndarray
)
and
isinstance
(
data
.
base
,
np
.
ndarray
):
if
not
data
.
flags
.
c_contiguous
:
if
not
data
.
flags
.
c_contiguous
:
...
@@ -564,7 +564,7 @@ def _c_int_array(data):
...
@@ -564,7 +564,7 @@ def _c_int_array(data):
return
(
ptr_data
,
type_data
,
data
)
# return `data` to avoid the temporary copy is freed
return
(
ptr_data
,
type_data
,
data
)
# return `data` to avoid the temporary copy is freed
def
_check_for_bad_pandas_dtypes
(
pandas_dtypes_series
)
:
def
_check_for_bad_pandas_dtypes
(
pandas_dtypes_series
:
pd_Series
)
->
None
:
float128
=
getattr
(
np
,
'float128'
,
type
(
None
))
float128
=
getattr
(
np
,
'float128'
,
type
(
None
))
def
is_allowed_numpy_dtype
(
dtype
):
def
is_allowed_numpy_dtype
(
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