Computes coordinates of the constituent hexagons of a hexagonal heatmap.

    Parameters
    ----------
    i, j, k: enumeration of the desired hexagon

    Returns
    -------
    A numpy array of coordinates of the hexagon (unprojected)
975203
def hexagon_coordinates(i, j, k):
    

    signature = ""
    for x in [i, j, k]:
        if x == 0:
            signature += "0"
        else:
            signature += "1"
    deltas = hexagon_deltas[signature]
    center = numpy.array([i, j, k])
    return numpy.array([center + x for x in deltas])
728034
function(array) {
				array = array || [];
				var i = 0;
				var l = this.vertices.length;
				for (var j=0;j<l;j++) {
					var v = this.vertices[j];
					array[i++] = v.x;
					array[i++] = v.y;
					array[i++] = v.z;
				}
				return array;
			}
499248
@Override
    public double calcJ(int i, int j) {
        double result = 0d;
        for (int l = 1; l <= N2; l++)
            result += Math.cos(l * 2 * Math.PI * (i - j) / N) * Tl * l * l;
        return result * 2d / N;
    }

    /*
     * public Matrix calcT() { int i,j,l; Matrix T = new Matrix(N,N); double Tl
     * = (2/m)*(hdash*Math.PI/(N*dx))*(hdash*Math.PI/(N*dx)); int n = (N-1)/2;
     * for(i=0; i<N; i++) for(j=0; j<N; j++) { T.matrix[i][j] = 0d; for(l=1;
     * l<=n; l++) T.matrix[i][j] += Math.cos(l*2*Math.PI*(i-j)/N)*Tl*l*l;
     * T.matrix[i][j] *= 2d/N; } return T; }
     */

    @Override
    public double calcV(int i, int j) {
        if (i == j) return potential.getValue(minx + dx * i, 0d, 0d);
        return 0d;
    }

    /*
     * public Matrix calcV() { int i,j; Matrix V = new Matrix(N,N); for(i=0;
     * i<N; i++) for(j=0; j<N; j++) V.matrix[i][j] = 0d; for(i=0; i<N; i++)
     * V.matrix[i][i] = potential.getValue(minx+dx*i, 0d, 0d); return V; }
     */

    /*
     * public Matrix getS() { return S; } public Matrix getT() { return T; }
     * public Matrix getV() { return V; }
     */

    @Override
    public double calcI(int i, int j, int k, int l) {
        return 0d;
    }
1179117
def compute_coordinate(self, index):
        ''''''
        j = index%self.board_size
        i = (index - j) // self.board_size
        return (i, j)
670762
public static float[] restoreVertices(int[] intVertices, int[] gridIndices, Grid grid, float vertexPrecision) {
        int ve = CTM_POSITION_ELEMENT_COUNT;
        int vc = intVertices.length / ve;

        int prevGridIndex = 0x7fffffff;
        int prevDeltaX = 0;
        float[] vertices = new float[vc * ve];
        for (int i = 0; i < vc; ++i) {
            // Get grid box origin
            int gridIdx = gridIndices[i];
            float[] gridOrigin = gridIdxToPoint(grid, gridIdx);

            // Restore original point
            int deltaX = intVertices[i * ve];
            if (gridIdx == prevGridIndex) {
                deltaX += prevDeltaX;
            }
            vertices[i * ve] = vertexPrecision * deltaX + gridOrigin[0];
            vertices[i * ve + 1] = vertexPrecision * intVertices[i * ve + 1] + gridOrigin[1];
            vertices[i * ve + 2] = vertexPrecision * intVertices[i * ve + 2] + gridOrigin[2];

            prevGridIndex = gridIdx;
            prevDeltaX = deltaX;
        }
        return vertices;
    }
1065875
def coords
      x, y, z = Array.new, Array.new, Array.new
      @coordinates.each do |coord|
        x << coord.x
        y << coord.y
        z << coord.z
      end
      return x, y, z
    end
