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
df14e607
Unverified
Commit
df14e607
authored
Jun 27, 2022
by
James Lamb
Committed by
GitHub
Jun 27, 2022
Browse files
[python-package] add more type hints in basic.py (#5330)
parent
b6deb9a8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
python-package/lightgbm/basic.py
python-package/lightgbm/basic.py
+4
-4
No files found.
python-package/lightgbm/basic.py
View file @
df14e607
...
@@ -22,7 +22,7 @@ from .libpath import find_lib_path
...
@@ -22,7 +22,7 @@ from .libpath import find_lib_path
ZERO_THRESHOLD
=
1e-35
ZERO_THRESHOLD
=
1e-35
def
_get_sample_count
(
total_nrow
:
int
,
params
:
str
):
def
_get_sample_count
(
total_nrow
:
int
,
params
:
str
)
->
int
:
sample_cnt
=
ctypes
.
c_int
(
0
)
sample_cnt
=
ctypes
.
c_int
(
0
)
_safe_call
(
_LIB
.
LGBM_GetSampleCount
(
_safe_call
(
_LIB
.
LGBM_GetSampleCount
(
ctypes
.
c_int32
(
total_nrow
),
ctypes
.
c_int32
(
total_nrow
),
...
@@ -108,7 +108,7 @@ def _log_callback(msg: bytes) -> None:
...
@@ -108,7 +108,7 @@ def _log_callback(msg: bytes) -> None:
_log_native
(
str
(
msg
.
decode
(
'utf-8'
)))
_log_native
(
str
(
msg
.
decode
(
'utf-8'
)))
def
_load_lib
():
def
_load_lib
()
->
Optional
[
ctypes
.
CDLL
]
:
"""Load LightGBM library."""
"""Load LightGBM library."""
lib_path
=
find_lib_path
()
lib_path
=
find_lib_path
()
if
len
(
lib_path
)
==
0
:
if
len
(
lib_path
)
==
0
:
...
@@ -141,7 +141,7 @@ def _safe_call(ret: int) -> None:
...
@@ -141,7 +141,7 @@ def _safe_call(ret: int) -> None:
raise
LightGBMError
(
_LIB
.
LGBM_GetLastError
().
decode
(
'utf-8'
))
raise
LightGBMError
(
_LIB
.
LGBM_GetLastError
().
decode
(
'utf-8'
))
def
is_numeric
(
obj
)
:
def
is_numeric
(
obj
:
Any
)
->
bool
:
"""Check whether object is a number or not, include numpy number, etc."""
"""Check whether object is a number or not, include numpy number, etc."""
try
:
try
:
float
(
obj
)
float
(
obj
)
...
@@ -289,7 +289,7 @@ def json_default_with_numpy(obj):
...
@@ -289,7 +289,7 @@ def json_default_with_numpy(obj):
return
obj
return
obj
def
param_dict_to_str
(
data
)
:
def
param_dict_to_str
(
data
:
Optional
[
Dict
[
str
,
Any
]])
->
str
:
"""Convert Python dictionary to string, which is passed to C API."""
"""Convert Python dictionary to string, which is passed to C API."""
if
data
is
None
or
not
data
:
if
data
is
None
or
not
data
:
return
""
return
""
...
...
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