def run(config, **kwargs): print("Run example training") if hasattr(config, "setup"): config = config.setup() set_seed(config.seed) assert foo()
def test_exclude_code(profiler): foo_code = foo().f_code with profiler: assert foo_code not in profiler.stats profiler.stats.ensure_child(foo_code) assert foo_code in profiler.stats profiler.exclude_code(foo_code) assert foo_code not in profiler.stats profiler.exclude_code(foo_code) assert foo_code not in profiler.stats
def test_profile(): profiler = TracingProfiler() frame = foo() profiler._profile(frame, 'call', None) profiler._profile(frame, 'return', None) assert len(profiler.stats) == 1 stats1 = find_stats(profiler.stats, 'foo') stats2 = find_stats(profiler.stats, 'bar') stats3 = find_stats(profiler.stats, 'baz') assert stats1.own_hits == 0 assert stats2.own_hits == 0 assert stats3.own_hits == 1 assert stats1.deep_hits == 1 assert stats2.deep_hits == 1 assert stats3.deep_hits == 1
def test_profile(): profiler = TracingProfiler() frame = foo() profiler._profile(frame, "call", None) profiler._profile(frame, "return", None) assert len(profiler.stats) == 1 stats1 = find_stats(profiler.stats, "foo") stats2 = find_stats(profiler.stats, "bar") stats3 = find_stats(profiler.stats, "baz") assert stats1.own_hits == 0 assert stats2.own_hits == 0 assert stats3.own_hits == 1 assert stats1.deep_hits == 1 assert stats2.deep_hits == 1 assert stats3.deep_hits == 1
def test_frame_stack(): def to_code_names(frames): code_names = deque() for frame in reversed(frames): code_name = frame.f_code.co_name if code_name not in mock_code_names: break code_names.appendleft(code_name) return list(code_names) frame = foo() frames = frame_stack(frame) assert to_code_names(frames) == ['foo', 'bar', 'baz'] # top frame frames = frame_stack(frame, top_frame=frame.f_back) assert to_code_names(frames) == ['bar', 'baz'] # top code frames = frame_stack(frame, top_code=frame.f_back.f_code) assert to_code_names(frames) == ['bar', 'baz'] # both of top frame and top code frames = frame_stack(frame, top_frame=frame.f_back, top_code=frame.f_back.f_code) assert to_code_names(frames) == ['bar', 'baz']
def run(config, **kwargs): print("Run example training") print(config.seed) assert foo()
image_path = "dataset/train" new_image_path = "dataset/new_train" image_labels = os.listdir(image_path) image_labels.sort() print(image_labels) for name in image_labels: dir = os.path.join(image_path, name) new_dir = os.path.join(new_image_path, name) for x in range(1, 11): file = dir + "/" + "image (" + str(x) + ").jpg" count = 1 image = cv2.imread(file) for i in range(1, 8 + 1):#8 new_image = utils.foo(utils.rotate_image(image, random.uniform(0, 360))) new_file = new_dir + "/" + str(count + 40 * (x - 1)) + ".jpg" cv2.imwrite(new_file, new_image) print(count + 40 * (x - 1)) count += 1 for i in range(1, 7 + 1):#7 new_image = utils.contras_image(image, random.uniform(80, 200) / 100, random.uniform(0, 50) / 10) new_file = new_dir + "/" + str(count + 40 * (x - 1)) + ".jpg" cv2.imwrite(new_file, new_image) print(count + 40 * (x - 1)) count += 1 for i in range(1, 7 + 1):#7 new_image = utils.random_shadow(image) new_file = new_dir + "/" + str(count + 40 * (x - 1)) + ".jpg" cv2.imwrite(new_file, new_image) print(count + 40 * (x - 1))
def main(event, context): a = np.array([1, 2, 3]) foo() return {"array": a.tolist(), "status": "ok"}
def test_repr_frame(): frame = foo() assert repr_frame(frame) == '<string>:9' assert repr_frame(frame.f_back) == '<string>:6'
def test_mock_db_write(): assert foo() == 2
def test_mock_db_write_with_patch_3(): assert foo() == 20
from utils import foo if __name__ == '__main__': foo()