Draw a quick preview of a sparse matrix with automated
    binning and normalization.
351599
def draw_sparse_matrix(
    array_filename,
    output_image,
    vmax=DEFAULT_SATURATION_THRESHOLD,
    max_size_matrix=DEFAULT_MAX_SIZE_MATRIX,
):
    

    matrix = np.loadtxt(array_filename, dtype=np.int32, skiprows=1)
    try:
        row, col, data = matrix.T
    except ValueError:
        row, col, data = matrix
    size = max(np.amax(row), np.amax(col)) + 1
    S = sparse.coo_matrix((data, (row, col)), shape=(size, size))
    if max_size_matrix <= 0:
        binning = 1
    else:
        binning = (size // max_size_matrix) + 1
    binned_S = hcs.bin_sparse(S, subsampling_factor=binning)
    dense_S = binned_S.todense()
    dense_S = dense_S + dense_S.T - np.diag(np.diag(dense_S))
    normed_S = hcs.normalize_dense(dense_S)
    spaceless_pdf_plot_maker(normed_S, output_image, vmax=vmax)
309327
private void describeImage(T input, List<Point2D_F64> points, FastQueue<TD> descs )
	{
		detDesc.detect(input);

		for( int i = 0; i < detDesc.getNumberOfFeatures(); i++ ) {
			points.add( detDesc.getLocation(i).copy() );
			descs.grow().setTo(detDesc.getDescription(i));
		}
	}
44525
def draw(self):
        ""
        glBindVertexArray( self.m_glVertArray )
        glActiveTexture( GL_TEXTURE0 )
        glBindTexture( GL_TEXTURE_2D, self.m_glTexture )
        glDrawElements( GL_TRIANGLES, self.m_unVertexCount, GL_UNSIGNED_SHORT, 0 )
        glBindVertexArray( 0 )
884997
def visualise(seq, sort=lambda x: x[0]):
    """"""
    frmt = "{:6} {:8,d} {}"
    if isinstance(seq, dict):
        seq = seq.items()
    if sort:
        seq = sorted(seq, key=sort)
    mx, mn = max([i[1] for i in seq]), min([i[1] for i in seq])  
    range = mx - mn
    for i in seq:
        v = int((i[1] * 100) / range)
        print (frmt.format(i[0], i[1], "*" * v))
868166
def canvas2pix(self, pos):
        
        x, y, z = pos
        #print('c2p in', x, y, z)
        mm = gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX)
        pm = gl.glGetDoublev(gl.GL_PROJECTION_MATRIX)
        vp = gl.glGetIntegerv(gl.GL_VIEWPORT)

        pt = glu.gluProject(x, y, z, mm, pm, vp)
        #print('c2p out', pt)
        return pt
1178881
def draw_hist(self, metric, title=""):
        
        # TODO: assert isinstance(list(values.values())[0], np.ndarray)

        rows = 1
        cols = 1
        limit = 10  # max steps to show

        # We need a 3D projection Subplot, so ignore the one provided to
        # as an create a new one.
        ax = self.figure.add_subplot(self.gs, projection="3d")
        ax.view_init(30, -80)

        # Compute histograms
        verts = []
        area_colors = []
        edge_colors = []
        for i, s in enumerate(metric.steps[-limit:]):
            hist, edges = np.histogram(metric.data[-i-1:])
            # X is bin centers
            x = np.diff(edges)/2 + edges[:-1]
            # Y is hist values
            y = hist
            x = np.concatenate([x[0:1], x, x[-1:]])
            y = np.concatenate([[0], y, [0]])

            # Ranges
            if i == 0:
                x_min = x.min()
                x_max = x.max()
                y_min = y.min()
                y_max = y.max()
            x_min = np.minimum(x_min, x.min())
            x_max = np.maximum(x_max, x.max())
            y_min = np.minimum(y_min, y.min())
            y_max = np.maximum(y_max, y.max())

            alpha = 0.8 * (i+1) / min(limit, len(metric.steps))
            verts.append(list(zip(x, y)))
            area_colors.append(np.array(self.theme["hist_color"] + [alpha]))
            edge_colors.append(np.array(self.theme["hist_outline_color"] + [alpha]))

        poly = PolyCollection(verts, facecolors=area_colors, edgecolors=edge_colors)
        ax.add_collection3d(poly, zs=list(range(min(limit, len(metric.steps)))), zdir='y')

        ax.set_xlim(x_min, x_max)
        ax.set_ylim(0, limit)
        ax.set_yticklabels(metric.formatted_steps[-limit:])
        ax.set_zlim(y_min, y_max)
        ax.set_title(metric.name)
