All vertical squares from the piece's point of view.

        Returns a list of relative movements up to the board's bound.
164997
def verticals(self):
        
        vertical_shifts = set(izip_longest([], map(
            lambda i: i - self.y, range(self.board.height)), fillvalue=0))
        vertical_shifts.discard((0, 0))
        return vertical_shifts
309212
public static Map<Point2D, Ruling[]> findIntersections(List<Ruling> horizontals, List<Ruling> verticals) {
        
        class SortObject {
            protected SOType type;
            protected float position;
            protected Ruling ruling;
            
            public SortObject(SOType type, float position, Ruling ruling) {
                this.type = type;
                this.position = position;
                this.ruling = ruling;
            }
        }
        
        List<SortObject> sos = new ArrayList<>();
        
        TreeMap<Ruling, Boolean> tree = new TreeMap<>(new Comparator<Ruling>() {
            @Override
            public int compare(Ruling o1, Ruling o2) {
                return java.lang.Double.compare(o1.getTop(), o2.getTop());
            }});
        
        TreeMap<Point2D, Ruling[]> rv = new TreeMap<>(new Comparator<Point2D>() {
            @Override
            public int compare(Point2D o1, Point2D o2) {
                if (o1.getY() > o2.getY()) return  1;
                if (o1.getY() < o2.getY()) return -1;
                if (o1.getX() > o2.getX()) return  1;
                if (o1.getX() < o2.getX()) return -1;
                return 0;
            }
        });
        
        for (Ruling h : horizontals) {
            sos.add(new SortObject(SOType.HLEFT, h.getLeft() - PERPENDICULAR_PIXEL_EXPAND_AMOUNT, h));
            sos.add(new SortObject(SOType.HRIGHT, h.getRight() + PERPENDICULAR_PIXEL_EXPAND_AMOUNT, h));
        }

        for (Ruling v : verticals) {
            sos.add(new SortObject(SOType.VERTICAL, v.getLeft(), v));
        }
        
        Collections.sort(sos, new Comparator<SortObject>() {
            @Override
            public int compare(SortObject a, SortObject b) {
                int rv;
                if (Utils.feq(a.position, b.position)) {
                    if (a.type == SOType.VERTICAL && b.type == SOType.HLEFT) {
                       rv = 1;     
                    }
                    else if (a.type == SOType.VERTICAL && b.type == SOType.HRIGHT) {
                       rv = -1;
                    }
                    else if (a.type == SOType.HLEFT && b.type == SOType.VERTICAL) {
                       rv = -1;
                    }
                    else if (a.type == SOType.HRIGHT && b.type == SOType.VERTICAL) {
                       rv = 1;
                     }
                    else {
                       rv = java.lang.Double.compare(a.position, b.position);
                    }
                }
                else {
                    return java.lang.Double.compare(a.position, b.position);
                }
                return rv;
            }
        });
        
        for (SortObject so : sos) {
            switch(so.type) {
            case VERTICAL:
                for (Map.Entry<Ruling, Boolean> h : tree.entrySet()) {
                    Point2D i = h.getKey().intersectionPoint(so.ruling);
                    if (i == null) {
                        continue;
                    }
                    rv.put(i, 
                           new Ruling[] { h.getKey().expand(PERPENDICULAR_PIXEL_EXPAND_AMOUNT), 
                                          so.ruling.expand(PERPENDICULAR_PIXEL_EXPAND_AMOUNT) });
                }
                break;
            case HRIGHT:
                tree.remove(so.ruling);
                break;
            case HLEFT:
                tree.put(so.ruling, true);
                break;
            }
        }
        
        return rv;
        
    }
229577
def positions_with_tile(self):
        
        for p, tile in numpy.ndenumerate(self._array):
            yield p, tile
295298
def grid_tiles(self, bbox, zoomlevel):
        
        tiles = self.tileslist(bbox, [zoomlevel])
        grid = {}
        for (z, x, y) in tiles:
            if not grid.get(y):
                grid[y] = []
            grid[y].append(x)
        sortedgrid = []
        for y in sorted(grid.keys(), reverse=self.tile_scheme == 'tms'):
            sortedgrid.append([(x, y) for x in sorted(grid[y])])
        return sortedgrid
33273
function getNotEmptyNearPositions(board, position) {
    return getNearPositions(board, position).filter(function (p) {
        return Position.hasPiece(p);
    });
}
769896
def get_open_spaces(board):
  """"""
  open_spaces = []
  for i in range(3):
    for j in range(3):
      if board[i][j] == 0:
        open_spaces.append(encode_pos(i, j))
  return open_spaces
384854
def bbox(self):
        """"""
        if not hasattr(self, '_bbox'):
            data = None
            for key in ('ARTBOARD_DATA1', 'ARTBOARD_DATA2', 'ARTBOARD_DATA3'):
                if key in self.tagged_blocks:
                    data = self.tagged_blocks.get_data(key)
            assert data is not None
            rect = data.get(b'artboardRect')
            self._bbox = (
                int(rect.get(b'Left')),
                int(rect.get(b'Top ')),
                int(rect.get(b'Rght')),
                int(rect.get(b'Btom')),
            )
        return self._bbox
