From e2f39e528626d3c6093e4e0490e1337d9bf7ff84 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 1 Sep 2016 14:18:20 +0300 Subject: code style --- filters/kernel/shift.py | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/filters/kernel/shift.py b/filters/kernel/shift.py index 4e1e497..b9e586b 100644 --- a/filters/kernel/shift.py +++ b/filters/kernel/shift.py @@ -19,26 +19,18 @@ class Direction(Enum): def gen_kernel(self, distance): radius = distance + r = radius size = 2 * radius + 1 kernel = np.zeros((size, size)) - x, y = radius, radius - if self is Direction.NORTH: - x = -1 - elif self is Direction.NORTH_EAST: - x, y = -1, 0 - elif self is Direction.EAST: - y = 0 - elif self is Direction.SOUTH_EAST: - x, y = 0, 0 - elif self is Direction.SOUTH: - x = 0 - elif self is Direction.SOUTH_WEST: - x, y = 0, -1 - elif self is Direction.WEST: - y = -1 - elif self is Direction.NORTH_WEST: - x, y = -1, -1 + if self is Direction.NORTH: x, y = -1, r + elif self is Direction.NORTH_EAST: x, y = -1, 0 + elif self is Direction.EAST: x, y = r, 0 + elif self is Direction.SOUTH_EAST: x, y = 0, 0 + elif self is Direction.SOUTH: x, y = 0, r + elif self is Direction.SOUTH_WEST: x, y = 0, -1 + elif self is Direction.WEST: x, y = r, -1 + elif self is Direction.NORTH_WEST: x, y = -1, -1 else: raise NotImplementedError('unsupported direction: ' + str(self)) -- cgit v1.2.3