[backport] Fix pylint and mypy. (#7563)
* Fix Python typehint with upgraded mypy. (#7513) * Fix pylint. (#7498)
This commit is contained in:
parent
87ddcf308e
commit
ed8ba2150b
@ -229,7 +229,7 @@ def _numpy2ctypes_type(dtype):
|
|||||||
}
|
}
|
||||||
if np.intc is not np.int32: # Windows
|
if np.intc is not np.int32: # Windows
|
||||||
_NUMPY_TO_CTYPES_MAPPING[np.intc] = _NUMPY_TO_CTYPES_MAPPING[np.int32]
|
_NUMPY_TO_CTYPES_MAPPING[np.intc] = _NUMPY_TO_CTYPES_MAPPING[np.int32]
|
||||||
if dtype not in _NUMPY_TO_CTYPES_MAPPING.keys():
|
if dtype not in _NUMPY_TO_CTYPES_MAPPING:
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
f"Supported types: {_NUMPY_TO_CTYPES_MAPPING.keys()}, got: {dtype}"
|
f"Supported types: {_NUMPY_TO_CTYPES_MAPPING.keys()}, got: {dtype}"
|
||||||
)
|
)
|
||||||
@ -266,7 +266,7 @@ def ctypes2cupy(cptr, length, dtype):
|
|||||||
from cupy.cuda.memory import UnownedMemory
|
from cupy.cuda.memory import UnownedMemory
|
||||||
|
|
||||||
CUPY_TO_CTYPES_MAPPING = {cupy.float32: ctypes.c_float, cupy.uint32: ctypes.c_uint}
|
CUPY_TO_CTYPES_MAPPING = {cupy.float32: ctypes.c_float, cupy.uint32: ctypes.c_uint}
|
||||||
if dtype not in CUPY_TO_CTYPES_MAPPING.keys():
|
if dtype not in CUPY_TO_CTYPES_MAPPING:
|
||||||
raise RuntimeError(f"Supported types: {CUPY_TO_CTYPES_MAPPING.keys()}")
|
raise RuntimeError(f"Supported types: {CUPY_TO_CTYPES_MAPPING.keys()}")
|
||||||
addr = ctypes.cast(cptr, ctypes.c_void_p).value
|
addr = ctypes.cast(cptr, ctypes.c_void_p).value
|
||||||
# pylint: disable=c-extension-no-member,no-member
|
# pylint: disable=c-extension-no-member,no-member
|
||||||
|
|||||||
@ -1834,7 +1834,7 @@ class DaskXGBClassifier(DaskScikitLearnBase, XGBClassifierBase):
|
|||||||
vstack = update_wrapper(
|
vstack = update_wrapper(
|
||||||
partial(da.vstack, allow_unknown_chunksizes=True), da.vstack
|
partial(da.vstack, allow_unknown_chunksizes=True), da.vstack
|
||||||
)
|
)
|
||||||
return _cls_predict_proba(getattr(self, "n_classes_", None), predts, vstack)
|
return _cls_predict_proba(getattr(self, "n_classes_", 0), predts, vstack)
|
||||||
|
|
||||||
# pylint: disable=missing-function-docstring
|
# pylint: disable=missing-function-docstring
|
||||||
def predict_proba(
|
def predict_proba(
|
||||||
|
|||||||
@ -814,7 +814,7 @@ def dispatch_data_backend(
|
|||||||
|
|
||||||
def _to_data_type(dtype: str, name: str):
|
def _to_data_type(dtype: str, name: str):
|
||||||
dtype_map = {'float32': 1, 'float64': 2, 'uint32': 3, 'uint64': 4}
|
dtype_map = {'float32': 1, 'float64': 2, 'uint32': 3, 'uint64': 4}
|
||||||
if dtype not in dtype_map.keys():
|
if dtype not in dtype_map:
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
f'Expecting float32, float64, uint32, uint64, got {dtype} ' +
|
f'Expecting float32, float64, uint32, uint64, got {dtype} ' +
|
||||||
f'for {name}.')
|
f'for {name}.')
|
||||||
|
|||||||
@ -1354,9 +1354,7 @@ class XGBClassifier(XGBModel, XGBClassifierBase):
|
|||||||
iteration_range=iteration_range
|
iteration_range=iteration_range
|
||||||
)
|
)
|
||||||
# If model is loaded from a raw booster there's no `n_classes_`
|
# If model is loaded from a raw booster there's no `n_classes_`
|
||||||
return _cls_predict_proba(
|
return _cls_predict_proba(getattr(self, "n_classes_", 0), class_probs, np.vstack)
|
||||||
getattr(self, "n_classes_", None), class_probs, np.vstack
|
|
||||||
)
|
|
||||||
|
|
||||||
def evals_result(self) -> TrainingCallback.EvalsLog:
|
def evals_result(self) -> TrainingCallback.EvalsLog:
|
||||||
"""Return the evaluation results.
|
"""Return the evaluation results.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user