From 7db1c631b10916e853ba66cd23dfb9d34a3104ce Mon Sep 17 00:00:00 2001 From: TheJacobKim Date: Sat, 19 Oct 2019 23:22:51 +0900 Subject: [PATCH 1/9] Docstring convetnion for --- python/mxnet/util.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/python/mxnet/util.py b/python/mxnet/util.py index c2dfd85dcfac..7ecdc3d315d9 100644 --- a/python/mxnet/util.py +++ b/python/mxnet/util.py @@ -60,8 +60,7 @@ def get_gpu_memory(gpu_dev_id): def set_np_shape(active): - """ - Turns on/off NumPy shape semantics, in which `()` represents the shape of scalar tensors, + """Turns on/off NumPy shape semantics, in which `()` represents the shape of scalar tensors, and tuples with `0` elements, for example, `(0,)`, `(1, 0, 2)`, represent the shapes of zero-size tensors. This is turned off by default for keeping backward compatibility. @@ -568,8 +567,7 @@ def hybrid_forward(self, F, x, w): def np_ufunc_legal_option(key, value): - """ - Checking if ufunc arguments are legal inputs + """Checking if ufunc arguments are legal inputs Parameters ---------- From dc1824faed1745c824b8a87e27b294afb16ce8fb Mon Sep 17 00:00:00 2001 From: TheJacobKim Date: Sat, 19 Oct 2019 23:25:02 +0900 Subject: [PATCH 2/9] Docstring convention for --- python/mxnet/test_utils.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/python/mxnet/test_utils.py b/python/mxnet/test_utils.py index 6ee37982a124..2bd287d88080 100644 --- a/python/mxnet/test_utils.py +++ b/python/mxnet/test_utils.py @@ -1932,8 +1932,7 @@ def same_array(array1, array2): @contextmanager def discard_stderr(): - """ - Discards error output of a routine if invoked as: + """Discards error output of a routine if invoked as: with discard_stderr(): ... @@ -2321,7 +2320,8 @@ def __exit__(self, ptype, value, trace): def collapse_sum_like(a, shape): """Given `a` as a numpy ndarray, perform reduce_sum on `a` over the axes that do not - exist in `shape`. Note that an ndarray with `shape` must be broadcastable to `a`.""" + exist in `shape`. Note that an ndarray with `shape` must be broadcastable to `a`. + """ assert len(a.shape) >= len(shape) if np.prod(shape) == 0 or a.size == 0: return np.zeros(shape, dtype=a.dtype) @@ -2346,7 +2346,8 @@ def is_cd_run(): def has_tvm_ops(): """Returns True if MXNet is compiled with TVM generated operators. If current ctx - is GPU, it only returns True for CUDA compute capability > 52 where FP16 is supported.""" + is GPU, it only returns True for CUDA compute capability > 52 where FP16 is supported. + """ built_with_tvm_op = _features.is_enabled("TVM_OP") ctx = current_context() if ctx.device_type == 'gpu': @@ -2364,7 +2365,8 @@ def has_tvm_ops(): def is_op_runnable(): """Returns True for all CPU tests. Returns True for GPU tests that are either of the following. 1. Built with USE_TVM_OP=0. - 2. Built with USE_TVM_OP=1, but with compute capability >= 53.""" + 2. Built with USE_TVM_OP=1, but with compute capability >= 53. + """ ctx = current_context() if ctx.device_type == 'gpu': if not _features.is_enabled("TVM_OP"): From 387e02bf20a206a87dd0a4ae4a1e2f689d593bb4 Mon Sep 17 00:00:00 2001 From: TheJacobKim Date: Sat, 19 Oct 2019 23:26:37 +0900 Subject: [PATCH 3/9] Docstring convention for --- python/mxnet/runtime.py | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/python/mxnet/runtime.py b/python/mxnet/runtime.py index 0f7de76937c0..f2e98fe674fa 100644 --- a/python/mxnet/runtime.py +++ b/python/mxnet/runtime.py @@ -26,9 +26,7 @@ from .base import _LIB, check_call class Feature(ctypes.Structure): - """ - Compile time feature description, member fields: `name` and `enabled`. - """ + """Compile time feature description, member fields: `name` and `enabled`.""" _fields_ = [ ("_name", ctypes.c_char_p), ("_enabled", ctypes.c_bool) @@ -36,16 +34,12 @@ class Feature(ctypes.Structure): @property def name(self): - """ - Feature name. - """ + """Feature name.""" return self._name.decode() @property def enabled(self): - """ - True if MXNet was compiled with the given compile-time feature. - """ + """True if MXNet was compiled with the given compile-time feature.""" return self._enabled def __repr__(self): @@ -55,8 +49,7 @@ def __repr__(self): return "✖ {}".format(self.name) def feature_list(): - """ - Check the library for compile-time features. The list of features are maintained in libinfo.h and libinfo.cc + """Check the library for compile-time features. The list of features are maintained in libinfo.h and libinfo.cc Returns ------- @@ -70,9 +63,7 @@ def feature_list(): return features class Features(collections.OrderedDict): - """ - OrderedDict of name to Feature - """ + """OrderedDict of name to Feature""" instance = None def __new__(cls): if cls.instance is None: @@ -84,8 +75,7 @@ def __repr__(self): return str(list(self.values())) def is_enabled(self, feature_name): - """ - Check for a particular feature by name + """Check for a particular feature by name Parameters ---------- From bb9a0eb591df7879e99ec7b3c07d450981fb12c4 Mon Sep 17 00:00:00 2001 From: TheJacobKim Date: Sat, 19 Oct 2019 23:27:04 +0900 Subject: [PATCH 4/9] Docstring convention for --- python/mxnet/rtc.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/mxnet/rtc.py b/python/mxnet/rtc.py index 4dea0e656b7e..5dfc5ea6dfe2 100644 --- a/python/mxnet/rtc.py +++ b/python/mxnet/rtc.py @@ -172,7 +172,8 @@ def get_kernel(self, name, signature): class CudaKernel(object): """Constructs CUDA kernel. Should be created by `CudaModule.get_kernel`, - not intended to be used by users.""" + not intended to be used by users. + """ def __init__(self, handle, name, is_ndarray, dtypes): self.handle = handle self._name = name From 8091f2381ef931f314c9c7021ef448578f4ce976 Mon Sep 17 00:00:00 2001 From: TheJacobKim Date: Sat, 19 Oct 2019 23:28:12 +0900 Subject: [PATCH 5/9] Docstring convention for --- python/mxnet/profiler.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/python/mxnet/profiler.py b/python/mxnet/profiler.py index 7dbc060ed60f..8e8ac87c9e06 100644 --- a/python/mxnet/profiler.py +++ b/python/mxnet/profiler.py @@ -207,8 +207,7 @@ def pause(profile_process='worker'): def resume(profile_process='worker'): - """ - Resume paused profiling. + """Resume paused profiling. Parameters ---------- From bf35e967f7ae9340dccfc8ff747b6fc8b491c11c Mon Sep 17 00:00:00 2001 From: TheJacobKim Date: Sat, 19 Oct 2019 23:30:50 +0900 Subject: [PATCH 6/9] Docstring convention for --- python/mxnet/metric.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/python/mxnet/metric.py b/python/mxnet/metric.py index 07ec2ef4d61d..6e2d66cb9d15 100644 --- a/python/mxnet/metric.py +++ b/python/mxnet/metric.py @@ -153,8 +153,7 @@ def reset(self): self.global_sum_metric = 0.0 def reset_local(self): - """Resets the local portion of the internal evaluation results - to initial state.""" + """Resets the local portion of the internal evaluation results to initial state.""" self.num_inst = 0 self.sum_metric = 0.0 @@ -372,8 +371,7 @@ def reset(self): pass def reset_local(self): - """Resets the local portion of the internal evaluation results - to initial state.""" + """Resets the local portion of the internal evaluation results to initial state.""" try: for metric in self.metrics: metric.reset_local() @@ -592,8 +590,7 @@ def update(self, labels, preds): class _BinaryClassificationMetrics(object): - """ - Private container class for classification metric statistics. True/false positive and + """Private container class for classification metric statistics. True/false positive and true/false negative counts are sufficient statistics for various classification metrics. This class provides the machinery to track those statistics across mini-batches of (label, prediction) pairs. @@ -610,9 +607,7 @@ def __init__(self): self.global_true_negatives = 0 def update_binary_stats(self, label, pred): - """ - Update various binary classification counts for a single (label, pred) - pair. + """Update various binary classification counts for a single (label, pred) pair. Parameters ---------- @@ -691,9 +686,7 @@ def global_fscore(self): return 0. def matthewscc(self, use_global=False): - """ - Calculate the Matthew's Correlation Coefficent - """ + """Calculate the Matthew's Correlation Coefficent""" if use_global: if not self.global_total_examples: return 0. @@ -1604,8 +1597,7 @@ def reset(self): self.reset_local() def reset_local(self): - """Resets the local portion of the internal evaluation results - to initial state.""" + """Resets the local portion of the internal evaluation results to initial state.""" self.num_inst = 0. self.lcm = numpy.zeros((self.k, self.k)) From 054bdc825333a991bd1c7583a576c5363ad24455 Mon Sep 17 00:00:00 2001 From: TheJacobKim Date: Sat, 19 Oct 2019 23:32:15 +0900 Subject: [PATCH 7/9] Docstring convention --- python/mxnet/kvstore.py | 7 ++----- python/mxnet/log.py | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/python/mxnet/kvstore.py b/python/mxnet/kvstore.py index 5d332ff45ecb..61c64ec0984f 100644 --- a/python/mxnet/kvstore.py +++ b/python/mxnet/kvstore.py @@ -31,8 +31,7 @@ from .profiler import set_kvstore_handle def _ctype_key_value(keys, vals): - """ - Returns ctype arrays for the key-value args, and the whether string keys are used. + """Returns ctype arrays for the key-value args, and the whether string keys are used. For internal use only. """ if isinstance(keys, (tuple, list)): @@ -66,9 +65,7 @@ def _ctype_key_value(keys, vals): return (c_keys, c_handle_array(vals), use_str_keys) def _ctype_dict(param_dict): - """ - Returns ctype arrays for keys and values(converted to strings) in a dictionary - """ + """Returns ctype arrays for keys and values(converted to strings) in a dictionary""" assert(isinstance(param_dict, dict)), \ "unexpected type for param_dict: " + str(type(param_dict)) c_keys = c_array(ctypes.c_char_p, [c_str(k) for k in param_dict.keys()]) diff --git a/python/mxnet/log.py b/python/mxnet/log.py index 6dcaedbe6fe7..174e95e40b3c 100644 --- a/python/mxnet/log.py +++ b/python/mxnet/log.py @@ -81,7 +81,6 @@ def getLogger(name=None, filename=None, filemode=None, level=WARNING): """Gets a customized logger. .. note:: `getLogger` is deprecated. Use `get_logger` instead. - """ warnings.warn("getLogger is deprecated, Use get_logger instead.", DeprecationWarning, stacklevel=2) From 72c14aca1fc2671b2644055e0757fcbf22b6f226 Mon Sep 17 00:00:00 2001 From: TheJacobKim Date: Sun, 20 Oct 2019 13:55:41 +0900 Subject: [PATCH 8/9] Revert removing new line --- python/mxnet/log.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/mxnet/log.py b/python/mxnet/log.py index 174e95e40b3c..e4bfea6d88c7 100644 --- a/python/mxnet/log.py +++ b/python/mxnet/log.py @@ -81,6 +81,7 @@ def getLogger(name=None, filename=None, filemode=None, level=WARNING): """Gets a customized logger. .. note:: `getLogger` is deprecated. Use `get_logger` instead. + """ warnings.warn("getLogger is deprecated, Use get_logger instead.", DeprecationWarning, stacklevel=2) From 05b4a61f6e2d022949a0e2a58c41550bb71568fc Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Sun, 20 Oct 2019 15:54:50 +0900 Subject: [PATCH 9/9] Remove white space --- python/mxnet/log.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/mxnet/log.py b/python/mxnet/log.py index e4bfea6d88c7..6dcaedbe6fe7 100644 --- a/python/mxnet/log.py +++ b/python/mxnet/log.py @@ -81,7 +81,7 @@ def getLogger(name=None, filename=None, filemode=None, level=WARNING): """Gets a customized logger. .. note:: `getLogger` is deprecated. Use `get_logger` instead. - + """ warnings.warn("getLogger is deprecated, Use get_logger instead.", DeprecationWarning, stacklevel=2)