988210
def print_matrix(X, decimals=1):
    """"""
    for row in np.round(X, decimals=decimals):
        print(row)
1342967
def draw(self):
        '''
        
        '''
        if self.__conditional_flag is True:
            return np.concatenate((self.__create_samples(), self.__create_samples()), axis=1)
        else:
            return self.__create_samples()
881680
def draw_arith(ax, p0, size=1, alpha=0, arith=None, format=None,
               fontsize=10, **kwds):
    """
    if format is None: format = 'k-'
    a = size/2.0
    x0 = [0, 2.5*a, 0, 0]
    y0 = [a, 0, -a, a]

    cur_list = [(x0, y0)]
    cur_list = rotate_and_traslate(cur_list, alpha, p0)

    for curi in cur_list: ax.plot(curi[0], curi[1], format, **kwds)

    if arith is not None:
        pyplot.text(p0[0]+0.75*a, p0[1], arith, horizontalalignment='center',
                    verticalalignment='center', fontsize=fontsize)
949242
private void renderMatrix(Graphics2D g2, double fontSize) {
		int numCategories = confusion.getNumRows();

		Font fontNumber = new Font("Serif", Font.BOLD, (int)(0.6*fontSize + 0.5));
		g2.setFont(fontNumber);
		FontMetrics metrics = g2.getFontMetrics(fontNumber);
		for (int i = 0; i < numCategories; i++) {
			int y0 = i*gridHeight/numCategories;
			int y1 = (i+1)*gridHeight/numCategories;

			for (int j = 0; j < numCategories; j++) {
				int x0 = j*gridWidth/numCategories;
				int x1 = (j+1)*gridWidth/numCategories;

				double value = confusion.unsafe_get(i,j);

				int red,green,blue;
				if( gray ) {
					red = green = blue = (int)(255*(1.0-value));
				} else {
					green = 0;
					red = (int)(255*value);
					blue = (int)(255*(1.0-value));
				}
				g2.setColor(new Color(red, green, blue));

				g2.fillRect(x0,y0,x1-x0,y1-y0);

				// Render numbers inside the squares.  Pick a color so that the number is visible no matter what
				// the color of the square is
				if( showNumbers && (showZeros || value != 0 )) {
					int a = (red+green+blue)/3;

					String text = ""+(int)(value*100.0+0.5);
					Rectangle2D r = metrics.getStringBounds(text,null);

					float adjX = (float)(r.getX()*2 + r.getWidth())/2.0f;
					float adjY = (float)(r.getY()*2 + r.getHeight())/2.0f;

					float x = ((x1+x0)/2f-adjX);
					float y = ((y1+y0)/2f-adjY);

					int gray = a > 127 ? 0 : 255;

					g2.setColor(new Color(gray,gray,gray));
					g2.drawString(text,x,y);
				}
			}
		}
	}
266617
def _draw_pr_curve(self, recall, precision, label=None):
        
        self.ax.step(
            recall, precision, alpha=self.line_opacity, where='post', label=label
        )
        if self.fill_area:
            self.ax.fill_between(recall, precision, step='post', alpha=self.fill_opacity)
649666
function _drawArrow(pStart, pEnd, arrowSize, color) {
        var p = new Primitive();
        p.color = toColor(color);

        p.vertices.push(pStart);
        p.vertices.push(pEnd);

        var dir = new THREE.Vector3();
        dir.subVectors(pEnd, pStart);
        dir.normalize();

        var right = new THREE.Vector3();
        var dot = dir.dot(UNIT_Y);
        if (dot > 0.99 || dot < -0.99) {
            right.crossVectors(dir, UNIT_X);
        } else {
            right.crossVectors(dir, UNIT_Y);
        }

        var top = new THREE.Vector3();
        top.crossVectors(right, dir);

        dir.multiplyScalar(arrowSize);
        right.multiplyScalar(arrowSize);
        top.multiplyScalar(arrowSize);

        // Right slant.
        var tmp = new THREE.Vector3();
        p.vertices.push(pEnd);
        p.vertices.push(tmp.addVectors(pEnd, right).sub(dir));

        // Left slant.
        tmp = new THREE.Vector3();
        p.vertices.push(pEnd);
        p.vertices.push(tmp.subVectors(pEnd, right).sub(dir));

        // Top slant.
        tmp = new THREE.Vector3();
        p.vertices.push(pEnd);
        p.vertices.push(tmp.addVectors(pEnd, top).sub(dir));

        // Bottom slant.
        tmp = new THREE.Vector3();
        p.vertices.push(pEnd);
        p.vertices.push(tmp.subVectors(pEnd, top).sub(dir));

        renderer.addPrimitive(p);
    }
661740
function drawSinglePoseResults(pose) {
  const canvas = singlePersonCanvas();
  drawResults(
      canvas, [pose], guiState.singlePoseDetection.minPartConfidence,
      guiState.singlePoseDetection.minPoseConfidence);

  const {part, showHeatmap, showOffsets} = guiState.visualizeOutputs;
  // displacements not used for single pose decoding
  const showDisplacements = false;
  const partId = +part;

  visualizeOutputs(
      partId, showHeatmap, showOffsets, showDisplacements,
      canvas.getContext('2d'));
}
972650
def pix2canvas(self, pt):
        
        x, y = pt[:2]
        #print('p2c in', x, y)
        mm = gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX)
        pm = gl.glGetDoublev(gl.GL_PROJECTION_MATRIX)
        vp = gl.glGetIntegerv(gl.GL_VIEWPORT)

        win_x, win_y = float(x), float(vp[3] - y)
        win_z = gl.glReadPixels(int(win_x), int(win_y), 1, 1,
                                gl.GL_DEPTH_COMPONENT, gl.GL_FLOAT)
        pos = glu.gluUnProject(win_x, win_y, win_z, mm, pm, vp)
        #print('out', pos)
        return pos
205957
def draw(self, **kwargs):
        
        # Set the axes aspect to be equal
        self.ax.set_aspect("equal")

        # Generate a mask for the upper triangle
        mask = np.zeros_like(self.ranks_, dtype=np.bool)
        mask[np.triu_indices_from(mask)] = True

        # Draw the heatmap
        # TODO: Move mesh to a property so the colorbar can be finalized
        data = np.ma.masked_where(mask, self.ranks_)
        mesh = self.ax.pcolormesh(data, cmap=self.colormap, vmin=-1, vmax=1)

        # Set the Axis limits
        self.ax.set(
            xlim=(0, data.shape[1]), ylim=(0, data.shape[0])
        )

        # Add the colorbar
        cb = self.ax.figure.colorbar(mesh, None, self.ax)
        cb.outline.set_linewidth(0)

        # Reverse the rows to get the lower left triangle
        self.ax.invert_yaxis()

        # Add ticks and tick labels
        self.ax.set_xticks(np.arange(len(self.ranks_)) + 0.5)
        self.ax.set_yticks(np.arange(len(self.ranks_)) + 0.5)
        if self.show_feature_names_:
            self.ax.set_xticklabels(self.features_, rotation=90)
            self.ax.set_yticklabels(self.features_)
        else:
            self.ax.set_xticklabels([])
            self.ax.set_yticklabels([])
591765
function render(gl, width, height, dt, batch, shader) {
    time+=dt
    var anim = Math.sin(time/1000)/2+0.5
        
    //clear the batch to zero
    batch.clear()

    //bind before drawing
    batch.bind(shader)

    //push our sprites which may have a variety
    //of textures
    batch.push({
        position: [anim*100, anim*50],
        shape: [128, 128],
        texture: tex2
    })

    batch.push({
        position: [100, 100],
        shape: [128, 128],
        color: [1, 1, 1, 0.5],
        texture: tex
    })
    batch.push({
        position: [300, 100],
        shape: [128, 128],
        color: [1, 1, 1, 0.5],
        texcoord: [0, 0, 2.5, 2.5],
        texture: tex
    })


    batch.push({
        texture: null,
        position: [100+100*Math.sin(time/2000), 100],
        shape: [63, 63],
        color: [anim, 0, 0, 1.0]
    })


    //we need to flush any outstanding sprites
    batch.draw()

    //and unbind it...
    batch.unbind()
}
68921
def preview(src_path):
  ''' 
  '''
  previews = []

  if sketch.is_sketchfile(src_path):
    previews = sketch.preview(src_path)

  if not previews:
    previews = quicklook.preview(src_path)

  previews = [safely_decode(preview) for preview in previews]

  return previews