1022817
def board_fen(self, *, promoted: Optional[bool] = False) -> str:
        
        builder = []
        empty = 0

        for square in SQUARES_180:
            piece = self.piece_at(square)

            if not piece:
                empty += 1
            else:
                if empty:
                    builder.append(str(empty))
                    empty = 0
                builder.append(piece.symbol())
                if promoted and BB_SQUARES[square] & self.promoted:
                    builder.append("~")

            if BB_SQUARES[square] & BB_FILE_H:
                if empty:
                    builder.append(str(empty))
                    empty = 0

                if square != H1:
                    builder.append("/")

        return "".join(builder)
806338
def _calc_all_possible_moves(self, input_color):
        
        for piece in self:

            # Tests if square on the board is not empty
            if piece is not None and piece.color == input_color:

                for move in piece.possible_moves(self):

                    test = cp(self)
                    test_move = Move(end_loc=move.end_loc,
                                     piece=test.piece_at_square(move.start_loc),
                                     status=move.status,
                                     start_loc=move.start_loc,
                                     promoted_to_piece=move.promoted_to_piece)
                    test.update(test_move)

                    if self.king_loc_dict is None:
                        yield move
                        continue

                    my_king = test.piece_at_square(self.king_loc_dict[input_color])

                    if my_king is None or \
                            not isinstance(my_king, King) or \
                            my_king.color != input_color:
                        self.king_loc_dict[input_color] = test.find_king(input_color)
                        my_king = test.piece_at_square(self.king_loc_dict[input_color])

                    if not my_king.in_check(test):
                        yield move
1112661
def _mark_grid_bounds(self, plane, region_bbox):
        
        # Grid boundaries
        vbars = np.zeros([self.num_rows, self.num_cols + 1], dtype=np.bool)
        hbars = np.zeros([self.num_rows + 1, self.num_cols], dtype=np.bool)

        def closest_idx(arr, elem):
            left = bisect.bisect_left(arr, elem) - 1
            right = bisect.bisect_right(arr, elem) - 1
            return left if abs(arr[left] - elem) < abs(arr[right] - elem) else right

        # Figure out which separating segments are missing, i.e. merge cells
        for row, (y0, y1) in enumerate(self.yranges):
            yc = (y0 + y1) // 2
            for l in plane.find((region_bbox.x0, yc, region_bbox.x1, yc)):
                vbars[row, closest_idx(self.xs, l.xc)] = True
        for col, (x0, x1) in enumerate(self.xranges):
            xc = (x0 + x1) // 2
            for l in plane.find((xc, region_bbox.y0, xc, region_bbox.y1)):
                hbars[closest_idx(self.ys, l.yc), col] = True
        return vbars, hbars
1260623
def pmt_angles(self):
        """"""
        if self._pmt_angles == []:
            mask = (self.pmts.du == 1) & (self.pmts.floor == 1)
            self._pmt_angles = self.pmts.dir[mask]
        return self._pmt_angles
876232
def list(self):
        """"""
        return [self._pos3d.x, self._pos3d.y, self._pos3d.z]
732573
def get_outer_bounding_boxes(rectangles):
    
    if len(rectangles) == 0:
        return []
    outer_bboxes = [rectangles[0]]
    for bbox2 in rectangles[1:]:
        overlap_indexes = []
        for i, bbox1 in enumerate(outer_bboxes):  # TODO: optimize this !!
            if doOverlap(bbox1, bbox2):
                overlap_indexes.append(i)
        for i in overlap_indexes:
            bbox2 = mergeBboxes(bbox2, outer_bboxes[i])
        for i in sorted(overlap_indexes, reverse=True):
            del outer_bboxes[i]
        outer_bboxes.append(bbox2)
    return outer_bboxes
839951
function getScore(board) {
    var pieces = Board.getPiecesFromBoard(board);
    var startEndRows = Board.getStartEndRows(board);
    var white = getColorScore(startEndRows.white, pieces.white);
    var black = getColorScore(startEndRows.black, pieces.black);
    return {
        ended: white.won || black.won,
        white: white,
        black: black
    };
}
782404
def get_surface_boundaries(self):
        
        min_lon, min_lat, max_lon, max_lat = self.get_bounding_box()
        return [[min_lon, max_lon]], [[min_lat, max_lat]]
527277
public static AxisAlignedBB[] getCollisionBoundingBoxes(World world, MBlockState state)
	{
		return getCollisionBoundingBoxes(world, state, false);
	}
720290
def enforce_vertical_symmetry(pixmap):
    ''''''
    mirror = []
    for item in pixmap:
        y = item[0]
        x = item[1]

        if x <= IMAGE_APEX:
            diff_x = diff(x, IMAGE_APEX)
            mirror.append((y, x + (2 * diff_x) - 1))

        if x > IMAGE_APEX:
            diff_x = diff(x, IMAGE_APEX)
            mirror.append((y, x - (2 * diff_x) - 1))

    return mirror + pixmap