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
a6bf4ad4
Unverified
Commit
a6bf4ad4
authored
Mar 16, 2023
by
James Lamb
Committed by
GitHub
Mar 16, 2023
Browse files
[python-package] fix mypy error about cpu_count() methods (#5786)
parent
54486b4f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
python-package/lightgbm/compat.py
python-package/lightgbm/compat.py
+4
-4
No files found.
python-package/lightgbm/compat.py
View file @
a6bf4ad4
...
@@ -183,18 +183,18 @@ except ImportError:
...
@@ -183,18 +183,18 @@ except ImportError:
try
:
try
:
from
joblib
import
cpu_count
from
joblib
import
cpu_count
def
_LGBMCpuCount
(
only_physical_cores
:
bool
=
True
):
def
_LGBMCpuCount
(
only_physical_cores
:
bool
=
True
)
->
int
:
return
cpu_count
(
only_physical_cores
=
only_physical_cores
)
return
cpu_count
(
only_physical_cores
=
only_physical_cores
)
except
ImportError
:
except
ImportError
:
try
:
try
:
from
psutil
import
cpu_count
from
psutil
import
cpu_count
def
_LGBMCpuCount
(
only_physical_cores
:
bool
=
True
):
def
_LGBMCpuCount
(
only_physical_cores
:
bool
=
True
)
->
int
:
return
cpu_count
(
logical
=
not
only_physical_cores
)
return
cpu_count
(
logical
=
not
only_physical_cores
)
or
1
except
ImportError
:
except
ImportError
:
from
multiprocessing
import
cpu_count
from
multiprocessing
import
cpu_count
def
_LGBMCpuCount
(
only_physical_cores
:
bool
=
True
):
def
_LGBMCpuCount
(
only_physical_cores
:
bool
=
True
)
->
int
:
return
cpu_count
()
return
cpu_count
()
__all__
:
List
[
str
]
=
[]
__all__
:
List
[
str
]
=
[]
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