Skip to content

Commit

Permalink
FIx incorrect function name. (#8346)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis committed Oct 17, 2022
1 parent 80e10e0 commit fcddbc9
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions python-package/xgboost/core.py
Expand Up @@ -346,7 +346,7 @@ def ctypes2numpy(cptr: CNumericPtr, length: int, dtype: Type[np.number]) -> np.n
if not isinstance(cptr, ctypes.POINTER(ctype)): # type: ignore
raise RuntimeError(f"expected {ctype} pointer")
res = np.zeros(length, dtype=dtype)
if not ctypes.memmove(res.ctypes.data, cptr, length * res.strides[0]): # type: ignore
if not ctypes.memmove(res.ctypes.data, cptr, length * res.strides[0]):
raise RuntimeError("memmove failed")
return res

Expand Down Expand Up @@ -507,7 +507,7 @@ def _next_wrapper(self, this: None) -> int: # pylint: disable=unused-argument
pointer.
"""
@require_pos_args(True)
@require_keyword_args(True)
def input_data(
data: Any,
*,
Expand Down Expand Up @@ -559,7 +559,7 @@ def next(self, input_data: Callable) -> int:
raise NotImplementedError()


# Notice for `require_pos_args`
# Notice for `require_keyword_args`
# Authors: Olivier Grisel
# Gael Varoquaux
# Andreas Mueller
Expand All @@ -568,7 +568,9 @@ def next(self, input_data: Callable) -> int:
# Nicolas Tresegnie
# Sylvain Marie
# License: BSD 3 clause
def require_pos_args(error: bool) -> Callable[[Callable[..., _T]], Callable[..., _T]]:
def require_keyword_args(
error: bool,
) -> Callable[[Callable[..., _T]], Callable[..., _T]]:
"""Decorator for methods that issues warnings for positional arguments
Using the keyword-only argument syntax in pep 3102, arguments after the
Expand All @@ -583,7 +585,7 @@ def require_pos_args(error: bool) -> Callable[[Callable[..., _T]], Callable[...,
"""

def throw_if(func: Callable[..., _T]) -> Callable[..., _T]:
"""Throw error/warning if there are positional arguments after the asterisk.
"""Throw an error/warning if there are positional arguments after the asterisk.
Parameters
----------
Expand Down Expand Up @@ -624,7 +626,7 @@ def inner_f(*args: Any, **kwargs: Any) -> _T:
return throw_if


_deprecate_positional_args = require_pos_args(False)
_deprecate_positional_args = require_keyword_args(False)


class DMatrix: # pylint: disable=too-many-instance-attributes,too-many-public-methods
Expand Down

0 comments on commit fcddbc9

Please sign in to comment.