xypiece : xy piece
557565
def parse_xy_piece
      s0 = @current_pos
      s1 = parse_xy
      if s1 != :failed
        s2 = parse_piece
        if s2 != :failed
          @reported_pos = s0
          s0 = { "xy" => s1, "piece" => s2 }
        else
          @current_pos = s0
          s0 = :failed
        end
      else
        @current_pos = s0
        s0 = :failed
      end
      s0
    end
104285
function smix (B, Bi, r, N, V, XY) {
    var Xi = 0
    var Yi = 128 * r
    var i

    B.copy(XY, Xi, Bi, Bi + Yi)

    for (i = 0; i < N; i++) {
      XY.copy(V, i * Yi, Xi, Xi + Yi)
      blockmix_salsa8(XY, Xi, Yi, r)

      if (tickCallback) tickCallback()
    }

    for (i = 0; i < N; i++) {
      var offset = Xi + (2 * r - 1) * 64
      var j = XY.readUInt32LE(offset) & (N - 1)
      blockxor(V, j * Yi, XY, Xi, Yi)
      blockmix_salsa8(XY, Xi, Yi, r)

      if (tickCallback) tickCallback()
    }

    XY.copy(B, Bi, Xi, Xi + Yi)
  }
655047
def xyY_to_XYZ(cobj, *args, **kwargs):
    
    # avoid division by zero
    if cobj.xyy_y == 0.0:
        xyz_x = 0.0
        xyz_y = 0.0
        xyz_z = 0.0
    else:
        xyz_x = (cobj.xyy_x * cobj.xyy_Y) / cobj.xyy_y
        xyz_y = cobj.xyy_Y
        xyz_z = ((1.0 - cobj.xyy_x - cobj.xyy_y) * xyz_y) / cobj.xyy_y

    return XYZColor(
        xyz_x, xyz_y, xyz_z, illuminant=cobj.illuminant, observer=cobj.observer)
260715
def visual(title, X, name):
    
    assert len(X.shape) == 4
    X = X.transpose((0, 2, 3, 1))
    X = np.clip((X - np.min(X))*(255.0/(np.max(X) - np.min(X))), 0, 255).astype(np.uint8)
    n = np.ceil(np.sqrt(X.shape[0]))
    buff = np.zeros((int(n*X.shape[1]), int(n*X.shape[2]), int(X.shape[3])), dtype=np.uint8)
    for i, img in enumerate(X):
        fill_buf(buff, i, img, X.shape[1:3])
    buff = buff[:, :, ::-1]
    plt.imshow(buff)
    plt.title(title)
    plt.savefig(name)
1275207
def ipix_to_xypix(self, ipix, colwise=False):
        
        return np.unravel_index(ipix, self.npix,
                                order='F' if colwise else 'C')
771516
def xywh_from_points(points):
    
    xys = [[int(p) for p in pair.split(',')] for pair in points.split(' ')]
    minx = sys.maxsize
    miny = sys.maxsize
    maxx = 0
    maxy = 0
    for xy in xys:
        if xy[0] < minx:
            minx = xy[0]
        if xy[0] > maxx:
            maxx = xy[0]
        if xy[1] < miny:
            miny = xy[1]
        if xy[1] > maxy:
            maxy = xy[1]

    return {
        'x': minx,
        'y': miny,
        'w': maxx - minx,
        'h': maxy - miny,
    }
77777
def _setup_xy(self,bounds,xdensity,ydensity,x,y,orientation):
        
        self.debug("bounds=%s, xdensity=%s, ydensity=%s, x=%s, y=%s, orientation=%s",bounds,xdensity,ydensity,x,y,orientation)
        # Generate vectors representing coordinates at which the pattern
        # will be sampled.

        # CB: note to myself - use slice_._scs if supplied?
        x_points,y_points = SheetCoordinateSystem(bounds,xdensity,ydensity).sheetcoordinates_of_matrixidx()

        # Generate matrices of x and y sheet coordinates at which to
        # sample pattern, at the correct orientation
        self.pattern_x, self.pattern_y = self._create_and_rotate_coordinate_arrays(x_points-x,y_points-y,orientation)
32749
function (dx, dy) {

    	    var phynode_id = this.id;

	    // Move box positions.
    	    var assoc_phynodes = get_descendant_phynodes(phynode_id);
    	    for( var si = 0; si < assoc_phynodes.length; si++ ){
		var mshp = assoc_phynodes[si];
		mshp.move_y(dy);
		//ll('mshp['+si+']:'+' oy: '+mshp.start_y+', dy:'+dy);
    	    }

	    // Collect subtree edges for next bit.
	    var dimmable_subtree = {};
	    var subtree_edges = get_descendant_connections(phynode_id);
	    for( var se = 0; se < subtree_edges.length; se++ ){
		var ste = subtree_edges[se];
		dimmable_subtree[ste.id] = true;
	    }

	    // Update connections; keep subtree dimmed while in transit.
            for (var i = connections.length; i--;) {
		var conn = connections[i];
		if( dimmable_subtree[conn.id] ){
		    conn.update('dim');		
		}else{
		    conn.update();		
		}
            }
            paper.safari();
	}