1009774
def pd_coords(self, comp):
        
        if set(comp.elements).difference(self.elements):
            raise ValueError('{} has elements not in the phase diagram {}'
                             ''.format(comp, self.elements))
        return np.array(
            [comp.get_atomic_fraction(el) for el in self.elements[1:]])
454110
def process_parsed_coords(coords):
    
    geometry = np.zeros(shape=(len(coords), 3), dtype=float)
    for ii, entry in enumerate(coords):
        for jj in range(3):
            geometry[ii, jj] = float(entry[jj])
    return geometry
1167952
def init_heatmap(x_vec, y_vec, hist_matrix, fig, colormap='Blues',
                 alpha=1, grid=False, colorbar=True,
                 vmax='auto', vmin='auto', crop=True):
    
    plt.figure(fig.number)
    ax = fig.gca()

    # set vmax and vmin
    vma = np.amax(hist_matrix) if vmax == 'auto' else vmax
    vmi = np.amin(hist_matrix) if vmin == 'auto' else vmin

    # an error check
    if vma <= vmi:
        vma = vmi + 1

    # grid the space for pcolormesh
    x_grid, y_grid = np.meshgrid(x_vec, y_vec)

    hmap = ax.pcolormesh(x_grid, y_grid, np.array(hist_matrix),
               cmap=colormap, alpha=alpha, shading='gouraud',
               vmax=vma, vmin=vmi)

    if colorbar:
        plt.colorbar(hmap)

    if not grid:
        ax.grid(False)

    if crop:
        ax.set_xlim([x_vec[0], x_vec[-1]])
        ax.set_ylim([y_vec[0], y_vec[-1]])
781387
def get_projection_on_elements(self, structure):
        
        dico = {}
        for spin in self.data.keys():
            dico[spin] = [[defaultdict(float)
                           for i in range(self.nkpoints)]
                          for j in range(self.nbands)]

        for iat in range(self.nions):
            name = structure.species[iat].symbol
            for spin, d in self.data.items():
                for k, b in itertools.product(range(self.nkpoints),
                                              range(self.nbands)):
                    dico[spin][b][k][name] = np.sum(d[k, b, iat, :])

        return dico
1147285
def get_KE_constraints(self):
        
        C2 = np.eye(self.m)
        C2 = C2[:self.m - 2, :]
        to_be_deleted = []
        for idx_vij_1 in range(self.m - 2):
            idx_vij_2 = idx_vij_1 + 1
            C2[idx_vij_1, idx_vij_2] = -1
            i1 = np.where(self.C[idx_vij_1, :] == 1)[0][0]
            i2 = np.where(self.C[idx_vij_2, :] == 1)[0][0]
            j = np.where(self.C[idx_vij_1, :] == -1)[0][0]
            if i1 == i2:
                i = i1
                k = np.where(self.C[idx_vij_2, :] == -1)[0][0]
                i_indices = self.C[:, j] == 1
                j_indices = self.C[:, k] == -1
                idx_vij_3 = np.where(np.bitwise_and(
                    i_indices, j_indices))[0][0]
                #print('v{}{}, v{}{}, v{}{}\n{}    {}    {}'.format(j,i,k,i,k,j,idx_vij_1,idx_vij_2,idx_vij_3))
                C2[idx_vij_1, idx_vij_3] = 1
            else:
                #print('v{}{}, v{}{} not considered.'.format(j,i1,j,i2))
                to_be_deleted.append(idx_vij_1)
        C2 = np.delete(C2, to_be_deleted, axis=0)
        b = np.zeros((C2.shape[0], 1))
        return C2, b
1092081
private static Point2d[] coordinatesOfCycle(int[] cycle, IAtomContainer container) {
        Point2d[] points = new Point2d[cycle.length];
        for (int i = 0; i < cycle.length; i++) {
            points[i] = container.getAtom(cycle[i]).getPoint2d();
        }
        return points;
    }
