Skip to content

Commit 4afaaa4

Browse files
committed
Autoformat all files
1 parent 9453879 commit 4afaaa4

File tree

9 files changed

+70
-75
lines changed

9 files changed

+70
-75
lines changed

WORKSPACE

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
# External dependency to Google protobuf.
22
http_archive(
3-
name = "protobuf",
4-
url = "http://github.com/google/protobuf/archive/v3.1.0.tar.gz",
5-
sha256 = "0a0ae63cbffc274efb573bdde9a253e3f32e458c41261df51c5dbc5ad541e8f7",
6-
strip_prefix = "protobuf-3.1.0",
7-
)
3+
name="protobuf",
4+
url="http://github.com/google/protobuf/archive/v3.1.0.tar.gz",
5+
sha256="0a0ae63cbffc274efb573bdde9a253e3f32e458c41261df51c5dbc5ad541e8f7",
6+
strip_prefix="protobuf-3.1.0", )
87

98
# External dependency to gtest 1.7.0. This method comes from
109
# https://www.bazel.io/versions/master/docs/tutorial/cpp.html.
1110
new_http_archive(
12-
name = "gtest",
13-
url = "https://github.com/google/googletest/archive/release-1.7.0.zip",
14-
sha256 = "b58cb7547a28b2c718d1e38aee18a3659c9e3ff52440297e965f5edffe34b6d0",
15-
build_file = "third_party/gtest.BUILD",
16-
strip_prefix = "googletest-release-1.7.0",
17-
)
11+
name="gtest",
12+
url="https://github.com/google/googletest/archive/release-1.7.0.zip",
13+
sha256="b58cb7547a28b2c718d1e38aee18a3659c9e3ff52440297e965f5edffe34b6d0",
14+
build_file="third_party/gtest.BUILD",
15+
strip_prefix="googletest-release-1.7.0", )

demo/sentiment/predict.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ def get_index(self, data):
7171
transform word into integer index according to the dictionary.
7272
"""
7373
words = data.strip().split()
74-
word_slot = [
75-
self.word_dict[w] for w in words if w in self.word_dict
76-
]
74+
word_slot = [self.word_dict[w] for w in words if w in self.word_dict]
7775
return word_slot
7876

7977
def batch_predict(self, data_batch):
@@ -85,8 +83,8 @@ def batch_predict(self, data_batch):
8583
if self.label is None:
8684
print("predicting label is %d" % (lab[0]))
8785
else:
88-
print("predicting label is %s" %
89-
(self.label[lab[0]]))
86+
print("predicting label is %s" % (self.label[lab[0]]))
87+
9088

9189
def option_parser():
9290
usage = "python predict.py -n config -w model_dir -d dictionary -i input_file "
@@ -143,9 +141,10 @@ def main():
143141
batch.append([predict.get_index(line)])
144142
if len(batch) == batch_size:
145143
predict.batch_predict(batch)
146-
batch=[]
144+
batch = []
147145
if len(batch) > 0:
148146
predict.batch_predict(batch)
149147

148+
150149
if __name__ == '__main__':
151150
main()

python/paddle/trainer/config_parser.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3364,7 +3364,10 @@ def my_fatal(s):
33643364
logger.critical(s)
33653365
raise Exception()
33663366

3367+
33673368
_parse_config_hooks = set()
3369+
3370+
33683371
def register_parse_config_hook(f):
33693372
"""
33703373
Register a hook function for parse_config. parse_config will invoke the hook
@@ -3373,6 +3376,7 @@ def register_parse_config_hook(f):
33733376
"""
33743377
_parse_config_hooks.add(f)
33753378

3379+
33763380
def parse_config(config_file, config_arg_str):
33773381
'''
33783382
@param config_arg_str: a string of the form var1=val1,var2=val2. It will be

python/paddle/trainer_config_helpers/default_decorators.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,15 @@ def reset(self):
8484

8585
_name_factories = []
8686

87+
8788
def reset_hook():
8889
for factory in _name_factories:
8990
factory.reset()
9091

92+
9193
register_parse_config_hook(reset_hook)
9294

95+
9396
def wrap_name_default(name_prefix=None):
9497
"""
9598
Decorator to set "name" arguments default to "{name_prefix}_{invoke_count}".

python/paddle/trainer_config_helpers/tests/configs/test_config_parser_for_non_file_config.py

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,35 @@
1717
import re
1818
import getopt
1919

