mirror of
https://github.com/wassname/ray.git
synced 2026-09-11 12:43:20 +08:00
Make example applications pep8 compliant. (#553)
* Test examples for pep8 compliance. * Make rl_pong example pep8 compliant. * Make policy gradient example pep8 compliant. * Make lbfgs example pep8 compliant. * Make hyperopt example pep8 compliant. * Make a3c example pep8 compliant. * Make evolution strategies example pep8 compliant. * Make resnet example pep8 compliant. * Fix.
This commit is contained in:
committed by
Alexey Tumanov
parent
9018dffd7f
commit
3ebfd850e1
+20
-16
@@ -2,28 +2,32 @@ from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import numpy as np
|
||||
from datetime import datetime
|
||||
import cProfile, pstats, io
|
||||
import cProfile
|
||||
import io
|
||||
import pstats
|
||||
|
||||
|
||||
def timestamp():
|
||||
return datetime.now().timestamp()
|
||||
return datetime.now().timestamp()
|
||||
|
||||
|
||||
def time_string():
|
||||
return datetime.now().strftime("%Y%m%d_%H_%M_%f")
|
||||
return datetime.now().strftime("%Y%m%d_%H_%M_%f")
|
||||
|
||||
|
||||
class Profiler(object):
|
||||
def __init__(self):
|
||||
self.pr = cProfile.Profile()
|
||||
pass
|
||||
def __init__(self):
|
||||
self.pr = cProfile.Profile()
|
||||
pass
|
||||
|
||||
def __enter__(self):
|
||||
self.pr.enable()
|
||||
def __enter__(self):
|
||||
self.pr.enable()
|
||||
|
||||
def __exit__(self ,type, value, traceback):
|
||||
self.pr.disable()
|
||||
s = io.StringIO()
|
||||
sortby = 'cumtime'
|
||||
ps = pstats.Stats(self.pr, stream=s).sort_stats(sortby)
|
||||
ps.print_stats(.2)
|
||||
print(s.getvalue())
|
||||
def __exit__(self, type, value, traceback):
|
||||
self.pr.disable()
|
||||
s = io.StringIO()
|
||||
sortby = "cumtime"
|
||||
ps = pstats.Stats(self.pr, stream=s).sort_stats(sortby)
|
||||
ps.print_stats(.2)
|
||||
print(s.getvalue())
|
||||
|
||||
Reference in New Issue
Block a user