From ffed95eec08ae4470075147a674a5496336629c6 Mon Sep 17 00:00:00 2001 From: Vadim Khotilovich Date: Sun, 15 May 2016 22:04:38 -0500 Subject: [PATCH] py: replace attr_names() with attributes() --- python-package/xgboost/core.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/python-package/xgboost/core.py b/python-package/xgboost/core.py index aad8b9266..f22ca7ef1 100644 --- a/python-package/xgboost/core.py +++ b/python-package/xgboost/core.py @@ -709,20 +709,21 @@ class Booster(object): else: return None - def attr_names(self): - """Get the names of attributes stored in the Booster. + def attributes(self): + """Get attributes stored in the Booster as a dictionary. Returns ------- - value : list of strings - Returns an empty list if there's no attributes. + result : dictionary of attribute_name: attribute_value pairs of strings. + Returns an empty dict if there's no attributes. """ length = ctypes.c_ulong() sarr = ctypes.POINTER(ctypes.c_char_p)() _check_call(_LIB.XGBoosterGetAttrNames(self.handle, ctypes.byref(length), ctypes.byref(sarr))) - res = from_cstr_to_pystr(sarr, length) + attr_names = from_cstr_to_pystr(sarr, length) + res = {n: self.attr(n) for n in attr_names} return res def set_attr(self, **kwargs):