cclauss closed pull request #12143: Use dict comprehension to avoid backslash
URL: https://github.com/apache/incubator-mxnet/pull/12143
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/python/mxnet/base.py b/python/mxnet/base.py
index 1bbc121ded9..63befcb9028 100644
--- a/python/mxnet/base.py
+++ b/python/mxnet/base.py
@@ -678,8 +678,7 @@ def get_module_file(module_name):
def write_all_str(module_file, module_all_list):
"""Write the proper __all__ based on available operators."""
- module_file.write(os.linesep)
- module_file.write(os.linesep)
+ module_file.write(os.linesep * 2)
all_str = '__all__ = [' + ', '.join(["'%s'"%s for s in
module_all_list]) + ']'
module_file.write(all_str)
@@ -688,19 +687,16 @@ def write_all_str(module_file, module_all_list):
check_call(_LIB.MXListAllOpNames(ctypes.byref(size),
ctypes.byref(plist)))
- op_names = []
- for i in range(size.value):
- op_names.append(py_str(plist[i]))
+ op_names = [py_str(plist[i]) for i in range(size.value)]
module_op_file = get_module_file("%s.%s.op" % (root_namespace,
module_name))
module_op_all = []
module_internal_file = get_module_file("%s.%s._internal"%(root_namespace,
module_name))
module_internal_all = []
- submodule_dict = {}
- for op_name_prefix in _OP_NAME_PREFIX_LIST:
- submodule_dict[op_name_prefix] =\
- (get_module_file("%s.%s.%s" % (root_namespace, module_name,
- op_name_prefix[1:-1])), [])
+ submodule_dict = {op_name_prefix:
+ (get_module_file("%s.%s.%s" % (root_namespace,
module_name,
+ op_name_prefix[1:-1])),
[])}
+ for op_name_prefix in _OP_NAME_PREFIX_LIST}
for name in op_names:
hdl = OpHandle()
check_call(_LIB.NNGetOpHandle(c_str(name), ctypes.byref(hdl)))
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services