1070492
private List<HistogramScene> computeHistograms(FeatureToWordHistogram_F64 featuresToHistogram ) {

		List<String> scenes = getScenes();

		List<HistogramScene> memory;// Processed results which will be passed into the k-NN algorithm
		memory = new ArrayList<>();

		for( int sceneIndex = 0; sceneIndex < scenes.size(); sceneIndex++ ) {
			String scene = scenes.get(sceneIndex);
			System.out.println("   " + scene);
			List<String> imagePaths = train.get(scene);

			for (String path : imagePaths) {
				GrayU8 image = UtilImageIO.loadImage(path, GrayU8.class);

				// reset before processing a new image
				featuresToHistogram.reset();
				describeImage.process(image);
				for ( TupleDesc_F64 d : describeImage.getDescriptions() ) {
					featuresToHistogram.addFeature(d);
				}
				featuresToHistogram.process();

				// The histogram is already normalized so that it sums up to 1.  This provides invariance
				// against the overall number of features changing.
				double[] histogram = featuresToHistogram.getHistogram();

				// Create the data structure used by the KNN classifier
				HistogramScene imageHist = new HistogramScene(NUMBER_OF_WORDS);
				imageHist.setHistogram(histogram);
				imageHist.type = sceneIndex;

				memory.add(imageHist);
			}
		}
		return memory;
	}
525376
def _hexplot(matrix, fig, colormap):
    
    umatrix_min = matrix.min()
    umatrix_max = matrix.max()
    n_rows, n_columns = matrix.shape
    cmap = plt.get_cmap(colormap)
    offsets = np.zeros((n_columns * n_rows, 2))
    facecolors = []
    for row in range(n_rows):
        for col in range(n_columns):
            if row % 2 == 0:
                offsets[row * n_columns + col] = [col +
                                                  0.5, 2 * n_rows - 2 * row]
                facecolors.append(cmap((matrix[row, col] - umatrix_min) /
                                       (umatrix_max) * 255))
            else:
                offsets[row * n_columns + col] = [col, 2 * n_rows - 2 * row]
                facecolors.append(cmap((matrix[row, col] - umatrix_min) /
                                       (umatrix_max) * 255))
    polygon = np.zeros((6, 2), float)
    polygon[:, 0] = 1.1 * np.array([0.5, 0.5, 0.0, -0.5, -0.5, 0.0])
    polygon[:, 1] = 1.1 * np.array([-np.sqrt(3) / 6, np.sqrt(3) / 6,
                                    np.sqrt(3) / 2 + np.sqrt(3) / 6,
                                    np.sqrt(3) / 6, -np.sqrt(3) / 6,
                                    -np.sqrt(3) / 2 - np.sqrt(3) / 6])
    polygons = np.expand_dims(polygon, 0) + np.expand_dims(offsets, 1)
    ax = fig.gca()
    collection = mcoll.PolyCollection(
        polygons,
        offsets=offsets,
        facecolors=facecolors,
        edgecolors=facecolors,
        linewidths=1.0,
        offset_position="data")
    ax.add_collection(collection, autolim=False)
    corners = ((-0.5, -0.5), (n_columns + 0.5, 2 * n_rows + 0.5))
    ax.update_datalim(corners)
    ax.autoscale_view(tight=True)
    return offsets
628446
def prox_components(X, step, prox=None, axis=0):
    
    K = X.shape[axis]

    if not hasattr(prox_list, '__iter__'):
        prox = [prox] * K
    assert len(prox_list) == K

    if axis == 0:
        Pk = [prox_list[k](X[k], step) for k in range(K)]
    if axis == 1:
        Pk = [prox_list[k](X[:,k], step) for k in range(K)]
    return np.stack(Pk, axis=axis)
1269279
def get_xy_array(x_segment, y_segment):
    
    xy_array = []
    for num, x in enumerate(x_segment):
        xy_array.append((x, y_segment[num]))
    return xy_array
173261
private Coordinate p( int i, double t ) {
        double px = 0;
        double py = 0;
        for( int j = -2; j <= 1; j++ ) {
            Coordinate coordinate = pts.get(i + j);
            px += b(j, t) * coordinate.x;
            py += b(j, t) * coordinate.y;
        }
        return new Coordinate(px, py);
    }