<EOL>stretch_offset = (x + y + z + w) * STRETCH_CONSTANT_4D<EOL>xs = x + stretch_offset<EOL>ys = y + stretch_offset<EOL>zs = z + stretch_offset<EOL>ws = w + stretch_offset<EOL>xsb = floor(xs)<EOL>ysb = floor(ys)<EOL>zsb = floor(zs)<EOL>wsb = floor(ws)<EOL>squish_offset = (xsb + ysb + zsb + wsb) * SQUISH_CONSTANT_4D<EOL>xb = xsb + squish_offset<EOL>yb = ysb + squish_offset<EOL>zb = zsb + squish_offset<EOL>wb = wsb + squish_offset<EOL>xins = xs - xsb<EOL>yins = ys - ysb<EOL>zins = zs - zsb<EOL>wins = ws - wsb<EOL>in_sum = xins + yins + zins + wins<EOL>dx0 = x - xb<EOL>dy0 = y - yb<EOL>dz0 = z - zb<EOL>dw0 = w - wb<EOL>value = <NUM_LIT:0><EOL>extrapolate = self._extrapolate4d<EOL>if in_sum <= <NUM_LIT:1>: <EOL><INDENT>a_po = <NUM_LIT><EOL>a_score = xins<EOL>b_po = <NUM_LIT><EOL>b_score = yins<EOL>if a_score >= b_score and zins > b_score:<EOL><INDENT>b_score = zins<EOL>b_po = <NUM_LIT><EOL><DEDENT>elif a_score < b_score and zins > a_score:<EOL><INDENT>a_score = zins<EOL>a_po = <NUM_LIT><EOL><DEDENT>if a_score >= b_score and wins > b_score:<EOL><INDENT>b_score = wins<EOL>b_po = <NUM_LIT><EOL><DEDENT>elif a_score < b_score and wins > a_score:<EOL><INDENT>a_score = wins<EOL>a_po = <NUM_LIT><EOL><DEDENT>uins = <NUM_LIT:1> - in_sum<EOL>if uins > a_score or uins > b_score: <EOL><INDENT>c = b_po if (b_score > a_score) else a_po <EOL>if (c & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>xsv_ext0 = xsb - <NUM_LIT:1><EOL>xsv_ext1 = xsv_ext2 = xsb<EOL>dx_ext0 = dx0 + <NUM_LIT:1><EOL>dx_ext1 = dx_ext2 = dx0<EOL><DEDENT>else:<EOL><INDENT>xsv_ext0 = xsv_ext1 = xsv_ext2 = xsb + <NUM_LIT:1><EOL>dx_ext0 = dx_ext1 = dx_ext2 = dx0 - <NUM_LIT:1><EOL><DEDENT>if (c & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>ysv_ext0 = ysv_ext1 = ysv_ext2 = ysb<EOL>dy_ext0 = dy_ext1 = dy_ext2 = dy0<EOL>if (c & <NUM_LIT>) == <NUM_LIT>:<EOL><INDENT>ysv_ext0 -= <NUM_LIT:1><EOL>dy_ext0 += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>ysv_ext1 -= <NUM_LIT:1><EOL>dy_ext1 += <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>ysv_ext0 = ysv_ext1 = ysv_ext2 = ysb + <NUM_LIT:1><EOL>dy_ext0 = dy_ext1 = dy_ext2 = dy0 - <NUM_LIT:1><EOL><DEDENT>if (c & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>zsv_ext0 = zsv_ext1 = zsv_ext2 = zsb<EOL>dz_ext0 = dz_ext1 = dz_ext2 = dz0<EOL>if (c & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>if (c & <NUM_LIT>) == <NUM_LIT>:<EOL><INDENT>zsv_ext0 -= <NUM_LIT:1><EOL>dz_ext0 += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>zsv_ext1 -= <NUM_LIT:1><EOL>dz_ext1 += <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>zsv_ext2 -= <NUM_LIT:1><EOL>dz_ext2 += <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>zsv_ext0 = zsv_ext1 = zsv_ext2 = zsb + <NUM_LIT:1><EOL>dz_ext0 = dz_ext1 = dz_ext2 = dz0 - <NUM_LIT:1><EOL><DEDENT>if (c & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>wsv_ext0 = wsv_ext1 = wsb<EOL>wsv_ext2 = wsb - <NUM_LIT:1><EOL>dw_ext0 = dw_ext1 = dw0<EOL>dw_ext2 = dw0 + <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>wsv_ext0 = wsv_ext1 = wsv_ext2 = wsb + <NUM_LIT:1><EOL>dw_ext0 = dw_ext1 = dw_ext2 = dw0 - <NUM_LIT:1><EOL><DEDENT><DEDENT>else: <EOL><INDENT>c = (a_po | b_po) <EOL>if (c & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>xsv_ext0 = xsv_ext2 = xsb<EOL>xsv_ext1 = xsb - <NUM_LIT:1><EOL>dx_ext0 = dx0 - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dx_ext1 = dx0 + <NUM_LIT:1> - SQUISH_CONSTANT_4D<EOL>dx_ext2 = dx0 - SQUISH_CONSTANT_4D<EOL><DEDENT>else:<EOL><INDENT>xsv_ext0 = xsv_ext1 = xsv_ext2 = xsb + <NUM_LIT:1><EOL>dx_ext0 = dx0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dx_ext1 = dx_ext2 = dx0 - <NUM_LIT:1> - SQUISH_CONSTANT_4D<EOL><DEDENT>if (c & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>ysv_ext0 = ysv_ext1 = ysv_ext2 = ysb<EOL>dy_ext0 = dy0 - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dy_ext1 = dy_ext2 = dy0 - SQUISH_CONSTANT_4D<EOL>if (c & <NUM_LIT>) == <NUM_LIT>:<EOL><INDENT>ysv_ext1 -= <NUM_LIT:1><EOL>dy_ext1 += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>ysv_ext2 -= <NUM_LIT:1><EOL>dy_ext2 += <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>ysv_ext0 = ysv_ext1 = ysv_ext2 = ysb + <NUM_LIT:1><EOL>dy_ext0 = dy0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dy_ext1 = dy_ext2 = dy0 - <NUM_LIT:1> - SQUISH_CONSTANT_4D<EOL><DEDENT>if (c & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>zsv_ext0 = zsv_ext1 = zsv_ext2 = zsb<EOL>dz_ext0 = dz0 - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dz_ext1 = dz_ext2 = dz0 - SQUISH_CONSTANT_4D<EOL>if (c & <NUM_LIT>) == <NUM_LIT>:<EOL><INDENT>zsv_ext1 -= <NUM_LIT:1><EOL>dz_ext1 += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>zsv_ext2 -= <NUM_LIT:1><EOL>dz_ext2 += <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>zsv_ext0 = zsv_ext1 = zsv_ext2 = zsb + <NUM_LIT:1><EOL>dz_ext0 = dz0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dz_ext1 = dz_ext2 = dz0 - <NUM_LIT:1> - SQUISH_CONSTANT_4D<EOL><DEDENT>if (c & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>wsv_ext0 = wsv_ext1 = wsb<EOL>wsv_ext2 = wsb - <NUM_LIT:1><EOL>dw_ext0 = dw0 - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dw_ext1 = dw0 - SQUISH_CONSTANT_4D<EOL>dw_ext2 = dw0 + <NUM_LIT:1> - SQUISH_CONSTANT_4D<EOL><DEDENT>else:<EOL><INDENT>wsv_ext0 = wsv_ext1 = wsv_ext2 = wsb + <NUM_LIT:1><EOL>dw_ext0 = dw0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dw_ext1 = dw_ext2 = dw0 - <NUM_LIT:1> - SQUISH_CONSTANT_4D<EOL><DEDENT><DEDENT>attn0 = <NUM_LIT:2> - dx0 * dx0 - dy0 * dy0 - dz0 * dz0 - dw0 * dw0<EOL>if attn0 > <NUM_LIT:0>:<EOL><INDENT>attn0 *= attn0<EOL>value += attn0 * attn0 * extrapolate(xsb + <NUM_LIT:0>, ysb + <NUM_LIT:0>, zsb + <NUM_LIT:0>, wsb + <NUM_LIT:0>, dx0, dy0, dz0, dw0)<EOL><DEDENT>dx1 = dx0 - <NUM_LIT:1> - SQUISH_CONSTANT_4D<EOL>dy1 = dy0 - <NUM_LIT:0> - SQUISH_CONSTANT_4D<EOL>dz1 = dz0 - <NUM_LIT:0> - SQUISH_CONSTANT_4D<EOL>dw1 = dw0 - <NUM_LIT:0> - SQUISH_CONSTANT_4D<EOL>attn1 = <NUM_LIT:2> - dx1 * dx1 - dy1 * dy1 - dz1 * dz1 - dw1 * dw1<EOL>if attn1 > <NUM_LIT:0>:<EOL><INDENT>attn1 *= attn1<EOL>value += attn1 * attn1 * extrapolate(xsb + <NUM_LIT:1>, ysb + <NUM_LIT:0>, zsb + <NUM_LIT:0>, wsb + <NUM_LIT:0>, dx1, dy1, dz1, dw1)<EOL><DEDENT>dx2 = dx0 - <NUM_LIT:0> - SQUISH_CONSTANT_4D<EOL>dy2 = dy0 - <NUM_LIT:1> - SQUISH_CONSTANT_4D<EOL>dz2 = dz1<EOL>dw2 = dw1<EOL>attn2 = <NUM_LIT:2> - dx2 * dx2 - dy2 * dy2 - dz2 * dz2 - dw2 * dw2<EOL>if attn2 > <NUM_LIT:0>:<EOL><INDENT>attn2 *= attn2<EOL>value += attn2 * attn2 * extrapolate(xsb + <NUM_LIT:0>, ysb + <NUM_LIT:1>, zsb + <NUM_LIT:0>, wsb + <NUM_LIT:0>, dx2, dy2, dz2, dw2)<EOL><DEDENT>dx3 = dx2<EOL>dy3 = dy1<EOL>dz3 = dz0 - <NUM_LIT:1> - SQUISH_CONSTANT_4D<EOL>dw3 = dw1<EOL>attn3 = <NUM_LIT:2> - dx3 * dx3 - dy3 * dy3 - dz3 * dz3 - dw3 * dw3<EOL>if attn3 > <NUM_LIT:0>:<EOL><INDENT>attn3 *= attn3<EOL>value += attn3 * attn3 * extrapolate(xsb + <NUM_LIT:0>, ysb + <NUM_LIT:0>, zsb + <NUM_LIT:1>, wsb + <NUM_LIT:0>, dx3, dy3, dz3, dw3)<EOL><DEDENT>dx4 = dx2<EOL>dy4 = dy1<EOL>dz4 = dz1<EOL>dw4 = dw0 - <NUM_LIT:1> - SQUISH_CONSTANT_4D<EOL>attn4 = <NUM_LIT:2> - dx4 * dx4 - dy4 * dy4 - dz4 * dz4 - dw4 * dw4<EOL>if attn4 > <NUM_LIT:0>:<EOL><INDENT>attn4 *= attn4<EOL>value += attn4 * attn4 * extrapolate(xsb + <NUM_LIT:0>, ysb + <NUM_LIT:0>, zsb + <NUM_LIT:0>, wsb + <NUM_LIT:1>, dx4, dy4, dz4, dw4)<EOL><DEDENT><DEDENT>elif in_sum >= <NUM_LIT:3>: <EOL><INDENT>a_po = <NUM_LIT><EOL>a_score = xins<EOL>b_po = <NUM_LIT><EOL>b_score = yins<EOL>if a_score <= b_score and zins < b_score:<EOL><INDENT>b_score = zins<EOL>b_po = <NUM_LIT><EOL><DEDENT>elif a_score > b_score and zins < a_score:<EOL><INDENT>a_score = zins<EOL>a_po = <NUM_LIT><EOL><DEDENT>if a_score <= b_score and wins < b_score:<EOL><INDENT>b_score = wins<EOL>b_po = <NUM_LIT><EOL><DEDENT>elif a_score > b_score and wins < a_score:<EOL><INDENT>a_score = wins<EOL>a_po = <NUM_LIT><EOL><DEDENT>uins = <NUM_LIT:4> - in_sum<EOL>if uins < a_score or uins < b_score: <EOL><INDENT>c = b_po if (b_score < a_score) else a_po <EOL>if (c & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>xsv_ext0 = xsb + <NUM_LIT:2><EOL>xsv_ext1 = xsv_ext2 = xsb + <NUM_LIT:1><EOL>dx_ext0 = dx0 - <NUM_LIT:2> - <NUM_LIT:4> * SQUISH_CONSTANT_4D<EOL>dx_ext1 = dx_ext2 = dx0 - <NUM_LIT:1> - <NUM_LIT:4> * SQUISH_CONSTANT_4D<EOL><DEDENT>else:<EOL><INDENT>xsv_ext0 = xsv_ext1 = xsv_ext2 = xsb<EOL>dx_ext0 = dx_ext1 = dx_ext2 = dx0 - <NUM_LIT:4> * SQUISH_CONSTANT_4D<EOL><DEDENT>if (c & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>ysv_ext0 = ysv_ext1 = ysv_ext2 = ysb + <NUM_LIT:1><EOL>dy_ext0 = dy_ext1 = dy_ext2 = dy0 - <NUM_LIT:1> - <NUM_LIT:4> * SQUISH_CONSTANT_4D<EOL>if (c & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>ysv_ext1 += <NUM_LIT:1><EOL>dy_ext1 -= <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>ysv_ext0 += <NUM_LIT:1><EOL>dy_ext0 -= <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>ysv_ext0 = ysv_ext1 = ysv_ext2 = ysb<EOL>dy_ext0 = dy_ext1 = dy_ext2 = dy0 - <NUM_LIT:4> * SQUISH_CONSTANT_4D<EOL><DEDENT>if (c & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>zsv_ext0 = zsv_ext1 = zsv_ext2 = zsb + <NUM_LIT:1><EOL>dz_ext0 = dz_ext1 = dz_ext2 = dz0 - <NUM_LIT:1> - <NUM_LIT:4> * SQUISH_CONSTANT_4D<EOL>if (c & <NUM_LIT>) != <NUM_LIT>:<EOL><INDENT>if (c & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>zsv_ext0 += <NUM_LIT:1><EOL>dz_ext0 -= <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>zsv_ext1 += <NUM_LIT:1><EOL>dz_ext1 -= <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>zsv_ext2 += <NUM_LIT:1><EOL>dz_ext2 -= <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>zsv_ext0 = zsv_ext1 = zsv_ext2 = zsb<EOL>dz_ext0 = dz_ext1 = dz_ext2 = dz0 - <NUM_LIT:4> * SQUISH_CONSTANT_4D<EOL><DEDENT>if (c & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>wsv_ext0 = wsv_ext1 = wsb + <NUM_LIT:1><EOL>wsv_ext2 = wsb + <NUM_LIT:2><EOL>dw_ext0 = dw_ext1 = dw0 - <NUM_LIT:1> - <NUM_LIT:4> * SQUISH_CONSTANT_4D<EOL>dw_ext2 = dw0 - <NUM_LIT:2> - <NUM_LIT:4> * SQUISH_CONSTANT_4D<EOL><DEDENT>else:<EOL><INDENT>wsv_ext0 = wsv_ext1 = wsv_ext2 = wsb<EOL>dw_ext0 = dw_ext1 = dw_ext2 = dw0 - <NUM_LIT:4> * SQUISH_CONSTANT_4D<EOL><DEDENT><DEDENT>else: <EOL><INDENT>c = (a_po & b_po) <EOL>if (c & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>xsv_ext0 = xsv_ext2 = xsb + <NUM_LIT:1><EOL>xsv_ext1 = xsb + <NUM_LIT:2><EOL>dx_ext0 = dx0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dx_ext1 = dx0 - <NUM_LIT:2> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>dx_ext2 = dx0 - <NUM_LIT:1> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL><DEDENT>else:<EOL><INDENT>xsv_ext0 = xsv_ext1 = xsv_ext2 = xsb<EOL>dx_ext0 = dx0 - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dx_ext1 = dx_ext2 = dx0 - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL><DEDENT>if (c & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>ysv_ext0 = ysv_ext1 = ysv_ext2 = ysb + <NUM_LIT:1><EOL>dy_ext0 = dy0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dy_ext1 = dy_ext2 = dy0 - <NUM_LIT:1> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>if (c & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>ysv_ext2 += <NUM_LIT:1><EOL>dy_ext2 -= <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>ysv_ext1 += <NUM_LIT:1><EOL>dy_ext1 -= <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>ysv_ext0 = ysv_ext1 = ysv_ext2 = ysb<EOL>dy_ext0 = dy0 - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dy_ext1 = dy_ext2 = dy0 - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL><DEDENT>if (c & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>zsv_ext0 = zsv_ext1 = zsv_ext2 = zsb + <NUM_LIT:1><EOL>dz_ext0 = dz0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dz_ext1 = dz_ext2 = dz0 - <NUM_LIT:1> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>if (c & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>zsv_ext2 += <NUM_LIT:1><EOL>dz_ext2 -= <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>zsv_ext1 += <NUM_LIT:1><EOL>dz_ext1 -= <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>zsv_ext0 = zsv_ext1 = zsv_ext2 = zsb<EOL>dz_ext0 = dz0 - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dz_ext1 = dz_ext2 = dz0 - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL><DEDENT>if (c & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>wsv_ext0 = wsv_ext1 = wsb + <NUM_LIT:1><EOL>wsv_ext2 = wsb + <NUM_LIT:2><EOL>dw_ext0 = dw0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dw_ext1 = dw0 - <NUM_LIT:1> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>dw_ext2 = dw0 - <NUM_LIT:2> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL><DEDENT>else:<EOL><INDENT>wsv_ext0 = wsv_ext1 = wsv_ext2 = wsb<EOL>dw_ext0 = dw0 - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dw_ext1 = dw_ext2 = dw0 - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL><DEDENT><DEDENT>dx4 = dx0 - <NUM_LIT:1> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>dy4 = dy0 - <NUM_LIT:1> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>dz4 = dz0 - <NUM_LIT:1> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>dw4 = dw0 - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>attn4 = <NUM_LIT:2> - dx4 * dx4 - dy4 * dy4 - dz4 * dz4 - dw4 * dw4<EOL>if attn4 > <NUM_LIT:0>:<EOL><INDENT>attn4 *= attn4<EOL>value += attn4 * attn4 * extrapolate(xsb + <NUM_LIT:1>, ysb + <NUM_LIT:1>, zsb + <NUM_LIT:1>, wsb + <NUM_LIT:0>, dx4, dy4, dz4, dw4)<EOL><DEDENT>dx3 = dx4<EOL>dy3 = dy4<EOL>dz3 = dz0 - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>dw3 = dw0 - <NUM_LIT:1> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>attn3 = <NUM_LIT:2> - dx3 * dx3 - dy3 * dy3 - dz3 * dz3 - dw3 * dw3<EOL>if attn3 > <NUM_LIT:0>:<EOL><INDENT>attn3 *= attn3<EOL>value += attn3 * attn3 * extrapolate(xsb + <NUM_LIT:1>, ysb + <NUM_LIT:1>, zsb + <NUM_LIT:0>, wsb + <NUM_LIT:1>, dx3, dy3, dz3, dw3)<EOL><DEDENT>dx2 = dx4<EOL>dy2 = dy0 - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>dz2 = dz4<EOL>dw2 = dw3<EOL>attn2 = <NUM_LIT:2> - dx2 * dx2 - dy2 * dy2 - dz2 * dz2 - dw2 * dw2<EOL>if attn2 > <NUM_LIT:0>:<EOL><INDENT>attn2 *= attn2<EOL>value += attn2 * attn2 * extrapolate(xsb + <NUM_LIT:1>, ysb + <NUM_LIT:0>, zsb + <NUM_LIT:1>, wsb + <NUM_LIT:1>, dx2, dy2, dz2, dw2)<EOL><DEDENT>dx1 = dx0 - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>dz1 = dz4<EOL>dy1 = dy4<EOL>dw1 = dw3<EOL>attn1 = <NUM_LIT:2> - dx1 * dx1 - dy1 * dy1 - dz1 * dz1 - dw1 * dw1<EOL>if attn1 > <NUM_LIT:0>:<EOL><INDENT>attn1 *= attn1<EOL>value += attn1 * attn1 * extrapolate(xsb + <NUM_LIT:0>, ysb + <NUM_LIT:1>, zsb + <NUM_LIT:1>, wsb + <NUM_LIT:1>, dx1, dy1, dz1, dw1)<EOL><DEDENT>dx0 = dx0 - <NUM_LIT:1> - <NUM_LIT:4> * SQUISH_CONSTANT_4D<EOL>dy0 = dy0 - <NUM_LIT:1> - <NUM_LIT:4> * SQUISH_CONSTANT_4D<EOL>dz0 = dz0 - <NUM_LIT:1> - <NUM_LIT:4> * SQUISH_CONSTANT_4D<EOL>dw0 = dw0 - <NUM_LIT:1> - <NUM_LIT:4> * SQUISH_CONSTANT_4D<EOL>attn0 = <NUM_LIT:2> - dx0 * dx0 - dy0 * dy0 - dz0 * dz0 - dw0 * dw0<EOL>if attn0 > <NUM_LIT:0>:<EOL><INDENT>attn0 *= attn0<EOL>value += attn0 * attn0 * extrapolate(xsb + <NUM_LIT:1>, ysb + <NUM_LIT:1>, zsb + <NUM_LIT:1>, wsb + <NUM_LIT:1>, dx0, dy0, dz0, dw0)<EOL><DEDENT><DEDENT>elif in_sum <= <NUM_LIT:2>: <EOL><INDENT>a_is_bigger_side = True<EOL>b_is_bigger_side = True<EOL>if xins + yins > zins + wins:<EOL><INDENT>a_score = xins + yins<EOL>a_po = <NUM_LIT><EOL><DEDENT>else:<EOL><INDENT>a_score = zins + wins<EOL>a_po = <NUM_LIT><EOL><DEDENT>if xins + zins > yins + wins:<EOL><INDENT>b_score = xins + zins<EOL>b_po = <NUM_LIT><EOL><DEDENT>else:<EOL><INDENT>b_score = yins + wins<EOL>b_po = <NUM_LIT><EOL><DEDENT>if xins + wins > yins + zins:<EOL><INDENT>score = xins + wins<EOL>if a_score >= b_score and score > b_score:<EOL><INDENT>b_score = score<EOL>b_po = <NUM_LIT><EOL><DEDENT>elif a_score < b_score and score > a_score:<EOL><INDENT>a_score = score<EOL>a_po = <NUM_LIT><EOL><DEDENT><DEDENT>else:<EOL><INDENT>score = yins + zins<EOL>if a_score >= b_score and score > b_score:<EOL><INDENT>b_score = score<EOL>b_po = <NUM_LIT><EOL><DEDENT>elif a_score < b_score and score > a_score:<EOL><INDENT>a_score = score<EOL>a_po = <NUM_LIT><EOL><DEDENT><DEDENT>p1 = <NUM_LIT:2> - in_sum + xins<EOL>if a_score >= b_score and p1 > b_score:<EOL><INDENT>b_score = p1<EOL>b_po = <NUM_LIT><EOL>b_is_bigger_side = False<EOL><DEDENT>elif a_score < b_score and p1 > a_score:<EOL><INDENT>a_score = p1<EOL>a_po = <NUM_LIT><EOL>a_is_bigger_side = False<EOL><DEDENT>p2 = <NUM_LIT:2> - in_sum + yins<EOL>if a_score >= b_score and p2 > b_score:<EOL><INDENT>b_score = p2<EOL>b_po = <NUM_LIT><EOL>b_is_bigger_side = False<EOL><DEDENT>elif a_score < b_score and p2 > a_score:<EOL><INDENT>a_score = p2<EOL>a_po = <NUM_LIT><EOL>a_is_bigger_side = False<EOL><DEDENT>p3 = <NUM_LIT:2> - in_sum + zins<EOL>if a_score >= b_score and p3 > b_score:<EOL><INDENT>b_score = p3<EOL>b_po = <NUM_LIT><EOL>b_is_bigger_side = False<EOL><DEDENT>elif a_score < b_score and p3 > a_score:<EOL><INDENT>a_score = p3<EOL>a_po = <NUM_LIT><EOL>a_is_bigger_side = False<EOL><DEDENT>p4 = <NUM_LIT:2> - in_sum + wins<EOL>if a_score >= b_score and p4 > b_score:<EOL><INDENT>b_po = <NUM_LIT><EOL>b_is_bigger_side = False<EOL><DEDENT>elif a_score < b_score and p4 > a_score:<EOL><INDENT>a_po = <NUM_LIT><EOL>a_is_bigger_side = False<EOL><DEDENT>if a_is_bigger_side == b_is_bigger_side:<EOL><INDENT>if a_is_bigger_side: <EOL><INDENT>c1 = (a_po | b_po)<EOL>c2 = (a_po & b_po)<EOL>if (c1 & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>xsv_ext0 = xsb<EOL>xsv_ext1 = xsb - <NUM_LIT:1><EOL>dx_ext0 = dx0 - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>dx_ext1 = dx0 + <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL><DEDENT>else:<EOL><INDENT>xsv_ext0 = xsv_ext1 = xsb + <NUM_LIT:1><EOL>dx_ext0 = dx0 - <NUM_LIT:1> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>dx_ext1 = dx0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL><DEDENT>if (c1 & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>ysv_ext0 = ysb<EOL>ysv_ext1 = ysb - <NUM_LIT:1><EOL>dy_ext0 = dy0 - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>dy_ext1 = dy0 + <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL><DEDENT>else:<EOL><INDENT>ysv_ext0 = ysv_ext1 = ysb + <NUM_LIT:1><EOL>dy_ext0 = dy0 - <NUM_LIT:1> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>dy_ext1 = dy0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL><DEDENT>if (c1 & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>zsv_ext0 = zsb<EOL>zsv_ext1 = zsb - <NUM_LIT:1><EOL>dz_ext0 = dz0 - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>dz_ext1 = dz0 + <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL><DEDENT>else:<EOL><INDENT>zsv_ext0 = zsv_ext1 = zsb + <NUM_LIT:1><EOL>dz_ext0 = dz0 - <NUM_LIT:1> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>dz_ext1 = dz0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL><DEDENT>if (c1 & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>wsv_ext0 = wsb<EOL>wsv_ext1 = wsb - <NUM_LIT:1><EOL>dw_ext0 = dw0 - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>dw_ext1 = dw0 + <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL><DEDENT>else:<EOL><INDENT>wsv_ext0 = wsv_ext1 = wsb + <NUM_LIT:1><EOL>dw_ext0 = dw0 - <NUM_LIT:1> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>dw_ext1 = dw0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL><DEDENT>xsv_ext2 = xsb<EOL>ysv_ext2 = ysb<EOL>zsv_ext2 = zsb<EOL>wsv_ext2 = wsb<EOL>dx_ext2 = dx0 - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dy_ext2 = dy0 - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dz_ext2 = dz0 - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dw_ext2 = dw0 - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>if (c2 & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>xsv_ext2 += <NUM_LIT:2><EOL>dx_ext2 -= <NUM_LIT:2><EOL><DEDENT>elif (c2 & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>ysv_ext2 += <NUM_LIT:2><EOL>dy_ext2 -= <NUM_LIT:2><EOL><DEDENT>elif (c2 & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>zsv_ext2 += <NUM_LIT:2><EOL>dz_ext2 -= <NUM_LIT:2><EOL><DEDENT>else:<EOL><INDENT>wsv_ext2 += <NUM_LIT:2><EOL>dw_ext2 -= <NUM_LIT:2><EOL><DEDENT><DEDENT>else: <EOL><INDENT>xsv_ext2 = xsb<EOL>ysv_ext2 = ysb<EOL>zsv_ext2 = zsb<EOL>wsv_ext2 = wsb<EOL>dx_ext2 = dx0<EOL>dy_ext2 = dy0<EOL>dz_ext2 = dz0<EOL>dw_ext2 = dw0<EOL>c = (a_po | b_po)<EOL>if (c & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>xsv_ext0 = xsb - <NUM_LIT:1><EOL>xsv_ext1 = xsb<EOL>dx_ext0 = dx0 + <NUM_LIT:1> - SQUISH_CONSTANT_4D<EOL>dx_ext1 = dx0 - SQUISH_CONSTANT_4D<EOL><DEDENT>else:<EOL><INDENT>xsv_ext0 = xsv_ext1 = xsb + <NUM_LIT:1><EOL>dx_ext0 = dx_ext1 = dx0 - <NUM_LIT:1> - SQUISH_CONSTANT_4D<EOL><DEDENT>if (c & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>ysv_ext0 = ysv_ext1 = ysb<EOL>dy_ext0 = dy_ext1 = dy0 - SQUISH_CONSTANT_4D<EOL>if (c & <NUM_LIT>) == <NUM_LIT>:<EOL><INDENT>ysv_ext0 -= <NUM_LIT:1><EOL>dy_ext0 += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>ysv_ext1 -= <NUM_LIT:1><EOL>dy_ext1 += <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>ysv_ext0 = ysv_ext1 = ysb + <NUM_LIT:1><EOL>dy_ext0 = dy_ext1 = dy0 - <NUM_LIT:1> - SQUISH_CONSTANT_4D<EOL><DEDENT>if (c & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>zsv_ext0 = zsv_ext1 = zsb<EOL>dz_ext0 = dz_ext1 = dz0 - SQUISH_CONSTANT_4D<EOL>if (c & <NUM_LIT>) == <NUM_LIT>:<EOL><INDENT>zsv_ext0 -= <NUM_LIT:1><EOL>dz_ext0 += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>zsv_ext1 -= <NUM_LIT:1><EOL>dz_ext1 += <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>zsv_ext0 = zsv_ext1 = zsb + <NUM_LIT:1><EOL>dz_ext0 = dz_ext1 = dz0 - <NUM_LIT:1> - SQUISH_CONSTANT_4D<EOL><DEDENT>if (c & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>wsv_ext0 = wsb<EOL>wsv_ext1 = wsb - <NUM_LIT:1><EOL>dw_ext0 = dw0 - SQUISH_CONSTANT_4D<EOL>dw_ext1 = dw0 + <NUM_LIT:1> - SQUISH_CONSTANT_4D<EOL><DEDENT>else:<EOL><INDENT>wsv_ext0 = wsv_ext1 = wsb + <NUM_LIT:1><EOL>dw_ext0 = dw_ext1 = dw0 - <NUM_LIT:1> - SQUISH_CONSTANT_4D<EOL><DEDENT><DEDENT><DEDENT>else: <EOL><INDENT>if a_is_bigger_side:<EOL><INDENT>c1 = a_po<EOL>c2 = b_po<EOL><DEDENT>else:<EOL><INDENT>c1 = b_po<EOL>c2 = a_po<EOL><DEDENT>if (c1 & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>xsv_ext0 = xsb - <NUM_LIT:1><EOL>xsv_ext1 = xsb<EOL>dx_ext0 = dx0 + <NUM_LIT:1> - SQUISH_CONSTANT_4D<EOL>dx_ext1 = dx0 - SQUISH_CONSTANT_4D<EOL><DEDENT>else:<EOL><INDENT>xsv_ext0 = xsv_ext1 = xsb + <NUM_LIT:1><EOL>dx_ext0 = dx_ext1 = dx0 - <NUM_LIT:1> - SQUISH_CONSTANT_4D<EOL><DEDENT>if (c1 & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>ysv_ext0 = ysv_ext1 = ysb<EOL>dy_ext0 = dy_ext1 = dy0 - SQUISH_CONSTANT_4D<EOL>if (c1 & <NUM_LIT>) == <NUM_LIT>:<EOL><INDENT>ysv_ext0 -= <NUM_LIT:1><EOL>dy_ext0 += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>ysv_ext1 -= <NUM_LIT:1><EOL>dy_ext1 += <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>ysv_ext0 = ysv_ext1 = ysb + <NUM_LIT:1><EOL>dy_ext0 = dy_ext1 = dy0 - <NUM_LIT:1> - SQUISH_CONSTANT_4D<EOL><DEDENT>if (c1 & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>zsv_ext0 = zsv_ext1 = zsb<EOL>dz_ext0 = dz_ext1 = dz0 - SQUISH_CONSTANT_4D<EOL>if (c1 & <NUM_LIT>) == <NUM_LIT>:<EOL><INDENT>zsv_ext0 -= <NUM_LIT:1><EOL>dz_ext0 += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>zsv_ext1 -= <NUM_LIT:1><EOL>dz_ext1 += <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>zsv_ext0 = zsv_ext1 = zsb + <NUM_LIT:1><EOL>dz_ext0 = dz_ext1 = dz0 - <NUM_LIT:1> - SQUISH_CONSTANT_4D<EOL><DEDENT>if (c1 & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>wsv_ext0 = wsb<EOL>wsv_ext1 = wsb - <NUM_LIT:1><EOL>dw_ext0 = dw0 - SQUISH_CONSTANT_4D<EOL>dw_ext1 = dw0 + <NUM_LIT:1> - SQUISH_CONSTANT_4D<EOL><DEDENT>else:<EOL><INDENT>wsv_ext0 = wsv_ext1 = wsb + <NUM_LIT:1><EOL>dw_ext0 = dw_ext1 = dw0 - <NUM_LIT:1> - SQUISH_CONSTANT_4D<EOL><DEDENT>xsv_ext2 = xsb<EOL>ysv_ext2 = ysb<EOL>zsv_ext2 = zsb<EOL>wsv_ext2 = wsb<EOL>dx_ext2 = dx0 - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dy_ext2 = dy0 - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dz_ext2 = dz0 - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dw_ext2 = dw0 - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>if (c2 & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>xsv_ext2 += <NUM_LIT:2><EOL>dx_ext2 -= <NUM_LIT:2><EOL><DEDENT>elif (c2 & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>ysv_ext2 += <NUM_LIT:2><EOL>dy_ext2 -= <NUM_LIT:2><EOL><DEDENT>elif (c2 & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>zsv_ext2 += <NUM_LIT:2><EOL>dz_ext2 -= <NUM_LIT:2><EOL><DEDENT>else:<EOL><INDENT>wsv_ext2 += <NUM_LIT:2><EOL>dw_ext2 -= <NUM_LIT:2><EOL><DEDENT><DEDENT>dx1 = dx0 - <NUM_LIT:1> - SQUISH_CONSTANT_4D<EOL>dy1 = dy0 - <NUM_LIT:0> - SQUISH_CONSTANT_4D<EOL>dz1 = dz0 - <NUM_LIT:0> - SQUISH_CONSTANT_4D<EOL>dw1 = dw0 - <NUM_LIT:0> - SQUISH_CONSTANT_4D<EOL>attn1 = <NUM_LIT:2> - dx1 * dx1 - dy1 * dy1 - dz1 * dz1 - dw1 * dw1<EOL>if attn1 > <NUM_LIT:0>:<EOL><INDENT>attn1 *= attn1<EOL>value += attn1 * attn1 * extrapolate(xsb + <NUM_LIT:1>, ysb + <NUM_LIT:0>, zsb + <NUM_LIT:0>, wsb + <NUM_LIT:0>, dx1, dy1, dz1, dw1)<EOL><DEDENT>dx2 = dx0 - <NUM_LIT:0> - SQUISH_CONSTANT_4D<EOL>dy2 = dy0 - <NUM_LIT:1> - SQUISH_CONSTANT_4D<EOL>dz2 = dz1<EOL>dw2 = dw1<EOL>attn2 = <NUM_LIT:2> - dx2 * dx2 - dy2 * dy2 - dz2 * dz2 - dw2 * dw2<EOL>if attn2 > <NUM_LIT:0>:<EOL><INDENT>attn2 *= attn2<EOL>value += attn2 * attn2 * extrapolate(xsb + <NUM_LIT:0>, ysb + <NUM_LIT:1>, zsb + <NUM_LIT:0>, wsb + <NUM_LIT:0>, dx2, dy2, dz2, dw2)<EOL><DEDENT>dx3 = dx2<EOL>dy3 = dy1<EOL>dz3 = dz0 - <NUM_LIT:1> - SQUISH_CONSTANT_4D<EOL>dw3 = dw1<EOL>attn3 = <NUM_LIT:2> - dx3 * dx3 - dy3 * dy3 - dz3 * dz3 - dw3 * dw3<EOL>if attn3 > <NUM_LIT:0>:<EOL><INDENT>attn3 *= attn3<EOL>value += attn3 * attn3 * extrapolate(xsb + <NUM_LIT:0>, ysb + <NUM_LIT:0>, zsb + <NUM_LIT:1>, wsb + <NUM_LIT:0>, dx3, dy3, dz3, dw3)<EOL><DEDENT>dx4 = dx2<EOL>dy4 = dy1<EOL>dz4 = dz1<EOL>dw4 = dw0 - <NUM_LIT:1> - SQUISH_CONSTANT_4D<EOL>attn4 = <NUM_LIT:2> - dx4 * dx4 - dy4 * dy4 - dz4 * dz4 - dw4 * dw4<EOL>if attn4 > <NUM_LIT:0>:<EOL><INDENT>attn4 *= attn4<EOL>value += attn4 * attn4 * extrapolate(xsb + <NUM_LIT:0>, ysb + <NUM_LIT:0>, zsb + <NUM_LIT:0>, wsb + <NUM_LIT:1>, dx4, dy4, dz4, dw4)<EOL><DEDENT>dx5 = dx0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dy5 = dy0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dz5 = dz0 - <NUM_LIT:0> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dw5 = dw0 - <NUM_LIT:0> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>attn5 = <NUM_LIT:2> - dx5 * dx5 - dy5 * dy5 - dz5 * dz5 - dw5 * dw5<EOL>if attn5 > <NUM_LIT:0>:<EOL><INDENT>attn5 *= attn5<EOL>value += attn5 * attn5 * extrapolate(xsb + <NUM_LIT:1>, ysb + <NUM_LIT:1>, zsb + <NUM_LIT:0>, wsb + <NUM_LIT:0>, dx5, dy5, dz5, dw5)<EOL><DEDENT>dx6 = dx0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dy6 = dy0 - <NUM_LIT:0> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dz6 = dz0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dw6 = dw0 - <NUM_LIT:0> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>attn6 = <NUM_LIT:2> - dx6 * dx6 - dy6 * dy6 - dz6 * dz6 - dw6 * dw6<EOL>if attn6 > <NUM_LIT:0>:<EOL><INDENT>attn6 *= attn6<EOL>value += attn6 * attn6 * extrapolate(xsb + <NUM_LIT:1>, ysb + <NUM_LIT:0>, zsb + <NUM_LIT:1>, wsb + <NUM_LIT:0>, dx6, dy6, dz6, dw6)<EOL><DEDENT>dx7 = dx0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dy7 = dy0 - <NUM_LIT:0> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dz7 = dz0 - <NUM_LIT:0> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dw7 = dw0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>attn7 = <NUM_LIT:2> - dx7 * dx7 - dy7 * dy7 - dz7 * dz7 - dw7 * dw7<EOL>if attn7 > <NUM_LIT:0>:<EOL><INDENT>attn7 *= attn7<EOL>value += attn7 * attn7 * extrapolate(xsb + <NUM_LIT:1>, ysb + <NUM_LIT:0>, zsb + <NUM_LIT:0>, wsb + <NUM_LIT:1>, dx7, dy7, dz7, dw7)<EOL><DEDENT>dx8 = dx0 - <NUM_LIT:0> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dy8 = dy0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dz8 = dz0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dw8 = dw0 - <NUM_LIT:0> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>attn8 = <NUM_LIT:2> - dx8 * dx8 - dy8 * dy8 - dz8 * dz8 - dw8 * dw8<EOL>if attn8 > <NUM_LIT:0>:<EOL><INDENT>attn8 *= attn8<EOL>value += attn8 * attn8 * extrapolate(xsb + <NUM_LIT:0>, ysb + <NUM_LIT:1>, zsb + <NUM_LIT:1>, wsb + <NUM_LIT:0>, dx8, dy8, dz8, dw8)<EOL><DEDENT>dx9 = dx0 - <NUM_LIT:0> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dy9 = dy0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dz9 = dz0 - <NUM_LIT:0> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dw9 = dw0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>attn9 = <NUM_LIT:2> - dx9 * dx9 - dy9 * dy9 - dz9 * dz9 - dw9 * dw9<EOL>if attn9 > <NUM_LIT:0>:<EOL><INDENT>attn9 *= attn9<EOL>value += attn9 * attn9 * extrapolate(xsb + <NUM_LIT:0>, ysb + <NUM_LIT:1>, zsb + <NUM_LIT:0>, wsb + <NUM_LIT:1>, dx9, dy9, dz9, dw9)<EOL><DEDENT>dx10 = dx0 - <NUM_LIT:0> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dy10 = dy0 - <NUM_LIT:0> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dz10 = dz0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dw10 = dw0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>attn10 = <NUM_LIT:2> - dx10 * dx10 - dy10 * dy10 - dz10 * dz10 - dw10 * dw10<EOL>if attn10 > <NUM_LIT:0>:<EOL><INDENT>attn10 *= attn10<EOL>value += attn10 * attn10 * extrapolate(xsb + <NUM_LIT:0>, ysb + <NUM_LIT:0>, zsb + <NUM_LIT:1>, wsb + <NUM_LIT:1>, dx10, dy10, dz10, dw10)<EOL><DEDENT><DEDENT>else: <EOL><INDENT>a_is_bigger_side = True<EOL>b_is_bigger_side = True<EOL>if xins + yins < zins + wins:<EOL><INDENT>a_score = xins + yins<EOL>a_po = <NUM_LIT><EOL><DEDENT>else:<EOL><INDENT>a_score = zins + wins<EOL>a_po = <NUM_LIT><EOL><DEDENT>if xins + zins < yins + wins:<EOL><INDENT>b_score = xins + zins<EOL>b_po = <NUM_LIT><EOL><DEDENT>else:<EOL><INDENT>b_score = yins + wins<EOL>b_po = <NUM_LIT><EOL><DEDENT>if xins + wins < yins + zins:<EOL><INDENT>score = xins + wins<EOL>if a_score <= b_score and score < b_score:<EOL><INDENT>b_score = score<EOL>b_po = <NUM_LIT><EOL><DEDENT>elif a_score > b_score and score < a_score:<EOL><INDENT>a_score = score<EOL>a_po = <NUM_LIT><EOL><DEDENT><DEDENT>else:<EOL><INDENT>score = yins + zins<EOL>if a_score <= b_score and score < b_score:<EOL><INDENT>b_score = score<EOL>b_po = <NUM_LIT><EOL><DEDENT>elif a_score > b_score and score < a_score:<EOL><INDENT>a_score = score<EOL>a_po = <NUM_LIT><EOL><DEDENT><DEDENT>p1 = <NUM_LIT:3> - in_sum + xins<EOL>if a_score <= b_score and p1 < b_score:<EOL><INDENT>b_score = p1<EOL>b_po = <NUM_LIT><EOL>b_is_bigger_side = False<EOL><DEDENT>elif a_score > b_score and p1 < a_score:<EOL><INDENT>a_score = p1<EOL>a_po = <NUM_LIT><EOL>a_is_bigger_side = False<EOL><DEDENT>p2 = <NUM_LIT:3> - in_sum + yins<EOL>if a_score <= b_score and p2 < b_score:<EOL><INDENT>b_score = p2<EOL>b_po = <NUM_LIT><EOL>b_is_bigger_side = False<EOL><DEDENT>elif a_score > b_score and p2 < a_score:<EOL><INDENT>a_score = p2<EOL>a_po = <NUM_LIT><EOL>a_is_bigger_side = False<EOL><DEDENT>p3 = <NUM_LIT:3> - in_sum + zins<EOL>if a_score <= b_score and p3 < b_score:<EOL><INDENT>b_score = p3<EOL>b_po = <NUM_LIT><EOL>b_is_bigger_side = False<EOL><DEDENT>elif a_score > b_score and p3 < a_score:<EOL><INDENT>a_score = p3<EOL>a_po = <NUM_LIT><EOL>a_is_bigger_side = False<EOL><DEDENT>p4 = <NUM_LIT:3> - in_sum + wins<EOL>if a_score <= b_score and p4 < b_score:<EOL><INDENT>b_po = <NUM_LIT><EOL>b_is_bigger_side = False<EOL><DEDENT>elif a_score > b_score and p4 < a_score:<EOL><INDENT>a_po = <NUM_LIT><EOL>a_is_bigger_side = False<EOL><DEDENT>if a_is_bigger_side == b_is_bigger_side:<EOL><INDENT>if a_is_bigger_side: <EOL><INDENT>c1 = (a_po & b_po)<EOL>c2 = (a_po | b_po)<EOL>xsv_ext0 = xsv_ext1 = xsb<EOL>ysv_ext0 = ysv_ext1 = ysb<EOL>zsv_ext0 = zsv_ext1 = zsb<EOL>wsv_ext0 = wsv_ext1 = wsb<EOL>dx_ext0 = dx0 - SQUISH_CONSTANT_4D<EOL>dy_ext0 = dy0 - SQUISH_CONSTANT_4D<EOL>dz_ext0 = dz0 - SQUISH_CONSTANT_4D<EOL>dw_ext0 = dw0 - SQUISH_CONSTANT_4D<EOL>dx_ext1 = dx0 - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dy_ext1 = dy0 - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dz_ext1 = dz0 - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dw_ext1 = dw0 - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>if (c1 & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>xsv_ext0 += <NUM_LIT:1><EOL>dx_ext0 -= <NUM_LIT:1><EOL>xsv_ext1 += <NUM_LIT:2><EOL>dx_ext1 -= <NUM_LIT:2><EOL><DEDENT>elif (c1 & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>ysv_ext0 += <NUM_LIT:1><EOL>dy_ext0 -= <NUM_LIT:1><EOL>ysv_ext1 += <NUM_LIT:2><EOL>dy_ext1 -= <NUM_LIT:2><EOL><DEDENT>elif (c1 & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>zsv_ext0 += <NUM_LIT:1><EOL>dz_ext0 -= <NUM_LIT:1><EOL>zsv_ext1 += <NUM_LIT:2><EOL>dz_ext1 -= <NUM_LIT:2><EOL><DEDENT>else:<EOL><INDENT>wsv_ext0 += <NUM_LIT:1><EOL>dw_ext0 -= <NUM_LIT:1><EOL>wsv_ext1 += <NUM_LIT:2><EOL>dw_ext1 -= <NUM_LIT:2><EOL><DEDENT>xsv_ext2 = xsb + <NUM_LIT:1><EOL>ysv_ext2 = ysb + <NUM_LIT:1><EOL>zsv_ext2 = zsb + <NUM_LIT:1><EOL>wsv_ext2 = wsb + <NUM_LIT:1><EOL>dx_ext2 = dx0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dy_ext2 = dy0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dz_ext2 = dz0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dw_ext2 = dw0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>if (c2 & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>xsv_ext2 -= <NUM_LIT:2><EOL>dx_ext2 += <NUM_LIT:2><EOL><DEDENT>elif (c2 & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>ysv_ext2 -= <NUM_LIT:2><EOL>dy_ext2 += <NUM_LIT:2><EOL><DEDENT>elif (c2 & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>zsv_ext2 -= <NUM_LIT:2><EOL>dz_ext2 += <NUM_LIT:2><EOL><DEDENT>else:<EOL><INDENT>wsv_ext2 -= <NUM_LIT:2><EOL>dw_ext2 += <NUM_LIT:2><EOL><DEDENT><DEDENT>else: <EOL><INDENT>xsv_ext2 = xsb + <NUM_LIT:1><EOL>ysv_ext2 = ysb + <NUM_LIT:1><EOL>zsv_ext2 = zsb + <NUM_LIT:1><EOL>wsv_ext2 = wsb + <NUM_LIT:1><EOL>dx_ext2 = dx0 - <NUM_LIT:1> - <NUM_LIT:4> * SQUISH_CONSTANT_4D<EOL>dy_ext2 = dy0 - <NUM_LIT:1> - <NUM_LIT:4> * SQUISH_CONSTANT_4D<EOL>dz_ext2 = dz0 - <NUM_LIT:1> - <NUM_LIT:4> * SQUISH_CONSTANT_4D<EOL>dw_ext2 = dw0 - <NUM_LIT:1> - <NUM_LIT:4> * SQUISH_CONSTANT_4D<EOL>c = (a_po & b_po)<EOL>if (c & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>xsv_ext0 = xsb + <NUM_LIT:2><EOL>xsv_ext1 = xsb + <NUM_LIT:1><EOL>dx_ext0 = dx0 - <NUM_LIT:2> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>dx_ext1 = dx0 - <NUM_LIT:1> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL><DEDENT>else:<EOL><INDENT>xsv_ext0 = xsv_ext1 = xsb<EOL>dx_ext0 = dx_ext1 = dx0 - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL><DEDENT>if (c & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>ysv_ext0 = ysv_ext1 = ysb + <NUM_LIT:1><EOL>dy_ext0 = dy_ext1 = dy0 - <NUM_LIT:1> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>if (c & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>ysv_ext0 += <NUM_LIT:1><EOL>dy_ext0 -= <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>ysv_ext1 += <NUM_LIT:1><EOL>dy_ext1 -= <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>ysv_ext0 = ysv_ext1 = ysb<EOL>dy_ext0 = dy_ext1 = dy0 - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL><DEDENT>if (c & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>zsv_ext0 = zsv_ext1 = zsb + <NUM_LIT:1><EOL>dz_ext0 = dz_ext1 = dz0 - <NUM_LIT:1> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>if (c & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>zsv_ext0 += <NUM_LIT:1><EOL>dz_ext0 -= <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>zsv_ext1 += <NUM_LIT:1><EOL>dz_ext1 -= <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>zsv_ext0 = zsv_ext1 = zsb<EOL>dz_ext0 = dz_ext1 = dz0 - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL><DEDENT>if (c & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>wsv_ext0 = wsb + <NUM_LIT:1><EOL>wsv_ext1 = wsb + <NUM_LIT:2><EOL>dw_ext0 = dw0 - <NUM_LIT:1> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>dw_ext1 = dw0 - <NUM_LIT:2> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL><DEDENT>else:<EOL><INDENT>wsv_ext0 = wsv_ext1 = wsb<EOL>dw_ext0 = dw_ext1 = dw0 - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL><DEDENT><DEDENT><DEDENT>else: <EOL><INDENT>if a_is_bigger_side:<EOL><INDENT>c1 = a_po<EOL>c2 = b_po<EOL><DEDENT>else:<EOL><INDENT>c1 = b_po<EOL>c2 = a_po<EOL><DEDENT>if (c1 & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>xsv_ext0 = xsb + <NUM_LIT:2><EOL>xsv_ext1 = xsb + <NUM_LIT:1><EOL>dx_ext0 = dx0 - <NUM_LIT:2> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>dx_ext1 = dx0 - <NUM_LIT:1> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL><DEDENT>else:<EOL><INDENT>xsv_ext0 = xsv_ext1 = xsb<EOL>dx_ext0 = dx_ext1 = dx0 - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL><DEDENT>if (c1 & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>ysv_ext0 = ysv_ext1 = ysb + <NUM_LIT:1><EOL>dy_ext0 = dy_ext1 = dy0 - <NUM_LIT:1> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>if (c1 & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>ysv_ext0 += <NUM_LIT:1><EOL>dy_ext0 -= <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>ysv_ext1 += <NUM_LIT:1><EOL>dy_ext1 -= <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>ysv_ext0 = ysv_ext1 = ysb<EOL>dy_ext0 = dy_ext1 = dy0 - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL><DEDENT>if (c1 & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>zsv_ext0 = zsv_ext1 = zsb + <NUM_LIT:1><EOL>dz_ext0 = dz_ext1 = dz0 - <NUM_LIT:1> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>if (c1 & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>zsv_ext0 += <NUM_LIT:1><EOL>dz_ext0 -= <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>zsv_ext1 += <NUM_LIT:1><EOL>dz_ext1 -= <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>zsv_ext0 = zsv_ext1 = zsb<EOL>dz_ext0 = dz_ext1 = dz0 - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL><DEDENT>if (c1 & <NUM_LIT>) != <NUM_LIT:0>:<EOL><INDENT>wsv_ext0 = wsb + <NUM_LIT:1><EOL>wsv_ext1 = wsb + <NUM_LIT:2><EOL>dw_ext0 = dw0 - <NUM_LIT:1> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>dw_ext1 = dw0 - <NUM_LIT:2> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL><DEDENT>else:<EOL><INDENT>wsv_ext0 = wsv_ext1 = wsb<EOL>dw_ext0 = dw_ext1 = dw0 - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL><DEDENT>xsv_ext2 = xsb + <NUM_LIT:1><EOL>ysv_ext2 = ysb + <NUM_LIT:1><EOL>zsv_ext2 = zsb + <NUM_LIT:1><EOL>wsv_ext2 = wsb + <NUM_LIT:1><EOL>dx_ext2 = dx0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dy_ext2 = dy0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dz_ext2 = dz0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dw_ext2 = dw0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>if (c2 & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>xsv_ext2 -= <NUM_LIT:2><EOL>dx_ext2 += <NUM_LIT:2><EOL><DEDENT>elif (c2 & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>ysv_ext2 -= <NUM_LIT:2><EOL>dy_ext2 += <NUM_LIT:2><EOL><DEDENT>elif (c2 & <NUM_LIT>) == <NUM_LIT:0>:<EOL><INDENT>zsv_ext2 -= <NUM_LIT:2><EOL>dz_ext2 += <NUM_LIT:2><EOL><DEDENT>else:<EOL><INDENT>wsv_ext2 -= <NUM_LIT:2><EOL>dw_ext2 += <NUM_LIT:2><EOL><DEDENT><DEDENT>dx4 = dx0 - <NUM_LIT:1> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>dy4 = dy0 - <NUM_LIT:1> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>dz4 = dz0 - <NUM_LIT:1> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>dw4 = dw0 - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>attn4 = <NUM_LIT:2> - dx4 * dx4 - dy4 * dy4 - dz4 * dz4 - dw4 * dw4<EOL>if attn4 > <NUM_LIT:0>:<EOL><INDENT>attn4 *= attn4<EOL>value += attn4 * attn4 * extrapolate(xsb + <NUM_LIT:1>, ysb + <NUM_LIT:1>, zsb + <NUM_LIT:1>, wsb + <NUM_LIT:0>, dx4, dy4, dz4, dw4)<EOL><DEDENT>dx3 = dx4<EOL>dy3 = dy4<EOL>dz3 = dz0 - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>dw3 = dw0 - <NUM_LIT:1> - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>attn3 = <NUM_LIT:2> - dx3 * dx3 - dy3 * dy3 - dz3 * dz3 - dw3 * dw3<EOL>if attn3 > <NUM_LIT:0>:<EOL><INDENT>attn3 *= attn3<EOL>value += attn3 * attn3 * extrapolate(xsb + <NUM_LIT:1>, ysb + <NUM_LIT:1>, zsb + <NUM_LIT:0>, wsb + <NUM_LIT:1>, dx3, dy3, dz3, dw3)<EOL><DEDENT>dx2 = dx4<EOL>dy2 = dy0 - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>dz2 = dz4<EOL>dw2 = dw3<EOL>attn2 = <NUM_LIT:2> - dx2 * dx2 - dy2 * dy2 - dz2 * dz2 - dw2 * dw2<EOL>if attn2 > <NUM_LIT:0>:<EOL><INDENT>attn2 *= attn2<EOL>value += attn2 * attn2 * extrapolate(xsb + <NUM_LIT:1>, ysb + <NUM_LIT:0>, zsb + <NUM_LIT:1>, wsb + <NUM_LIT:1>, dx2, dy2, dz2, dw2)<EOL><DEDENT>dx1 = dx0 - <NUM_LIT:3> * SQUISH_CONSTANT_4D<EOL>dz1 = dz4<EOL>dy1 = dy4<EOL>dw1 = dw3<EOL>attn1 = <NUM_LIT:2> - dx1 * dx1 - dy1 * dy1 - dz1 * dz1 - dw1 * dw1<EOL>if attn1 > <NUM_LIT:0>:<EOL><INDENT>attn1 *= attn1<EOL>value += attn1 * attn1 * extrapolate(xsb + <NUM_LIT:0>, ysb + <NUM_LIT:1>, zsb + <NUM_LIT:1>, wsb + <NUM_LIT:1>, dx1, dy1, dz1, dw1)<EOL><DEDENT>dx5 = dx0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dy5 = dy0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dz5 = dz0 - <NUM_LIT:0> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dw5 = dw0 - <NUM_LIT:0> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>attn5 = <NUM_LIT:2> - dx5 * dx5 - dy5 * dy5 - dz5 * dz5 - dw5 * dw5<EOL>if attn5 > <NUM_LIT:0>:<EOL><INDENT>attn5 *= attn5<EOL>value += attn5 * attn5 * extrapolate(xsb + <NUM_LIT:1>, ysb + <NUM_LIT:1>, zsb + <NUM_LIT:0>, wsb + <NUM_LIT:0>, dx5, dy5, dz5, dw5)<EOL><DEDENT>dx6 = dx0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dy6 = dy0 - <NUM_LIT:0> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dz6 = dz0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dw6 = dw0 - <NUM_LIT:0> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>attn6 = <NUM_LIT:2> - dx6 * dx6 - dy6 * dy6 - dz6 * dz6 - dw6 * dw6<EOL>if attn6 > <NUM_LIT:0>:<EOL><INDENT>attn6 *= attn6<EOL>value += attn6 * attn6 * extrapolate(xsb + <NUM_LIT:1>, ysb + <NUM_LIT:0>, zsb + <NUM_LIT:1>, wsb + <NUM_LIT:0>, dx6, dy6, dz6, dw6)<EOL><DEDENT>dx7 = dx0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dy7 = dy0 - <NUM_LIT:0> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dz7 = dz0 - <NUM_LIT:0> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dw7 = dw0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>attn7 = <NUM_LIT:2> - dx7 * dx7 - dy7 * dy7 - dz7 * dz7 - dw7 * dw7<EOL>if attn7 > <NUM_LIT:0>:<EOL><INDENT>attn7 *= attn7<EOL>value += attn7 * attn7 * extrapolate(xsb + <NUM_LIT:1>, ysb + <NUM_LIT:0>, zsb + <NUM_LIT:0>, wsb + <NUM_LIT:1>, dx7, dy7, dz7, dw7)<EOL><DEDENT>dx8 = dx0 - <NUM_LIT:0> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dy8 = dy0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dz8 = dz0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dw8 = dw0 - <NUM_LIT:0> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>attn8 = <NUM_LIT:2> - dx8 * dx8 - dy8 * dy8 - dz8 * dz8 - dw8 * dw8<EOL>if attn8 > <NUM_LIT:0>:<EOL><INDENT>attn8 *= attn8<EOL>value += attn8 * attn8 * extrapolate(xsb + <NUM_LIT:0>, ysb + <NUM_LIT:1>, zsb + <NUM_LIT:1>, wsb + <NUM_LIT:0>, dx8, dy8, dz8, dw8)<EOL><DEDENT>dx9 = dx0 - <NUM_LIT:0> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dy9 = dy0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dz9 = dz0 - <NUM_LIT:0> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dw9 = dw0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>attn9 = <NUM_LIT:2> - dx9 * dx9 - dy9 * dy9 - dz9 * dz9 - dw9 * dw9<EOL>if attn9 > <NUM_LIT:0>:<EOL><INDENT>attn9 *= attn9<EOL>value += attn9 * attn9 * extrapolate(xsb + <NUM_LIT:0>, ysb + <NUM_LIT:1>, zsb + <NUM_LIT:0>, wsb + <NUM_LIT:1>, dx9, dy9, dz9, dw9)<EOL><DEDENT>dx10 = dx0 - <NUM_LIT:0> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dy10 = dy0 - <NUM_LIT:0> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dz10 = dz0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>dw10 = dw0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_4D<EOL>attn10 = <NUM_LIT:2> - dx10 * dx10 - dy10 * dy10 - dz10 * dz10 - dw10 * dw10<EOL>if attn10 > <NUM_LIT:0>:<EOL><INDENT>attn10 *= attn10<EOL>value += attn10 * attn10 * extrapolate(xsb + <NUM_LIT:0>, ysb + <NUM_LIT:0>, zsb + <NUM_LIT:1>, wsb + <NUM_LIT:1>, dx10, dy10, dz10, dw10)<EOL><DEDENT><DEDENT>attn_ext0 = <NUM_LIT:2> - dx_ext0 * dx_ext0 - dy_ext0 * dy_ext0 - dz_ext0 * dz_ext0 - dw_ext0 * dw_ext0<EOL>if attn_ext0 > <NUM_LIT:0>:<EOL><INDENT>attn_ext0 *= attn_ext0<EOL>value += attn_ext0 * attn_ext0 * extrapolate(xsv_ext0, ysv_ext0, zsv_ext0, wsv_ext0, dx_ext0, dy_ext0, dz_ext0, dw_ext0)<EOL><DEDENT>attn_ext1 = <NUM_LIT:2> - dx_ext1 * dx_ext1 - dy_ext1 * dy_ext1 - dz_ext1 * dz_ext1 - dw_ext1 * dw_ext1<EOL>if attn_ext1 > <NUM_LIT:0>:<EOL><INDENT>attn_ext1 *= attn_ext1<EOL>value += attn_ext1 * attn_ext1 * extrapolate(xsv_ext1, ysv_ext1, zsv_ext1, wsv_ext1, dx_ext1, dy_ext1, dz_ext1, dw_ext1)<EOL><DEDENT>attn_ext2 = <NUM_LIT:2> - dx_ext2 * dx_ext2 - dy_ext2 * dy_ext2 - dz_ext2 * dz_ext2 - dw_ext2 * dw_ext2<EOL>if attn_ext2 > <NUM_LIT:0>:<EOL><INDENT>attn_ext2 *= attn_ext2<EOL>value += attn_ext2 * attn_ext2 * extrapolate(xsv_ext2, ysv_ext2, zsv_ext2, wsv_ext2, dx_ext2, dy_ext2, dz_ext2, dw_ext2)<EOL><DEDENT>return value / NORM_CONSTANT_4D<EOL>

Generate 4D OpenSimplex noise from X,Y,Z,W coordinates.


def isect_segments__naive(segments) -> list:

isect = []<EOL>if Real is float:<EOL><INDENT>segments = [<EOL>(s[<NUM_LIT:0>], s[<NUM_LIT:1>]) if s[<NUM_LIT:0>][X] <= s[<NUM_LIT:1>][X] else<EOL>(s[<NUM_LIT:1>], s[<NUM_LIT:0>])<EOL>for s in segments]<EOL><DEDENT>else:<EOL><INDENT>segments = [<EOL>(<EOL>(Real(s[<NUM_LIT:0>][<NUM_LIT:0>]), Real(s[<NUM_LIT:0>][<NUM_LIT:1>])),<EOL>(Real(s[<NUM_LIT:1>][<NUM_LIT:0>]), Real(s[<NUM_LIT:1>][<NUM_LIT:1>])),<EOL>) if (s[<NUM_LIT:0>] <= s[<NUM_LIT:1>]) else<EOL>(<EOL>(Real(s[<NUM_LIT:1>][<NUM_LIT:0>]), Real(s[<NUM_LIT:1>][<NUM_LIT:1>])),<EOL>(Real(s[<NUM_LIT:0>][<NUM_LIT:0>]), Real(s[<NUM_LIT:0>][<NUM_LIT:1>])),<EOL>)<EOL>for s in segments]<EOL><DEDENT>n = len(segments)<EOL>for i in range(n):<EOL><INDENT>a0, a1 = segments[i]<EOL>for j in range(i + <NUM_LIT:1>, n):<EOL><INDENT>b0, b1 = segments[j]<EOL>if a0 not in (b0, b1) and a1 not in (b0, b1):<EOL><INDENT>ix = isect_seg_seg_v2_point(a0, a1, b0, b1)<EOL>if ix is not None:<EOL><INDENT>isect.append(ix)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return isect<EOL>

Brute force O(n2) version of ``isect_segments`` for test validation.


def isect_polygon__naive(points) -> list:

isect = []<EOL>n = len(points)<EOL>if Real is float:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>points = [(Real(p[<NUM_LIT:0>]), Real(p[<NUM_LIT:1>])) for p in points]<EOL><DEDENT>for i in range(n):<EOL><INDENT>a0, a1 = points[i], points[(i + <NUM_LIT:1>) % n]<EOL>for j in range(i + <NUM_LIT:1>, n):<EOL><INDENT>b0, b1 = points[j], points[(j + <NUM_LIT:1>) % n]<EOL>if a0 not in (b0, b1) and a1 not in (b0, b1):<EOL><INDENT>ix = isect_seg_seg_v2_point(a0, a1, b0, b1)<EOL>if ix is not None:<EOL><INDENT>if USE_IGNORE_SEGMENT_ENDINGS:<EOL><INDENT>if ((len_squared_v2v2(ix, a0) < NUM_EPS_SQ or<EOL>len_squared_v2v2(ix, a1) < NUM_EPS_SQ) and<EOL>(len_squared_v2v2(ix, b0) < NUM_EPS_SQ or<EOL>len_squared_v2v2(ix, b1) < NUM_EPS_SQ)):<EOL><INDENT>continue<EOL><DEDENT><DEDENT>isect.append(ix)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return isect<EOL>

Brute force O(n2) version of ``isect_polygon`` for test validation.


if Real is float:<EOL><INDENT>return list(self.intersections.keys())<EOL><DEDENT>else:<EOL><INDENT>return [(float(p[<NUM_LIT:0>]), float(p[<NUM_LIT:1>])) for p in self.intersections.keys()]<EOL><DEDENT>

Return a list of unordered intersection points.


if Real is float:<EOL><INDENT>return [<EOL>(p, [event.segment for event in event_set])<EOL>for p, event_set in self.intersections.items()<EOL>]<EOL><DEDENT>else:<EOL><INDENT>return [<EOL>(<EOL>(float(p[<NUM_LIT:0>]), float(p[<NUM_LIT:1>])),<EOL>[((float(event.segment[<NUM_LIT:0>][<NUM_LIT:0>]), float(event.segment[<NUM_LIT:0>][<NUM_LIT:1>])),<EOL>(float(event.segment[<NUM_LIT:1>][<NUM_LIT:0>]), float(event.segment[<NUM_LIT:1>][<NUM_LIT:1>])))<EOL>for event in event_set],<EOL>)<EOL>for p, event_set in self.intersections.items()<EOL>]<EOL><DEDENT>

Return a list of unordered intersection '(point, segment)' pairs,
where segments may contain 2 or more values.


existing = self.events_scan.setdefault(<EOL>p, ([], [], [], []) if USE_VERTICAL else<EOL>([], [], []))<EOL>'''<STR_LIT>'''<EOL>existing[e.type].append(e)<EOL>

Offer a new event ``s`` at point ``p`` in this queue.


assert(len(self.events_scan) != <NUM_LIT:0>)<EOL>p, events_current = self.events_scan.pop_min()<EOL>return p, events_current<EOL>

Get, and remove, the first (lowest) item from this queue.

:return: the first (lowest) item from this queue.
:rtype: Point, Event pair.


def __init__(self, items=None, cmp=None, cmp_data=None):

self._root = None<EOL>self._count = <NUM_LIT:0><EOL>if cmp is None:<EOL><INDENT>def cmp(cmp_data, a, b):<EOL><INDENT>if a < b:<EOL><INDENT>return -<NUM_LIT:1><EOL><DEDENT>elif a > b:<EOL><INDENT>return <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT><DEDENT><DEDENT>self._cmp = cmp<EOL>self._cmp_data = cmp_data<EOL>if items is not None:<EOL><INDENT>self.update(items)<EOL><DEDENT>

T.__init__(...) initializes T; see T.__class__.__doc__ for signature


def _clear(node):<EOL><INDENT>if node is not None:<EOL><INDENT>_clear(node.left)<EOL>_clear(node.right)<EOL>node.free()<EOL><DEDENT><DEDENT>_clear(self._root)<EOL>self._count = <NUM_LIT:0><EOL>self._root = None<EOL>

T.clear() -> None.  Remove all items from T.


return self._count<EOL>


if self.is_empty():<EOL><INDENT>raise KeyError("<STR_LIT>")<EOL><DEDENT>node = self._root<EOL>while True:<EOL><INDENT>if node.left is not None:<EOL><INDENT>node = node.left<EOL><DEDENT>elif node.right is not None:<EOL><INDENT>node = node.right<EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT><DEDENT>key = node.key<EOL>value = node.value<EOL>self.remove(key)<EOL>return key, value<EOL>

T.pop_item() -> (k, v), remove and return some (key, value) pair as a
        2-tuple; but raise KeyError if T is empty.


if self.is_empty():<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>node = self._root<EOL>while node.left is not None:<EOL><INDENT>node = node.left<EOL><DEDENT>return node.key, node.value<EOL>

Get item with min key of tree, raises ValueError if tree is empty.


if self.is_empty():<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>node = self._root<EOL>while node.right is not None:<EOL><INDENT>node = node.right<EOL><DEDENT>return node.key, node.value<EOL>

Get item with max key of tree, raises ValueError if tree is empty.


def succ_item(self, key, default=_sentinel):

<EOL>node = self._root<EOL>succ_node = None<EOL>while node is not None:<EOL><INDENT>cmp = self._cmp(self._cmp_data, key, node.key)<EOL>if cmp == <NUM_LIT:0>:<EOL><INDENT>break<EOL><DEDENT>elif cmp < <NUM_LIT:0>:<EOL><INDENT>if (succ_node is None) or self._cmp(self._cmp_data, node.key, succ_node.key) < <NUM_LIT:0>:<EOL><INDENT>succ_node = node<EOL><DEDENT>node = node.left<EOL><DEDENT>else:<EOL><INDENT>node = node.right<EOL><DEDENT><DEDENT>if node is None:  <EOL><INDENT>if default is _sentinel:<EOL><INDENT>raise KeyError(str(key))<EOL><DEDENT>return default<EOL><DEDENT>if node.right is not None:<EOL><INDENT>node = node.right<EOL>while node.left is not None:<EOL><INDENT>node = node.left<EOL><DEDENT>if succ_node is None:<EOL><INDENT>succ_node = node<EOL><DEDENT>elif self._cmp(self._cmp_data, node.key, succ_node.key) < <NUM_LIT:0>:<EOL><INDENT>succ_node = node<EOL><DEDENT><DEDENT>elif succ_node is None:  <EOL><INDENT>if default is _sentinel:<EOL><INDENT>raise KeyError(str(key))<EOL><DEDENT>return default<EOL><DEDENT>return succ_node.key, succ_node.value<EOL>

Get successor (k,v) pair of key, raises KeyError if key is max key
        or key does not exist. optimized for pypy.


def prev_item(self, key, default=_sentinel):

<EOL>node = self._root<EOL>prev_node = None<EOL>while node is not None:<EOL><INDENT>cmp = self._cmp(self._cmp_data, key, node.key)<EOL>if cmp == <NUM_LIT:0>:<EOL><INDENT>break<EOL><DEDENT>elif cmp < <NUM_LIT:0>:<EOL><INDENT>node = node.left<EOL><DEDENT>else:<EOL><INDENT>if (prev_node is None) or self._cmp(self._cmp_data, prev_node.key, node.key) < <NUM_LIT:0>:<EOL><INDENT>prev_node = node<EOL><DEDENT>node = node.right<EOL><DEDENT><DEDENT>if node is None:  <EOL><INDENT>if default is _sentinel:<EOL><INDENT>raise KeyError(str(key))<EOL><DEDENT>return default<EOL><DEDENT>if node.left is not None:<EOL><INDENT>node = node.left<EOL>while node.right is not None:<EOL><INDENT>node = node.right<EOL><DEDENT>if prev_node is None:<EOL><INDENT>prev_node = node<EOL><DEDENT>elif self._cmp(self._cmp_data, prev_node.key, node.key) < <NUM_LIT:0>:<EOL><INDENT>prev_node = node<EOL><DEDENT><DEDENT>elif prev_node is None:  <EOL><INDENT>if default is _sentinel:<EOL><INDENT>raise KeyError(str(key))<EOL><DEDENT>return default<EOL><DEDENT>return prev_node.key, prev_node.value<EOL>

Get predecessor (k,v) pair of key, raises KeyError if key is min key
        or key does not exist. optimized for pypy.


tpl = "<STR_LIT>" % (self.__class__.__name__, '<STR_LIT:%s>')<EOL>return tpl % "<STR_LIT:U+002CU+0020>".join(("<STR_LIT>" % item for item in self.items()))<EOL>


try:<EOL><INDENT>self.get_value(key)<EOL>return True<EOL><DEDENT>except KeyError:<EOL><INDENT>return False<EOL><DEDENT>

k in T -> True if T has a key k, else False


return self.count<EOL>


return self.count == <NUM_LIT:0><EOL>

T.is_empty() -> False if T contains any items else True


def set_default(self, key, default=None):

try:<EOL><INDENT>return self.get_value(key)<EOL><DEDENT>except KeyError:<EOL><INDENT>self.insert(key, default)<EOL>return default<EOL><DEDENT>

T.set_default(k[,d]) -> T.get(k,d), also set T[k]=d if k not in T


try:<EOL><INDENT>return self.get_value(key)<EOL><DEDENT>except KeyError:<EOL><INDENT>return default<EOL><DEDENT>

T.get(k[,d]) -> T[k] if k in T, else d.  d defaults to None.


if len(args) > <NUM_LIT:1>:<EOL><INDENT>raise TypeError("<STR_LIT>" % (<NUM_LIT:1> + len(args)))<EOL><DEDENT>try:<EOL><INDENT>value = self.get_value(key)<EOL>self.remove(key)<EOL>return value<EOL><DEDENT>except KeyError:<EOL><INDENT>if len(args) == <NUM_LIT:0>:<EOL><INDENT>raise<EOL><DEDENT>else:<EOL><INDENT>return args[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>

T.pop(k[,d]) -> v, remove specified key and return the corresponding value.
        If key is not found, d is returned if given, otherwise KeyError is raised


def prev_key(self, key, default=_sentinel):

item = self.prev_item(key, default)<EOL>return default if item is default else item[<NUM_LIT:0>]<EOL>

Get predecessor to key, raises KeyError if key is min key
        or key does not exist.


def succ_key(self, key, default=_sentinel):

item = self.succ_item(key, default)<EOL>return default if item is default else item[<NUM_LIT:0>]<EOL>

Get successor to key, raises KeyError if key is max key
        or key does not exist.


item = self.min_item()<EOL>self.remove(item[<NUM_LIT:0>])<EOL>return item<EOL>

T.pop_min() -> (k, v), remove item with minimum key, raise ValueError
        if T is empty.


item = self.max_item()<EOL>self.remove(item[<NUM_LIT:0>])<EOL>return item<EOL>

T.pop_max() -> (k, v), remove item with maximum key, raise ValueError
        if T is empty.


return self.min_item()[<NUM_LIT:0>]<EOL>

Get min key of tree, raises ValueError if tree is empty.


return self.max_item()[<NUM_LIT:0>]<EOL>

Get max key of tree, raises ValueError if tree is empty.


def key_slice(self, start_key, end_key, reverse=False):

return (k for k, v in self.iter_items(start_key, end_key, reverse=reverse))<EOL>

T.key_slice(start_key, end_key) -> key iterator:
        start_key <= key < end_key.

        Yields keys in ascending order if reverse is False else in descending order.


def iter_items(self,  start_key=None, end_key=None, reverse=False):

<EOL>if self.is_empty():<EOL><INDENT>return []<EOL><DEDENT>if reverse:<EOL><INDENT>return self._iter_items_backward(start_key, end_key)<EOL><DEDENT>else:<EOL><INDENT>return self._iter_items_forward(start_key, end_key)<EOL><DEDENT>

Iterates over the (key, value) items of the associated tree,
        in ascending order if reverse is True, iterate in descending order,
        reverse defaults to False


return self.left if key == <NUM_LIT:0> else self.right<EOL>

N.__getitem__(key) <==> x[key], where key is 0 (left) or 1 (right).


if key == <NUM_LIT:0>:<EOL><INDENT>self.left = value<EOL><DEDENT>else:<EOL><INDENT>self.right = value<EOL><DEDENT>

N.__setitem__(key, value) <==> x[key]=value, where key is 0 (left) or 1 (right).


self._count += <NUM_LIT:1><EOL>return Node(key, value)<EOL>


if self._root is None:  <EOL><INDENT>self._root = self._new_node(key, value)<EOL>self._root.red = False  <EOL>return<EOL><DEDENT>head = Node()  <EOL>grand_parent = None<EOL>grand_grand_parent = head<EOL>parent = None  <EOL>direction = <NUM_LIT:0><EOL>last = <NUM_LIT:0><EOL>grand_grand_parent.right = self._root<EOL>node = grand_grand_parent.right<EOL>while True:<EOL><INDENT>if node is None:  <EOL><INDENT>node = self._new_node(key, value)<EOL>parent[direction] = node<EOL><DEDENT>elif RBTree.is_red(node.left) and RBTree.is_red(node.right):  <EOL><INDENT>node.red = True<EOL>node.left.red = False<EOL>node.right.red = False<EOL><DEDENT>if RBTree.is_red(node) and RBTree.is_red(parent):<EOL><INDENT>direction2 = <NUM_LIT:1> if grand_grand_parent.right is grand_parent else <NUM_LIT:0><EOL>if node is parent[last]:<EOL><INDENT>grand_grand_parent[direction2] = RBTree.jsw_single(grand_parent, <NUM_LIT:1> - last)<EOL><DEDENT>else:<EOL><INDENT>grand_grand_parent[direction2] = RBTree.jsw_double(grand_parent, <NUM_LIT:1> - last)<EOL><DEDENT><DEDENT>if self._cmp(self._cmp_data, key, node.key) == <NUM_LIT:0>:<EOL><INDENT>node.value = value  <EOL>break<EOL><DEDENT>last = direction<EOL>direction = <NUM_LIT:0> if (self._cmp(self._cmp_data, key, node.key) < <NUM_LIT:0>) else <NUM_LIT:1><EOL>if grand_parent is not None:<EOL><INDENT>grand_grand_parent = grand_parent<EOL><DEDENT>grand_parent = parent<EOL>parent = node<EOL>node = node[direction]<EOL><DEDENT>self._root = head.right  <EOL>self._root.red = False<EOL>

T.insert(key, value) <==> T[key] = value, insert key, value into tree.


if self._root is None:<EOL><INDENT>raise KeyError(str(key))<EOL><DEDENT>head = Node()  <EOL>node = head<EOL>node.right = self._root<EOL>parent = None<EOL>grand_parent = None<EOL>found = None  <EOL>direction = <NUM_LIT:1><EOL>while node[direction] is not None:<EOL><INDENT>last = direction<EOL>grand_parent = parent<EOL>parent = node<EOL>node = node[direction]<EOL>direction = <NUM_LIT:1> if (self._cmp(self._cmp_data, node.key, key) < <NUM_LIT:0>) else <NUM_LIT:0><EOL>if self._cmp(self._cmp_data, key, node.key) == <NUM_LIT:0>:<EOL><INDENT>found = node<EOL><DEDENT>if not RBTree.is_red(node) and not RBTree.is_red(node[direction]):<EOL><INDENT>if RBTree.is_red(node[<NUM_LIT:1> - direction]):<EOL><INDENT>parent[last] = RBTree.jsw_single(node, direction)<EOL>parent = parent[last]<EOL><DEDENT>elif not RBTree.is_red(node[<NUM_LIT:1> - direction]):<EOL><INDENT>sibling = parent[<NUM_LIT:1> - last]<EOL>if sibling is not None:<EOL><INDENT>if (not RBTree.is_red(sibling[<NUM_LIT:1> - last])) and (not RBTree.is_red(sibling[last])):<EOL><INDENT>parent.red = False<EOL>sibling.red = True<EOL>node.red = True<EOL><DEDENT>else:<EOL><INDENT>direction2 = <NUM_LIT:1> if grand_parent.right is parent else <NUM_LIT:0><EOL>if RBTree.is_red(sibling[last]):<EOL><INDENT>grand_parent[direction2] = RBTree.jsw_double(parent, last)<EOL><DEDENT>elif RBTree.is_red(sibling[<NUM_LIT:1>-last]):<EOL><INDENT>grand_parent[direction2] = RBTree.jsw_single(parent, last)<EOL><DEDENT>grand_parent[direction2].red = True<EOL>node.red = True<EOL>grand_parent[direction2].left.red = False<EOL>grand_parent[direction2].right.red = False<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>if found is not None:<EOL><INDENT>found.key = node.key<EOL>found.value = node.value<EOL>parent[int(parent.right is node)] = node[int(node.left is None)]<EOL>node.free()<EOL>self._count -= <NUM_LIT:1><EOL><DEDENT>self._root = head.right<EOL>if self._root is not None:<EOL><INDENT>self._root.red = False<EOL><DEDENT>if not found:<EOL><INDENT>raise KeyError(str(key))<EOL><DEDENT>

T.remove(key) <==> del T[key], remove item <key> from tree.


<EOL>return isinstance(val, np.ndarray)<EOL>

Checks whether a variable is a numpy array.

Parameters
----------
val
    The variable to check.

Returns
-------
out : bool
    True if the variable is a numpy array. Otherwise False.


return isinstance(val, numbers.Integral) and not isinstance(val, bool)<EOL>

Checks whether a variable is an integer.

Parameters
----------
val
    The variable to check.

Returns
-------
bool
    True if the variable is an integer. Otherwise False.


return isinstance(val, numbers.Real) and not is_single_integer(val) and not isinstance(val, bool)<EOL>

Checks whether a variable is a float.

Parameters
----------
val
    The variable to check.

Returns
-------
bool
    True if the variable is a float. Otherwise False.


return is_single_integer(val) or is_single_float(val)<EOL>

Checks whether a variable is a number, i.e. an integer or float.

Parameters
----------
val
    The variable to check.

Returns
-------
bool
    True if the variable is a number. Otherwise False.


return isinstance(val, collections.Iterable)<EOL>

Checks whether a variable is iterable.

Parameters
----------
val
    The variable to check.

Returns
-------
bool
    True if the variable is an iterable. Otherwise False.


return isinstance(val, six.string_types)<EOL>

Checks whether a variable is a string.

Parameters
----------
val
    The variable to check.

Returns
-------
bool
    True if the variable is a string. Otherwise False.


return type(val) == type(True)<EOL>

Checks whether a variable is a boolean.

Parameters
----------
val
    The variable to check.

Returns
-------
bool
    True if the variable is a boolean. Otherwise False.


return is_np_array(val) and issubclass(val.dtype.type, np.integer)<EOL>

Checks whether a variable is a numpy integer array.

Parameters
----------
val
    The variable to check.

Returns
-------
bool
    True if the variable is a numpy integer array. Otherwise False.


return is_np_array(val) and issubclass(val.dtype.type, np.floating)<EOL>

Checks whether a variable is a numpy float array.

Parameters
----------
val
    The variable to check.

Returns
-------
bool
    True if the variable is a numpy float array. Otherwise False.


<EOL>if sys.version_info[<NUM_LIT:0>] == <NUM_LIT:3> and sys.version_info[<NUM_LIT:1>] <= <NUM_LIT:2>:<EOL><INDENT>return hasattr(val, '<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>return callable(val)<EOL><DEDENT>

Checks whether a variable is a callable, e.g. a function.

Parameters
----------
val
    The variable to check.

Returns
-------
bool
    True if the variable is a callable. Otherwise False.


return isinstance(val, types.GeneratorType)<EOL>

Checks whether a variable is a generator.

Parameters
----------
val
    The variable to check.

Returns
-------
bool
    True is the variable is a generator. Otherwise False.


<EOL>if not isinstance(nested_iterable, (list, tuple)):<EOL><INDENT>yield nested_iterable<EOL><DEDENT>else:<EOL><INDENT>for i in nested_iterable:<EOL><INDENT>if isinstance(i, (list, tuple)):<EOL><INDENT>for j in flatten(i):<EOL><INDENT>yield j<EOL><DEDENT><DEDENT>else:<EOL><INDENT>yield i<EOL><DEDENT><DEDENT><DEDENT>

Flattens arbitrarily nested lists/tuples.

Code partially taken from https://stackoverflow.com/a/10824420.

Parameters
----------
nested_iterable
    A list or tuple of arbitrarily nested values.

Yields
------
any
    Non-list and non-tuple values in `nested_iterable`.


return sys._getframe(<NUM_LIT:1>).f_code.co_name<EOL>

Returns the name of the caller, e.g. a function.

Returns
-------
str
    The name of the caller as a string


Set the seed used by the global random state and thereby all randomness
in the library.

This random state is by default by all augmenters. Under special
circumstances (e.g. when an augmenter is switched to deterministic mode),
the global random state is replaced by another -- local -- one.
The replacement is dependent on the global random state.

Parameters
----------
seedval : int
    The seed to use.


return CURRENT_RANDOM_STATE<EOL>

Returns the current/global random state of the library.

Returns
----------
numpy.random.RandomState
    The current/global random state.


if seed is None:<EOL><INDENT>if not fully_random:<EOL><INDENT>seed = CURRENT_RANDOM_STATE.randint(SEED_MIN_VALUE, SEED_MAX_VALUE, <NUM_LIT:1>)[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>return np.random.RandomState(seed)<EOL>

Returns a new random state.

Parameters
----------
seed : None or int, optional
    Optional seed value to use.
    The same datatypes are allowed as for ``numpy.random.RandomState(seed)``.

fully_random : bool, optional
    Whether to use numpy's random initialization for the
    RandomState (used if set to True). If False, a seed is sampled from
    the global random state, which is a bit faster and hence the default.

Returns
-------
numpy.random.RandomState
    The new random state.


return np.random.RandomState(<NUM_LIT:1>)<EOL>

Returns a dummy random state that is always based on a seed of 1.

Returns
-------
numpy.random.RandomState
    The new random state.


if random_state == np.random and not force_copy:<EOL><INDENT>return random_state<EOL><DEDENT>else:<EOL><INDENT>rs_copy = dummy_random_state()<EOL>orig_state = random_state.get_state()<EOL>rs_copy.set_state(orig_state)<EOL>return rs_copy<EOL><DEDENT>

Creates a copy of a random state.

Parameters
----------
random_state : numpy.random.RandomState
    The random state to copy.

force_copy : bool, optional
    If True, this function will always create a copy of every random
    state. If False, it will not copy numpy's default random state,
    but all other random states.

Returns
-------
rs_copy : numpy.random.RandomState
    The copied random state.


return derive_random_states(random_state, n=<NUM_LIT:1>)[<NUM_LIT:0>]<EOL>

Create a new random states based on an existing random state or seed.

Parameters
----------
random_state : numpy.random.RandomState
    Random state or seed from which to derive the new random state.

Returns
-------
numpy.random.RandomState
    Derived random state.


seed_ = random_state.randint(SEED_MIN_VALUE, SEED_MAX_VALUE, <NUM_LIT:1>)[<NUM_LIT:0>]<EOL>return [new_random_state(seed_+i) for i in sm.xrange(n)]<EOL>

Create N new random states based on an existing random state or seed.

Parameters
----------
random_state : numpy.random.RandomState
    Random state or seed from which to derive new random states.

n : int, optional
    Number of random states to derive.

Returns
-------
list of numpy.random.RandomState
    Derived random states.


Forward the internal state of a random state.

This makes sure that future calls to the random_state will produce new random values.

Parameters
----------
random_state : numpy.random.RandomState
    Random state to forward.


<EOL>from imgaug.augmentables.bbs import BoundingBox, BoundingBoxesOnImage<EOL>if extract == "<STR_LIT>":<EOL><INDENT>bb = BoundingBox(x1=<NUM_LIT:0>, y1=<NUM_LIT:0>, x2=<NUM_LIT>, y2=<NUM_LIT>)<EOL><DEDENT>elif isinstance(extract, tuple) and len(extract) == <NUM_LIT:4>:<EOL><INDENT>bb = BoundingBox(x1=extract[<NUM_LIT:0>], y1=extract[<NUM_LIT:1>], x2=extract[<NUM_LIT:2>], y2=extract[<NUM_LIT:3>])<EOL><DEDENT>elif isinstance(extract, BoundingBox):<EOL><INDENT>bb = extract<EOL><DEDENT>elif isinstance(extract, BoundingBoxesOnImage):<EOL><INDENT>do_assert(len(extract.bounding_boxes) == <NUM_LIT:1>)<EOL>do_assert(extract.shape[<NUM_LIT:0>:<NUM_LIT:2>] == (<NUM_LIT>, <NUM_LIT>))<EOL>bb = extract.bounding_boxes[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>raise Exception(<EOL>"<STR_LIT>"<EOL>+ "<STR_LIT>" % (type(extract),)<EOL>)<EOL><DEDENT>return bb<EOL>

Generate a normalized rectangle to be extract from the standard quokka image.

Parameters
----------
extract : 'square' or tuple of number or imgaug.BoundingBox or imgaug.BoundingBoxesOnImage
    Unnormalized representation of the image subarea to be extracted.

        * If string ``square``, then a squared area ``(x: 0 to max 643, y: 0 to max 643)``
          will be extracted from the image.
        * If a tuple, then expected to contain four numbers denoting ``x1``, ``y1``, ``x2``
          and ``y2``.
        * If a BoundingBox, then that bounding box's area will be extracted from the image.
        * If a BoundingBoxesOnImage, then expected to contain exactly one bounding box
          and a shape matching the full image dimensions (i.e. (643, 960, *)). Then the
          one bounding box will be used similar to BoundingBox.

Returns
-------
bb : imgaug.BoundingBox
    Normalized representation of the area to extract from the standard quokka image.


if is_np_array(from_shape):<EOL><INDENT>from_shape = from_shape.shape<EOL><DEDENT>if is_np_array(to_shape):<EOL><INDENT>to_shape = to_shape.shape<EOL><DEDENT>to_shape_computed = list(from_shape)<EOL>if to_shape is None:<EOL><INDENT>pass<EOL><DEDENT>elif isinstance(to_shape, tuple):<EOL><INDENT>do_assert(len(from_shape) in [<NUM_LIT:2>, <NUM_LIT:3>])<EOL>do_assert(len(to_shape) in [<NUM_LIT:2>, <NUM_LIT:3>])<EOL>if len(from_shape) == <NUM_LIT:3> and len(to_shape) == <NUM_LIT:3>:<EOL><INDENT>do_assert(from_shape[<NUM_LIT:2>] == to_shape[<NUM_LIT:2>])<EOL><DEDENT>elif len(to_shape) == <NUM_LIT:3>:<EOL><INDENT>to_shape_computed.append(to_shape[<NUM_LIT:2>])<EOL><DEDENT>do_assert(all([v is None or is_single_number(v) for v in to_shape[<NUM_LIT:0>:<NUM_LIT:2>]]),<EOL>"<STR_LIT>"<EOL>+ "<STR_LIT>" % (str([type(v) for v in to_shape[<NUM_LIT:0>:<NUM_LIT:2>]]),))<EOL>for i, from_shape_i in enumerate(from_shape[<NUM_LIT:0>:<NUM_LIT:2>]):<EOL><INDENT>if to_shape[i] is None:<EOL><INDENT>to_shape_computed[i] = from_shape_i<EOL><DEDENT>elif is_single_integer(to_shape[i]):<EOL><INDENT>to_shape_computed[i] = to_shape[i]<EOL><DEDENT>else:  <EOL><INDENT>to_shape_computed[i] = int(np.round(from_shape_i * to_shape[i]))<EOL><DEDENT><DEDENT><DEDENT>elif is_single_integer(to_shape) or is_single_float(to_shape):<EOL><INDENT>to_shape_computed = _compute_resized_shape(from_shape, (to_shape, to_shape))<EOL><DEDENT>else:<EOL><INDENT>raise Exception("<STR_LIT>"<EOL>+ "<STR_LIT>" % (type(to_shape),))<EOL><DEDENT>return tuple(to_shape_computed)<EOL>

Computes the intended new shape of an image-like array after resizing.

Parameters
----------
from_shape : tuple or ndarray
    Old shape of the array. Usually expected to be a tuple of form ``(H, W)`` or ``(H, W, C)`` or
    alternatively an array with two or three dimensions.

to_shape : None or tuple of ints or tuple of floats or int or float or ndarray
    New shape of the array.

        * If None, then `from_shape` will be used as the new shape.
        * If an int ``V``, then the new shape will be ``(V, V, [C])``, where ``C`` will be added if it
          is part of `from_shape`.
        * If a float ``V``, then the new shape will be ``(H*V, W*V, [C])``, where ``H`` and ``W`` are the old
          height/width.
        * If a tuple ``(H', W', [C'])`` of ints, then ``H'`` and ``W'`` will be used as the new height
          and width.
        * If a tuple ``(H', W', [C'])`` of floats (except ``C``), then ``H'`` and ``W'`` will
          be used as the new height and width.
        * If a numpy array, then the array's shape will be used.

Returns
-------
to_shape_computed : tuple of int
    New shape.


img = imageio.imread(QUOKKA_FP, pilmode="<STR_LIT>")<EOL>if extract is not None:<EOL><INDENT>bb = _quokka_normalize_extract(extract)<EOL>img = bb.extract_from_image(img)<EOL><DEDENT>if size is not None:<EOL><INDENT>shape_resized = _compute_resized_shape(img.shape, size)<EOL>img = imresize_single_image(img, shape_resized[<NUM_LIT:0>:<NUM_LIT:2>])<EOL><DEDENT>return img<EOL>

Returns an image of a quokka as a numpy array.

Parameters
----------
size : None or float or tuple of int, optional
    Size of the output image. Input into :func:`imgaug.imgaug.imresize_single_image`.
    Usually expected to be a tuple ``(H, W)``, where ``H`` is the desired height
    and ``W`` is the width. If None, then the image will not be resized.

extract : None or 'square' or tuple of number or imgaug.BoundingBox or imgaug.BoundingBoxesOnImage
    Subarea of the quokka image to extract:

        * If None, then the whole image will be used.
        * If string ``square``, then a squared area ``(x: 0 to max 643, y: 0 to max 643)`` will
          be extracted from the image.
        * If a tuple, then expected to contain four numbers denoting ``x1``, ``y1``, ``x2``
          and ``y2``.
        * If a BoundingBox, then that bounding box's area will be extracted from the image.
        * If a BoundingBoxesOnImage, then expected to contain exactly one bounding box
          and a shape matching the full image dimensions (i.e. ``(643, 960, *)``). Then the
          one bounding box will be used similar to BoundingBox.

Returns
-------
img : (H,W,3) ndarray
    The image array of dtype uint8.


return quokka(size=size, extract="<STR_LIT>")<EOL>

Returns an (square) image of a quokka as a numpy array.

Parameters
----------
size : None or float or tuple of int, optional
    Size of the output image. Input into :func:`imgaug.imgaug.imresize_single_image`.
    Usually expected to be a tuple ``(H, W)``, where ``H`` is the desired height
    and ``W`` is the width. If None, then the image will not be resized.

Returns
-------
img : (H,W,3) ndarray
    The image array of dtype uint8.


<EOL>from imgaug.augmentables.heatmaps import HeatmapsOnImage<EOL>img = imageio.imread(QUOKKA_DEPTH_MAP_HALFRES_FP, pilmode="<STR_LIT>")<EOL>img = imresize_single_image(img, (<NUM_LIT>, <NUM_LIT>), interpolation="<STR_LIT>")<EOL>if extract is not None:<EOL><INDENT>bb = _quokka_normalize_extract(extract)<EOL>img = bb.extract_from_image(img)<EOL><DEDENT>if size is None:<EOL><INDENT>size = img.shape[<NUM_LIT:0>:<NUM_LIT:2>]<EOL><DEDENT>shape_resized = _compute_resized_shape(img.shape, size)<EOL>img = imresize_single_image(img, shape_resized[<NUM_LIT:0>:<NUM_LIT:2>])<EOL>img_0to1 = img[..., <NUM_LIT:0>]  <EOL>img_0to1 = img_0to1.astype(np.float32) / <NUM_LIT><EOL>img_0to1 = <NUM_LIT:1> - img_0to1  <EOL>return HeatmapsOnImage(img_0to1, shape=img_0to1.shape[<NUM_LIT:0>:<NUM_LIT:2>] + (<NUM_LIT:3>,))<EOL>

Returns a heatmap (here: depth map) for the standard example quokka image.

Parameters
----------
size : None or float or tuple of int, optional
    See :func:`imgaug.quokka`.

extract : None or 'square' or tuple of number or imgaug.BoundingBox or imgaug.BoundingBoxesOnImage
    See :func:`imgaug.quokka`.

Returns
-------
result : imgaug.HeatmapsOnImage
    Depth map as an heatmap object. Values close to 0.0 denote objects that are close to
    the camera. Values close to 1.0 denote objects that are furthest away (among all shown
    objects).


<EOL>from imgaug.augmentables.segmaps import SegmentationMapOnImage<EOL>with open(QUOKKA_ANNOTATIONS_FP, "<STR_LIT:r>") as f:<EOL><INDENT>json_dict = json.load(f)<EOL><DEDENT>xx = []<EOL>yy = []<EOL>for kp_dict in json_dict["<STR_LIT>"][<NUM_LIT:0>]["<STR_LIT>"]:<EOL><INDENT>x = kp_dict["<STR_LIT:x>"]<EOL>y = kp_dict["<STR_LIT:y>"]<EOL>xx.append(x)<EOL>yy.append(y)<EOL><DEDENT>img_seg = np.zeros((<NUM_LIT>, <NUM_LIT>, <NUM_LIT:1>), dtype=np.float32)<EOL>rr, cc = skimage.draw.polygon(np.array(yy), np.array(xx), shape=img_seg.shape)<EOL>img_seg[rr, cc] = <NUM_LIT:1.0><EOL>if extract is not None:<EOL><INDENT>bb = _quokka_normalize_extract(extract)<EOL>img_seg = bb.extract_from_image(img_seg)<EOL><DEDENT>segmap = SegmentationMapOnImage(img_seg, shape=img_seg.shape[<NUM_LIT:0>:<NUM_LIT:2>] + (<NUM_LIT:3>,))<EOL>if size is not None:<EOL><INDENT>shape_resized = _compute_resized_shape(img_seg.shape, size)<EOL>segmap = segmap.resize(shape_resized[<NUM_LIT:0>:<NUM_LIT:2>])<EOL>segmap.shape = tuple(shape_resized[<NUM_LIT:0>:<NUM_LIT:2>]) + (<NUM_LIT:3>,)<EOL><DEDENT>return segmap<EOL>

Returns a segmentation map for the standard example quokka image.

Parameters
----------
size : None or float or tuple of int, optional
    See :func:`imgaug.quokka`.

extract : None or 'square' or tuple of number or imgaug.BoundingBox or imgaug.BoundingBoxesOnImage
    See :func:`imgaug.quokka`.

Returns
-------
result : imgaug.SegmentationMapOnImage
    Segmentation map object.


<EOL>from imgaug.augmentables.kps import Keypoint, KeypointsOnImage<EOL>left, top = <NUM_LIT:0>, <NUM_LIT:0><EOL>if extract is not None:<EOL><INDENT>bb_extract = _quokka_normalize_extract(extract)<EOL>left = bb_extract.x1<EOL>top = bb_extract.y1<EOL><DEDENT>with open(QUOKKA_ANNOTATIONS_FP, "<STR_LIT:r>") as f:<EOL><INDENT>json_dict = json.load(f)<EOL><DEDENT>keypoints = []<EOL>for kp_dict in json_dict["<STR_LIT>"]:<EOL><INDENT>keypoints.append(Keypoint(x=kp_dict["<STR_LIT:x>"] - left, y=kp_dict["<STR_LIT:y>"] - top))<EOL><DEDENT>if extract is not None:<EOL><INDENT>shape = (bb_extract.height, bb_extract.width, <NUM_LIT:3>)<EOL><DEDENT>else:<EOL><INDENT>shape = (<NUM_LIT>, <NUM_LIT>, <NUM_LIT:3>)<EOL><DEDENT>kpsoi = KeypointsOnImage(keypoints, shape=shape)<EOL>if size is not None:<EOL><INDENT>shape_resized = _compute_resized_shape(shape, size)<EOL>kpsoi = kpsoi.on(shape_resized)<EOL><DEDENT>return kpsoi<EOL>

Returns example keypoints on the standard example quokke image.

The keypoints cover the eyes, ears, nose and paws.

Parameters
----------
size : None or float or tuple of int or tuple of float, optional
    Size of the output image on which the keypoints are placed. If None, then the keypoints
    are not projected to any new size (positions on the original image are used).
    Floats lead to relative size changes, ints to absolute sizes in pixels.

extract : None or 'square' or tuple of number or imgaug.BoundingBox or imgaug.BoundingBoxesOnImage
    Subarea to extract from the image. See :func:`imgaug.quokka`.

Returns
-------
kpsoi : imgaug.KeypointsOnImage
    Example keypoints on the quokka image.


<EOL>from imgaug.augmentables.bbs import BoundingBox, BoundingBoxesOnImage<EOL>left, top = <NUM_LIT:0>, <NUM_LIT:0><EOL>if extract is not None:<EOL><INDENT>bb_extract = _quokka_normalize_extract(extract)<EOL>left = bb_extract.x1<EOL>top = bb_extract.y1<EOL><DEDENT>with open(QUOKKA_ANNOTATIONS_FP, "<STR_LIT:r>") as f:<EOL><INDENT>json_dict = json.load(f)<EOL><DEDENT>bbs = []<EOL>for bb_dict in json_dict["<STR_LIT>"]:<EOL><INDENT>bbs.append(<EOL>BoundingBox(<EOL>x1=bb_dict["<STR_LIT>"] - left,<EOL>y1=bb_dict["<STR_LIT>"] - top,<EOL>x2=bb_dict["<STR_LIT>"] - left,<EOL>y2=bb_dict["<STR_LIT>"] - top<EOL>)<EOL>)<EOL><DEDENT>if extract is not None:<EOL><INDENT>shape = (bb_extract.height, bb_extract.width, <NUM_LIT:3>)<EOL><DEDENT>else:<EOL><INDENT>shape = (<NUM_LIT>, <NUM_LIT>, <NUM_LIT:3>)<EOL><DEDENT>bbsoi = BoundingBoxesOnImage(bbs, shape=shape)<EOL>if size is not None:<EOL><INDENT>shape_resized = _compute_resized_shape(shape, size)<EOL>bbsoi = bbsoi.on(shape_resized)<EOL><DEDENT>return bbsoi<EOL>

Returns example bounding boxes on the standard example quokke image.

Currently only a single bounding box is returned that covers the quokka.

Parameters
----------
size : None or float or tuple of int or tuple of float, optional
    Size of the output image on which the BBs are placed. If None, then the BBs
    are not projected to any new size (positions on the original image are used).
    Floats lead to relative size changes, ints to absolute sizes in pixels.

extract : None or 'square' or tuple of number or imgaug.BoundingBox or imgaug.BoundingBoxesOnImage
    Subarea to extract from the image. See :func:`imgaug.quokka`.

Returns
-------
bbsoi : imgaug.BoundingBoxesOnImage
    Example BBs on the quokka image.


<EOL>from imgaug.augmentables.polys import Polygon, PolygonsOnImage<EOL>left, top = <NUM_LIT:0>, <NUM_LIT:0><EOL>if extract is not None:<EOL><INDENT>bb_extract = _quokka_normalize_extract(extract)<EOL>left = bb_extract.x1<EOL>top = bb_extract.y1<EOL><DEDENT>with open(QUOKKA_ANNOTATIONS_FP, "<STR_LIT:r>") as f:<EOL><INDENT>json_dict = json.load(f)<EOL><DEDENT>polygons = []<EOL>for poly_json in json_dict["<STR_LIT>"]:<EOL><INDENT>polygons.append(<EOL>Polygon([(point["<STR_LIT:x>"] - left, point["<STR_LIT:y>"] - top)<EOL>for point in poly_json["<STR_LIT>"]])<EOL>)<EOL><DEDENT>if extract is not None:<EOL><INDENT>shape = (bb_extract.height, bb_extract.width, <NUM_LIT:3>)<EOL><DEDENT>else:<EOL><INDENT>shape = (<NUM_LIT>, <NUM_LIT>, <NUM_LIT:3>)<EOL><DEDENT>psoi = PolygonsOnImage(polygons, shape=shape)<EOL>if size is not None:<EOL><INDENT>shape_resized = _compute_resized_shape(shape, size)<EOL>psoi = psoi.on(shape_resized)<EOL><DEDENT>return psoi<EOL>

Returns example polygons on the standard example quokke image.

The result contains one polygon, covering the quokka's outline.

Parameters
----------
size : None or float or tuple of int or tuple of float, optional
    Size of the output image on which the polygons are placed. If None,
    then the polygons are not projected to any new size (positions on the
    original image are used). Floats lead to relative size changes, ints
    to absolute sizes in pixels.

extract : None or 'square' or tuple of number or imgaug.BoundingBox or \
          imgaug.BoundingBoxesOnImage
    Subarea to extract from the image. See :func:`imgaug.quokka`.

Returns
-------
psoi : imgaug.PolygonsOnImage
    Example polygons on the quokka image.


l1 = np.linalg.norm(v1)<EOL>l2 = np.linalg.norm(v2)<EOL>v1_u = (v1 / l1) if l1 > <NUM_LIT:0> else np.float32(v1) * <NUM_LIT:0><EOL>v2_u = (v2 / l2) if l2 > <NUM_LIT:0> else np.float32(v2) * <NUM_LIT:0><EOL>return np.arccos(np.clip(np.dot(v1_u, v2_u), -<NUM_LIT:1.0>, <NUM_LIT:1.0>))<EOL>

Returns the angle in radians between vectors `v1` and `v2`.

From http://stackoverflow.com/questions/2827393/angles-between-two-n-dimensional-vectors-in-python

Parameters
----------
v1 : (N,) ndarray
    First vector.

v2 : (N,) ndarray
    Second vector.

Returns
-------
out : float
    Angle in radians.

Examples
--------
>>> angle_between_vectors(np.float32([1, 0, 0]), np.float32([0, 1, 0]))
1.570796...

>>> angle_between_vectors(np.float32([1, 0, 0]), np.float32([1, 0, 0]))
0.0

>>> angle_between_vectors(np.float32([1, 0, 0]), np.float32([-1, 0, 0]))
3.141592...


def compute_line_intersection_point(x1, y1, x2, y2, x3, y3, x4, y4):

def _make_line(p1, p2):<EOL><INDENT>A = (p1[<NUM_LIT:1>] - p2[<NUM_LIT:1>])<EOL>B = (p2[<NUM_LIT:0>] - p1[<NUM_LIT:0>])<EOL>C = (p1[<NUM_LIT:0>]*p2[<NUM_LIT:1>] - p2[<NUM_LIT:0>]*p1[<NUM_LIT:1>])<EOL>return A, B, -C<EOL><DEDENT>L1 = _make_line((x1, y1), (x2, y2))<EOL>L2 = _make_line((x3, y3), (x4, y4))<EOL>D = L1[<NUM_LIT:0>] * L2[<NUM_LIT:1>] - L1[<NUM_LIT:1>] * L2[<NUM_LIT:0>]<EOL>Dx = L1[<NUM_LIT:2>] * L2[<NUM_LIT:1>] - L1[<NUM_LIT:1>] * L2[<NUM_LIT:2>]<EOL>Dy = L1[<NUM_LIT:0>] * L2[<NUM_LIT:2>] - L1[<NUM_LIT:2>] * L2[<NUM_LIT:0>]<EOL>if D != <NUM_LIT:0>:<EOL><INDENT>x = Dx / D<EOL>y = Dy / D<EOL>return x, y<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT>

Compute the intersection point of two lines.

Taken from https://stackoverflow.com/a/20679579 .

Parameters
----------
x1 : number
    x coordinate of the first point on line 1. (The lines extends beyond this point.)

y1 : number
    y coordinate of the first point on line 1. (The lines extends beyond this point.)

x2 : number
    x coordinate of the second point on line 1. (The lines extends beyond this point.)

y2 : number
    y coordinate of the second point on line 1. (The lines extends beyond this point.)

x3 : number
    x coordinate of the first point on line 2. (The lines extends beyond this point.)

y3 : number
    y coordinate of the first point on line 2. (The lines extends beyond this point.)

x4 : number
    x coordinate of the second point on line 2. (The lines extends beyond this point.)

y4 : number
    y coordinate of the second point on line 2. (The lines extends beyond this point.)

Returns
-------
tuple of number or bool
    The coordinate of the intersection point as a tuple ``(x, y)``.
    If the lines are parallel (no intersection point or an infinite number of them), the result is False.


def draw_text(img, y, x, text, color=(<NUM_LIT:0>, <NUM_LIT:255>, <NUM_LIT:0>), size=<NUM_LIT>):

do_assert(img.dtype in [np.uint8, np.float32])<EOL>input_dtype = img.dtype<EOL>if img.dtype == np.float32:<EOL><INDENT>img = img.astype(np.uint8)<EOL><DEDENT>img = PIL_Image.fromarray(img)<EOL>font = PIL_ImageFont.truetype(DEFAULT_FONT_FP, size)<EOL>context = PIL_ImageDraw.Draw(img)<EOL>context.text((x, y), text, fill=tuple(color), font=font)<EOL>img_np = np.asarray(img)<EOL>if not img_np.flags["<STR_LIT>"]:<EOL><INDENT>try:<EOL><INDENT>img_np.setflags(write=True)<EOL><DEDENT>except ValueError as ex:<EOL><INDENT>if "<STR_LIT>" in str(ex):<EOL><INDENT>img_np = np.copy(img_np)<EOL><DEDENT><DEDENT><DEDENT>if img_np.dtype != input_dtype:<EOL><INDENT>img_np = img_np.astype(input_dtype)<EOL><DEDENT>return img_np<EOL>

Draw text on an image.

This uses by default DejaVuSans as its font, which is included in this library.

dtype support::

    * ``uint8``: yes; fully tested
    * ``uint16``: no
    * ``uint32``: no
    * ``uint64``: no
    * ``int8``: no
    * ``int16``: no
    * ``int32``: no
    * ``int64``: no
    * ``float16``: no
    * ``float32``: yes; not tested
    * ``float64``: no
    * ``float128``: no
    * ``bool``: no

    TODO check if other dtypes could be enabled

Parameters
----------
img : (H,W,3) ndarray
    The image array to draw text on.
    Expected to be of dtype uint8 or float32 (value range 0.0 to 255.0).

y : int
    x-coordinate of the top left corner of the text.

x : int
    y- coordinate of the top left corner of the text.

text : str
    The text to draw.

color : iterable of int, optional
    Color of the text to draw. For RGB-images this is expected to be an RGB color.

size : int, optional
    Font size of the text to draw.

Returns
-------
img_np : (H,W,3) ndarray
    Input image with text drawn on it.


def imresize_many_images(images, sizes=None, interpolation=None):

<EOL>if len(images) == <NUM_LIT:0>:<EOL><INDENT>return images<EOL><DEDENT>do_assert(<EOL>all([image.shape[<NUM_LIT:0>] > <NUM_LIT:0> and image.shape[<NUM_LIT:1>] > <NUM_LIT:0> for image in images]),<EOL>("<STR_LIT>"<EOL>+ "<STR_LIT>") % (str([image.shape for image in images]),)<EOL>)<EOL>if is_single_number(sizes) and sizes <= <NUM_LIT:0>:<EOL><INDENT>raise Exception(<EOL>"<STR_LIT>" % (sizes,))<EOL><DEDENT>elif isinstance(sizes, tuple) and (sizes[<NUM_LIT:0>] <= <NUM_LIT:0> or sizes[<NUM_LIT:1>] <= <NUM_LIT:0>):<EOL><INDENT>sizes_str = [<EOL>"<STR_LIT>" % (sizes[<NUM_LIT:0>],) if is_single_integer(sizes[<NUM_LIT:0>]) else "<STR_LIT>" % (sizes[<NUM_LIT:0>],),<EOL>"<STR_LIT>" % (sizes[<NUM_LIT:1>],) if is_single_integer(sizes[<NUM_LIT:1>]) else "<STR_LIT>" % (sizes[<NUM_LIT:1>],),<EOL>]<EOL>sizes_str = "<STR_LIT>" % (sizes_str[<NUM_LIT:0>], sizes_str[<NUM_LIT:1>])<EOL>raise Exception(<EOL>"<STR_LIT>" % (sizes_str,))<EOL><DEDENT>if is_single_number(sizes):<EOL><INDENT>sizes = (sizes, sizes)<EOL><DEDENT>else:<EOL><INDENT>do_assert(len(sizes) == <NUM_LIT:2>, "<STR_LIT>" % (len(sizes),))<EOL>do_assert(all([is_single_number(val) for val in sizes]),<EOL>"<STR_LIT>" % (str([type(val) for val in sizes]),))<EOL><DEDENT>if isinstance(images, list):<EOL><INDENT>nb_shapes = len(set([image.shape for image in images]))<EOL>if nb_shapes == <NUM_LIT:1>:<EOL><INDENT>return list(imresize_many_images(np.array(images), sizes=sizes, interpolation=interpolation))<EOL><DEDENT>else:<EOL><INDENT>return [imresize_many_images(image[np.newaxis, ...], sizes=sizes, interpolation=interpolation)[<NUM_LIT:0>, ...]<EOL>for image in images]<EOL><DEDENT><DEDENT>shape = images.shape<EOL>do_assert(images.ndim in [<NUM_LIT:3>, <NUM_LIT:4>], "<STR_LIT>" % (str(shape),))<EOL>nb_images = shape[<NUM_LIT:0>]<EOL>im_height, im_width = shape[<NUM_LIT:1>], shape[<NUM_LIT:2>]<EOL>nb_channels = shape[<NUM_LIT:3>] if images.ndim > <NUM_LIT:3> else None<EOL>height, width = sizes[<NUM_LIT:0>], sizes[<NUM_LIT:1>]<EOL>height = int(np.round(im_height * height)) if is_single_float(height) else height<EOL>width = int(np.round(im_width * width)) if is_single_float(width) else width<EOL>if height == im_height and width == im_width:<EOL><INDENT>return np.copy(images)<EOL><DEDENT>ip = interpolation<EOL>do_assert(ip is None or ip in IMRESIZE_VALID_INTERPOLATIONS)<EOL>if ip is None:<EOL><INDENT>if height > im_height or width > im_width:<EOL><INDENT>ip = cv2.INTER_AREA<EOL><DEDENT>else:<EOL><INDENT>ip = cv2.INTER_LINEAR<EOL><DEDENT><DEDENT>elif ip in ["<STR_LIT>", cv2.INTER_NEAREST]:<EOL><INDENT>ip = cv2.INTER_NEAREST<EOL><DEDENT>elif ip in ["<STR_LIT>", cv2.INTER_LINEAR]:<EOL><INDENT>ip = cv2.INTER_LINEAR<EOL><DEDENT>elif ip in ["<STR_LIT>", cv2.INTER_AREA]:<EOL><INDENT>ip = cv2.INTER_AREA<EOL><DEDENT>else:  <EOL><INDENT>ip = cv2.INTER_CUBIC<EOL><DEDENT>from . import dtypes as iadt<EOL>if ip == cv2.INTER_NEAREST:<EOL><INDENT>iadt.gate_dtypes(images,<EOL>allowed=["<STR_LIT:bool>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>"],<EOL>disallowed=["<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>",<EOL>"<STR_LIT>", "<STR_LIT>", "<STR_LIT>"],<EOL>augmenter=None)<EOL><DEDENT>else:<EOL><INDENT>iadt.gate_dtypes(images,<EOL>allowed=["<STR_LIT:bool>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>"],<EOL>disallowed=["<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>",<EOL>"<STR_LIT>", "<STR_LIT>", "<STR_LIT>"],<EOL>augmenter=None)<EOL><DEDENT>result_shape = (nb_images, height, width)<EOL>if nb_channels is not None:<EOL><INDENT>result_shape = result_shape + (nb_channels,)<EOL><DEDENT>result = np.zeros(result_shape, dtype=images.dtype)<EOL>for i, image in enumerate(images):<EOL><INDENT>input_dtype = image.dtype<EOL>if image.dtype.type == np.bool_:<EOL><INDENT>image = image.astype(np.uint8) * <NUM_LIT:255><EOL><DEDENT>elif image.dtype.type == np.int8 and ip != cv2.INTER_NEAREST:<EOL><INDENT>image = image.astype(np.int16)<EOL><DEDENT>elif image.dtype.type == np.float16:<EOL><INDENT>image = image.astype(np.float32)<EOL><DEDENT>result_img = cv2.resize(image, (width, height), interpolation=ip)<EOL>assert result_img.dtype == image.dtype<EOL>if len(result_img.shape) == <NUM_LIT:2> and nb_channels is not None and nb_channels == <NUM_LIT:1>:<EOL><INDENT>result_img = result_img[:, :, np.newaxis]<EOL><DEDENT>if input_dtype.type == np.bool_:<EOL><INDENT>result_img = result_img > <NUM_LIT><EOL><DEDENT>elif input_dtype.type == np.int8 and ip != cv2.INTER_NEAREST:<EOL><INDENT>from . import dtypes as iadt<EOL>result_img = iadt.restore_dtypes_(result_img, np.int8)<EOL><DEDENT>elif input_dtype.type == np.float16:<EOL><INDENT>from . import dtypes as iadt<EOL>result_img = iadt.restore_dtypes_(result_img, np.float16)<EOL><DEDENT>result[i] = result_img<EOL><DEDENT>return result<EOL>

Resize many images to a specified size.

dtype support::

    * ``uint8``: yes; fully tested
    * ``uint16``: yes; tested
    * ``uint32``: no (1)
    * ``uint64``: no (2)
    * ``int8``: yes; tested (3)
    * ``int16``: yes; tested
    * ``int32``: limited; tested (4)
    * ``int64``: no (2)
    * ``float16``: yes; tested (5)
    * ``float32``: yes; tested
    * ``float64``: yes; tested
    * ``float128``: no (1)
    * ``bool``: yes; tested (6)

    - (1) rejected by ``cv2.imresize``
    - (2) results too inaccurate
    - (3) mapped internally to ``int16`` when interpolation!="nearest"
    - (4) only supported for interpolation="nearest", other interpolations lead to cv2 error
    - (5) mapped internally to ``float32``
    - (6) mapped internally to ``uint8``

Parameters
----------
images : (N,H,W,[C]) ndarray or list of (H,W,[C]) ndarray
    Array of the images to resize.
    Usually recommended to be of dtype uint8.

sizes : float or iterable of int or iterable of float
    The new size of the images, given either as a fraction (a single float) or as
    a ``(height, width)`` tuple of two integers or as a ``(height fraction, width fraction)``
    tuple of two floats.

interpolation : None or str or int, optional
    The interpolation to use during resize.
    If int, then expected to be one of:

        * ``cv2.INTER_NEAREST`` (nearest neighbour interpolation)
        * ``cv2.INTER_LINEAR`` (linear interpolation)
        * ``cv2.INTER_AREA`` (area interpolation)
        * ``cv2.INTER_CUBIC`` (cubic interpolation)

    If string, then expected to be one of:

        * ``nearest`` (identical to ``cv2.INTER_NEAREST``)
        * ``linear`` (identical to ``cv2.INTER_LINEAR``)
        * ``area`` (identical to ``cv2.INTER_AREA``)
        * ``cubic`` (identical to ``cv2.INTER_CUBIC``)

    If None, the interpolation will be chosen automatically. For size
    increases, area interpolation will be picked and for size decreases,
    linear interpolation will be picked.

Returns
-------
result : (N,H',W',[C]) ndarray
    Array of the resized images.

Examples
--------
>>> imresize_many_images(np.zeros((2, 16, 16, 3), dtype=np.uint8), 2.0)

Converts 2 RGB images of height and width 16 to images of height and width 16*2 = 32.

>>> imresize_many_images(np.zeros((2, 16, 16, 3), dtype=np.uint8), (16, 32))

Converts 2 RGB images of height and width 16 to images of height 16 and width 32.

>>> imresize_many_images(np.zeros((2, 16, 16, 3), dtype=np.uint8), (2.0, 4.0))

Converts 2 RGB images of height and width 16 to images of height 32 and width 64.


def imresize_single_image(image, sizes, interpolation=None):

grayscale = False<EOL>if image.ndim == <NUM_LIT:2>:<EOL><INDENT>grayscale = True<EOL>image = image[:, :, np.newaxis]<EOL><DEDENT>do_assert(len(image.shape) == <NUM_LIT:3>, image.shape)<EOL>rs = imresize_many_images(image[np.newaxis, :, :, :], sizes, interpolation=interpolation)<EOL>if grayscale:<EOL><INDENT>return np.squeeze(rs[<NUM_LIT:0>, :, :, <NUM_LIT:0>])<EOL><DEDENT>else:<EOL><INDENT>return rs[<NUM_LIT:0>, ...]<EOL><DEDENT>

Resizes a single image.

dtype support::

    See :func:`imgaug.imgaug.imresize_many_images`.

Parameters
----------
image : (H,W,C) ndarray or (H,W) ndarray
    Array of the image to resize.
    Usually recommended to be of dtype uint8.

sizes : float or iterable of int or iterable of float
    See :func:`imgaug.imgaug.imresize_many_images`.

interpolation : None or str or int, optional
    See :func:`imgaug.imgaug.imresize_many_images`.

Returns
-------
out : (H',W',C) ndarray or (H',W') ndarray
    The resized image.


def pad(arr, top=<NUM_LIT:0>, right=<NUM_LIT:0>, bottom=<NUM_LIT:0>, left=<NUM_LIT:0>, mode="<STR_LIT>", cval=<NUM_LIT:0>):

do_assert(arr.ndim in [<NUM_LIT:2>, <NUM_LIT:3>])<EOL>do_assert(top >= <NUM_LIT:0>)<EOL>do_assert(right >= <NUM_LIT:0>)<EOL>do_assert(bottom >= <NUM_LIT:0>)<EOL>do_assert(left >= <NUM_LIT:0>)<EOL>if top > <NUM_LIT:0> or right > <NUM_LIT:0> or bottom > <NUM_LIT:0> or left > <NUM_LIT:0>:<EOL><INDENT>mapping_mode_np_to_cv2 = {<EOL>"<STR_LIT>": cv2.BORDER_CONSTANT,<EOL>"<STR_LIT>": cv2.BORDER_REPLICATE,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": cv2.BORDER_REFLECT_101,<EOL>"<STR_LIT>": cv2.BORDER_REFLECT,<EOL>"<STR_LIT>": None,<EOL>cv2.BORDER_CONSTANT: cv2.BORDER_CONSTANT,<EOL>cv2.BORDER_REPLICATE: cv2.BORDER_REPLICATE,<EOL>cv2.BORDER_REFLECT_101: cv2.BORDER_REFLECT_101,<EOL>cv2.BORDER_REFLECT: cv2.BORDER_REFLECT<EOL>}<EOL>bad_mode_cv2 = mapping_mode_np_to_cv2.get(mode, None) is None<EOL>bad_datatype_cv2 = arr.dtype.name in ["<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT:bool>"]<EOL>if not bad_datatype_cv2 and not bad_mode_cv2:<EOL><INDENT>cval = float(cval) if arr.dtype.kind == "<STR_LIT:f>" else int(cval)  <EOL>if arr.ndim == <NUM_LIT:2> or arr.shape[<NUM_LIT:2>] <= <NUM_LIT:4>:<EOL><INDENT>if arr.ndim == <NUM_LIT:3>:<EOL><INDENT>cval = tuple([cval] * arr.shape[<NUM_LIT:2>])<EOL><DEDENT>arr_pad = cv2.copyMakeBorder(arr, top=top, bottom=bottom, left=left, right=right,<EOL>borderType=mapping_mode_np_to_cv2[mode], value=cval)<EOL>if arr.ndim == <NUM_LIT:3> and arr_pad.ndim == <NUM_LIT:2>:<EOL><INDENT>arr_pad = arr_pad[..., np.newaxis]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>result = []<EOL>channel_start_idx = <NUM_LIT:0><EOL>while channel_start_idx < arr.shape[<NUM_LIT:2>]:<EOL><INDENT>arr_c = arr[..., channel_start_idx:channel_start_idx+<NUM_LIT:4>]<EOL>cval_c = tuple([cval] * arr_c.shape[<NUM_LIT:2>])<EOL>arr_pad_c = cv2.copyMakeBorder(arr_c, top=top, bottom=bottom, left=left, right=right,<EOL>borderType=mapping_mode_np_to_cv2[mode], value=cval_c)<EOL>arr_pad_c = np.atleast_3d(arr_pad_c)<EOL>result.append(arr_pad_c)<EOL>channel_start_idx += <NUM_LIT:4><EOL><DEDENT>arr_pad = np.concatenate(result, axis=<NUM_LIT:2>)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>paddings_np = [(top, bottom), (left, right)]  <EOL>if arr.ndim == <NUM_LIT:3>:<EOL><INDENT>paddings_np.append((<NUM_LIT:0>, <NUM_LIT:0>))  <EOL><DEDENT>if mode == "<STR_LIT>":<EOL><INDENT>arr_pad = np.pad(arr, paddings_np, mode=mode, constant_values=cval)<EOL><DEDENT>elif mode == "<STR_LIT>":<EOL><INDENT>arr_pad = np.pad(arr, paddings_np, mode=mode, end_values=cval)<EOL><DEDENT>else:<EOL><INDENT>arr_pad = np.pad(arr, paddings_np, mode=mode)<EOL><DEDENT><DEDENT>return arr_pad<EOL><DEDENT>return np.copy(arr)<EOL>

Pad an image-like array on its top/right/bottom/left side.

This function is a wrapper around :func:`numpy.pad`.

dtype support::

    * ``uint8``: yes; fully tested (1)
    * ``uint16``: yes; fully tested (1)
    * ``uint32``: yes; fully tested (2) (3)
    * ``uint64``: yes; fully tested (2) (3)
    * ``int8``: yes; fully tested (1)
    * ``int16``: yes; fully tested (1)
    * ``int32``: yes; fully tested (1)
    * ``int64``: yes; fully tested (2) (3)
    * ``float16``: yes; fully tested (2) (3)
    * ``float32``: yes; fully tested (1)
    * ``float64``: yes; fully tested (1)
    * ``float128``: yes; fully tested (2) (3)
    * ``bool``: yes; tested (2) (3)

    - (1) Uses ``cv2`` if `mode` is one of: ``"constant"``, ``"edge"``, ``"reflect"``, ``"symmetric"``.
          Otherwise uses ``numpy``.
    - (2) Uses ``numpy``.
    - (3) Rejected by ``cv2``.

Parameters
----------
arr : (H,W) ndarray or (H,W,C) ndarray
    Image-like array to pad.

top : int, optional
    Amount of pixels to add at the top side of the image. Must be 0 or greater.

right : int, optional
    Amount of pixels to add at the right side of the image. Must be 0 or greater.

bottom : int, optional
    Amount of pixels to add at the bottom side of the image. Must be 0 or greater.

left : int, optional
    Amount of pixels to add at the left side of the image. Must be 0 or greater.

mode : str, optional
    Padding mode to use. See :func:`numpy.pad` for details.
    In case of mode ``constant``, the parameter `cval` will be used as the ``constant_values``
    parameter to :func:`numpy.pad`.
    In case of mode ``linear_ramp``, the parameter `cval` will be used as the ``end_values``
    parameter to :func:`numpy.pad`.

cval : number, optional
    Value to use for padding if `mode` is ``constant``. See :func:`numpy.pad` for details.
    The cval is expected to match the input array's dtype and value range.

Returns
-------
arr_pad : (H',W') ndarray or (H',W',C) ndarray
    Padded array with height ``H'=H+top+bottom`` and width ``W'=W+left+right``.


do_assert(arr.ndim in [<NUM_LIT:2>, <NUM_LIT:3>])<EOL>do_assert(aspect_ratio > <NUM_LIT:0>)<EOL>height, width = arr.shape[<NUM_LIT:0>:<NUM_LIT:2>]<EOL>do_assert(height > <NUM_LIT:0>)<EOL>aspect_ratio_current = width / height<EOL>pad_top = <NUM_LIT:0><EOL>pad_right = <NUM_LIT:0><EOL>pad_bottom = <NUM_LIT:0><EOL>pad_left = <NUM_LIT:0><EOL>if aspect_ratio_current < aspect_ratio:<EOL><INDENT>diff = (aspect_ratio * height) - width<EOL>pad_right = int(np.ceil(diff / <NUM_LIT:2>))<EOL>pad_left = int(np.floor(diff / <NUM_LIT:2>))<EOL><DEDENT>elif aspect_ratio_current > aspect_ratio:<EOL><INDENT>diff = ((<NUM_LIT:1>/aspect_ratio) * width) - height<EOL>pad_top = int(np.floor(diff / <NUM_LIT:2>))<EOL>pad_bottom = int(np.ceil(diff / <NUM_LIT:2>))<EOL><DEDENT>return pad_top, pad_right, pad_bottom, pad_left<EOL>

Compute the amount of pixels by which an array has to be padded to fulfill an aspect ratio.

The aspect ratio is given as width/height.
Depending on which dimension is smaller (height or width), only the corresponding
sides (left/right or top/bottom) will be padded. In each case, both of the sides will
be padded equally.

Parameters
----------
arr : (H,W) ndarray or (H,W,C) ndarray
    Image-like array for which to compute pad amounts.

aspect_ratio : float
    Target aspect ratio, given as width/height. E.g. 2.0 denotes the image having twice
    as much width as height.

Returns
-------
result : tuple of int
    Required paddign amounts to reach the target aspect ratio, given as a tuple
    of the form ``(top, right, bottom, left)``.