20+
2021
def main(print_whole_config, globals, locals):
21-
'''
22+
'''
2223
this test will all test_config.py
2324
'''
24-
cmdstr = """from paddle.trainer.config_parser import parse_config\n"""
25-
importstr = ""
26-
functionstr = ""
25+
cmdstr = """from paddle.trainer.config_parser import parse_config\n"""
26+
importstr = ""
27+
functionstr = ""
28+
29+
for line in sys.stdin:
30+
if re.match("^import", line) or re.match("^from.*import", line):
31+
importstr = importstr + line
32+
else:
33+
functionstr = functionstr + " " + line
2734

28-
for line in sys.stdin:
29-
if re.match("^import", line) or re.match("^from.*import", line):
30-
importstr = importstr + line
35+
cmdstr = cmdstr + importstr + """def configs():\n""" + functionstr
36+
#cmdstr = cmdstr + """def configs():\n""" + importstr + functionstr
37+
if print_whole_config:
38+
cmdstr = cmdstr + """print parse_config(configs, "")"""
3139
else:
32-
functionstr = functionstr + " " + line
40+
cmdstr = cmdstr + """print parse_config(configs, "").model_config"""
3341

34-
cmdstr = cmdstr + importstr + """def configs():\n""" + functionstr
35-
#cmdstr = cmdstr + """def configs():\n""" + importstr + functionstr
36-
if print_whole_config:
37-
cmdstr = cmdstr + """print parse_config(configs, "")"""
38-
else:
39-
cmdstr = cmdstr + """print parse_config(configs, "").model_config"""
42+
exec (cmdstr, globals, locals)
4043

41-
exec(cmdstr, globals, locals)
4244

4345
if __name__ == '__main__':
44-
whole = False
45-
opts, args = getopt.getopt(sys.argv[1:], "", ["whole"])
46-
for op, value in opts:
47-
if op == "--whole":
48-
whole = True
49-
main(whole, globals(), locals())
46+
whole = False
47+
opts, args = getopt.getopt(sys.argv[1:], "", ["whole"])
48+
for op, value in opts:
49+
if op == "--whole":
50+
whole = True
51+
main(whole, globals(), locals())

python/paddle/trainer_config_helpers/tests/test_reset_hook.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
import unittest
1515
from paddle.trainer.config_parser import parse_config
1616

17-
class TestParse(unittest.TestCase):
1817

18+
class TestParse(unittest.TestCase):
1919
def test_parse(self):
20-
a = parse_config(
21-
'trainer_config_helpers/tests/layers_test_config.py', '')
22-
b = parse_config(
23-
'trainer_config_helpers/tests/layers_test_config.py', '')
20+
a = parse_config('trainer_config_helpers/tests/layers_test_config.py',
21+
'')
22+
b = parse_config('trainer_config_helpers/tests/layers_test_config.py',
23+
'')
2424
self.assertEqual(a, b)
2525

2626

third_party/gtest.BUILD

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
cc_library(
2-
name = "main",
3-
srcs = glob(
4-
["src/*.cc"],
5-
exclude = ["src/gtest-all.cc"]
6-
),
7-
hdrs = glob([
8-
"include/**/*.h",
9-
"src/*.h"
10-
]),
11-
copts = ["-Iexternal/gtest/include"],
12-
linkopts = ["-pthread"],
13-
visibility = ["//visibility:public"],
14-
)
2+
name="main",
3+
srcs=glob(
4+
["src/*.cc"], exclude=["src/gtest-all.cc"]),
5+
hdrs=glob(["include/**/*.h", "src/*.h"]),
6+
copts=["-Iexternal/gtest/include"],
7+
linkopts=["-pthread"],
8+
visibility=["//visibility:public"], )

third_party/protobuf_test/BUILD

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,22 @@ licenses(["notice"]) # Apache 2.0
33
load("@protobuf//:protobuf.bzl", "cc_proto_library")
44

55
cc_proto_library(
6-
name = "example_proto",
7-
srcs = ["example.proto"],
8-
protoc = "@protobuf//:protoc",
9-
default_runtime = "@protobuf//:protobuf",
10-
)
6+
name="example_proto",
7+
srcs=["example.proto"],
8+
protoc="@protobuf//:protoc",
9+
default_runtime="@protobuf//:protobuf", )
1110

1211
cc_library(
13-
name = "example_lib",
14-
srcs = ["example_lib.cc"],
15-
hdrs = ["example_lib.h"],
16-
deps = [":example_proto"],
17-
)
12+
name="example_lib",
13+
srcs=["example_lib.cc"],
14+
hdrs=["example_lib.h"],
15+
deps=[":example_proto"], )
1816

1917
cc_test(
20-
name = "example_lib_test",
21-
srcs = ["example_lib_test.cc"],
22-
copts = ["-Iexternal/gtest/include"],
23-
deps =[
18+
name="example_lib_test",
19+
srcs=["example_lib_test.cc"],
20+
copts=["-Iexternal/gtest/include"],
21+
deps=[
2422
"@gtest//:main",
2523
":example_lib",
26-
],
27-
)
24+
], )

third_party/protobuf_test/example_lib.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
namespace third_party {
44
namespace protobuf_test {
55

6-
std::string get_greet(const Greeting& who) {
7-
return "Hello " + who.name();
8-
}
6+
std::string get_greet(const Greeting& who) { return "Hello " + who.name(); }
97

108
} // namespace protobuf_test
119
} // namespace thrid_party

0 commit comments

Comments
 (0)