410253
def solid(self, x, y):
        
        if not(0 <= x < self.xsize) or not(0 <= y < self.ysize):
            return False
        if self.data[x, y] == 0:
            return False
        return True
1157445
function (index, xy) {
            var show = true,
              axis = this.axis,
              isFirst = this.isFirst,
              isLast = this.isLast,
              horiz = axis.horiz,
              pxPos = horiz ? xy.x : xy.y,
              reversed = axis.reversed,
              tickPositions = axis.tickPositions,
              sides = this.getLabelSides(),
              leftSide = sides[0],
              rightSide = sides[1],
              axisLeft,
              axisRight,
              neighbour,
              neighbourEdge,
              line = this.label.line,
              lineIndex = line || 0,
              labelEdge = axis.labelEdge,
              justifyLabel = axis.justifyLabels && (isFirst || isLast),
              justifyToPlot;

            // Hide it if it now overlaps the neighbour label
            if (labelEdge[lineIndex] === UNDEFINED || pxPos + leftSide > labelEdge[lineIndex]) {
                labelEdge[lineIndex] = pxPos + rightSide;

            } else if (!justifyLabel) {
                show = false;
            }

            if (justifyLabel) {
                justifyToPlot = axis.justifyToPlot;
                axisLeft = justifyToPlot ? axis.pos : 0;
                axisRight = justifyToPlot ? axisLeft + axis.len : axis.chart.chartWidth;

                // Find the firsth neighbour on the same line
                do {
                    index += (isFirst ? 1 : -1);
                    neighbour = axis.ticks[tickPositions[index]];
                } while (tickPositions[index] && (!neighbour || !neighbour.label || neighbour.label.line !== line)); // #3044

                neighbourEdge = neighbour && neighbour.label.xy && neighbour.label.xy.x + neighbour.getLabelSides()[isFirst ? 0 : 1];

                if ((isFirst && !reversed) || (isLast && reversed)) {
                    // Is the label spilling out to the left of the plot area?
                    if (pxPos + leftSide < axisLeft) {

                        // Align it to plot left
                        pxPos = axisLeft - leftSide;

                        // Hide it if it now overlaps the neighbour label
                        if (neighbour && pxPos + rightSide > neighbourEdge) {
                            show = false;
                        }
                    }

                } else {
                    // Is the label spilling out to the right of the plot area?
                    if (pxPos + rightSide > axisRight) {

                        // Align it to plot right
                        pxPos = axisRight - rightSide;

                        // Hide it if it now overlaps the neighbour label
                        if (neighbour && pxPos + leftSide < neighbourEdge) {
                            show = false;
                        }

                    }
                }

                // Set the modified x position of the label
                xy.x = pxPos;
            }
            return show;
        }
791581
def panset_xy(self, data_x, data_y, no_reset=False):
        
        pan_coord = self.t_['pan_coord']
        # To center on the pixel
        if pan_coord == 'wcs':
            image = self.get_image()
            if image is None:
                return
            pan_x, pan_y = image.pixtoradec(data_x, data_y)
        else:
            pan_x, pan_y = data_x, data_y

        self.set_pan(pan_x, pan_y, coord=pan_coord, no_reset=no_reset)
470406
def recursive_xy_divide(elems, avg_font_size):
    
    log = logging.getLogger(__name__)
    log.info(avg_font_size)
    objects = list(elems.mentions)
    objects.extend(elems.segments)
    bboxes = []

    # A tree that is a list of its children
    # bboxes can be recursively reconstructed from
    # the leaves
    def divide(objs, bbox, h_split=True, is_single=False):
        """
        Recursive wrapper for splitting a list of objects
        with bounding boxes.
        h_split: whether to split along y axis, otherwise
        we split along x axis.
        """
        if not objs:
            return []

        # range start/end indices
        axis = 1 if h_split else 0

        intervals, groups = project_onto(objs, axis, avg_font_size)

        # base case where we can not actually divide
        single_child = len(groups) == 1

        # Can not divide in both X and Y, stop
        if is_single and single_child:
            bboxes.append(bbox)
            return objs
        else:
            children = []

            for interval, group in zip(intervals, groups):
                # Create the bbox for the subgroup
                sub_bbox = np.array(bbox)
                sub_bbox[[axis, axis + 2]] = interval
                # Append the sub-document tree
                child = divide(group, sub_bbox, not h_split, single_child)
                children.append(child)
            return children

    full_page_bbox = (0, 0, elems.layout.width, elems.layout.height)
    # Filter out invalid objects
    objects = [o for o in objects if inside(full_page_bbox, o.bbox)]
    log.info("avg_font_size for dividing", avg_font_size)
    tree = divide(objects, full_page_bbox) if objects else []
    return bboxes, tree
