Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIx incorrect function name. #8346

Merged
merged 3 commits into from Oct 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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