9589
function slice(str, beginSlice, endSlice) {
  return GraphemeBreaker.break(str)
    .slice(beginSlice, endSlice)
    .join('');
}
426953
def piece(piece: chess.Piece, size: Optional[int] = None) -> str:
    
    svg = _svg(SQUARE_SIZE, size)
    svg.append(ET.fromstring(PIECES[piece.symbol()]))
    return SvgWrapper(ET.tostring(svg).decode("utf-8"))
786918
def df2plotshape(dlen,xlabel_unit,ylabel_unit,
                 suptitle='',fix='h',xlabel_skip=[],
                 test=False):
    
    dlen['xlabel']=dlen.apply(lambda x : f"{x['_xlen']}" if not x['title'] in xlabel_skip else '',axis=1)
    dlen['ylabel']=dlen.apply(lambda x : "",axis=1)
    ylen=dlen['_ylen'].unique()[0]
    
    if test: print(dlen.columns)
    if fix=='h':    
        dlen['xlen']=dlen['_xlen']/dlen['_xlen'].max()/len(dlen)*0.8
        dlen['ylen']=0.8
        subsets=[]
        for subset in [c for c in dlen if c.startswith('_ylen ')]:
            subsetcol=subset.replace('_ylen','ylen')
            dlen[subsetcol]=0.25
            subsets.append(subsetcol)
        subsets2cols=dict(zip([subsetcol.replace('ylen ','') for s in subsets],subsets))
        if test: print(dlen.columns)
        if test: print(subsets2cols)
    elif fix=='w':    
        dlen['xlen']=0.8
        dlen['ylen']=dlen['_ylen']/dlen['_ylen'].max()/len(dlen)*0.85
   
    dlen=dlen.drop([c for c in dlen if c.startswith('_')],axis=1)    
    if test: print(dlen.columns)
    if fig is None:fig = plt.figure(figsize=[4,4])
    for idx in dlen.index:
        if idx==0:x_=0
        kws_plot_rect=makekws_plot_rect(dlen,fig,idx,x_)
        if test: print(kws_plot_rect)
        kws_plot_rect_big={k:kws_plot_rect[k] for k in kws_plot_rect if not 'ylen ' in k}
        kws_plot_rect_big['color']='gray'
        ax=plot_rect(**kws_plot_rect_big)
        for subset in subsets2cols:
            kws_plot_rect=makekws_plot_rect(dlen.drop('ylen',axis=1).rename(columns={subsets2cols[subset]:'ylen'}),fig,idx,x_)
            kws_plot_rect['title']=''
            kws_plot_rect['xlabel']=''
            kws_plot_rect['ylabel']=subset
            if idx!=0:kws_plot_rect['ylabel']=''
            if test: print(kws_plot_rect)
            ax=plot_rect(**kws_plot_rect)            
        x_=kws_plot_rect['x']+dlen.loc[idx,'xlen']+0.1  
    
    ax.text(x_/2.3,-0.1,xlabel_unit,ha='center')
    ax.text(x_/2.3,0.9,suptitle,ha='center')
    ax.text(-0.1,0.4,f"total ~{ylen}{ylabel_unit}",va='center',rotation=90)
    if fig is not None:
        return fig,ax
    else:
        return ax
1257445
def points_from_xywh(box):
    
    x, y, w, h = box['x'], box['y'], box['w'], box['h']
    # tesseract uses a different region representation format
    return "%i,%i %i,%i %i,%i %i,%i" % (
        x, y,
        x + w, y,
        x + w, y + h,
        x, y + h
    )
1215736
protected void initializePieces() {
    pieces.add(new Piece("x", " x /xxx/ x ", false, oneRotation));
    pieces.add(new Piece("v", "x  /x  /xxx", false, fourRotations));
    pieces.add(new Piece("t", "xxx/ x / x ", false, fourRotations));
    pieces.add(new Piece("w", "  x/ xx/xx ", false, fourRotations));
    pieces.add(new Piece("u", "x x/xxx", false, fourRotations));
    pieces.add(new Piece("i", "xxxxx", false, twoRotations));
    pieces.add(new Piece("f", " xx/xx / x ", true, fourRotations));
    pieces.add(new Piece("p", "xx/xx/x ", true, fourRotations));
    pieces.add(new Piece("z", "xx / x / xx", true, twoRotations));
    pieces.add(new Piece("n", "xx  / xxx", true, fourRotations));
    pieces.add(new Piece("y", "  x /xxxx", true, fourRotations));
    pieces.add(new Piece("l", "   x/xxxx", true, fourRotations));
  }