Return grid point index by tranlating grid address
969989
def get_grid_point_from_address(grid_address, mesh):
    """"""
    _set_no_error()

    return spg.grid_point_from_address(np.array(grid_address, dtype='intc'),
                                       np.array(mesh, dtype='intc'))
1324338
def grid_coords_from_corners(upper_left_corner, lower_right_corner, size):
    '''  '''
    assert upper_left_corner.wkt == lower_right_corner.wkt
    geotransform = np.array([upper_left_corner.lon, -(upper_left_corner.lon - lower_right_corner.lon) / float(size[1]), 0,
                            upper_left_corner.lat, 0, -(upper_left_corner.lat - lower_right_corner.lat) / float(size[0])])
    return GridCoordinates(geotransform=geotransform,
                               wkt=upper_left_corner.wkt,
                               y_size=size[0],
                               x_size=size[1])
1135614
def index_to_coords(index, shape):
    ''''''
    coords = []
    for i in xrange(1, len(shape)):
        divisor = int(np.product(shape[i:]))
        value = index // divisor
        coords.append(value)
        index -= value * divisor
    coords.append(index)
    return tuple(coords)
509619
function getColumnBlocks(tableGrid) {
        var cols = range(0, tableGrid.grid.maxCols);
        var rows = range(0, tableGrid.grid.maxRows);

        return Tools.map(cols, function (col) {
          function getBlock() {
            var details = [];
            for (var i = 0; i < rows.length; i++) {
              var detail = tableGrid.getAt(i, col);
              if (detail && detail.colIndex === col) {
                details.push(detail);
              }
            }

            return details;
          }

          function isSingle(detail) {
            return detail.colspan === 1;
          }

          function getFallback() {
            var item;

            for (var i = 0; i < rows.length; i++) {
              item = tableGrid.getAt(i, col);
              if (item) {
                return item;
              }
            }

            return null;
          }

          return decide(getBlock, isSingle, getFallback);
        });
      }
1328951
def dist_grid(grid, source, target=None):
    
    rows = len(grid)
    cols = len(grid[0])
    dirs = [(0, +1, '>'), (0, -1, '<'), (+1, 0, 'v'), (-1, 0, '^')]
    i, j = source
    grid[i][j] = 's'
    Q = deque()
    Q.append(source)
    while Q:
        i1, j1 = Q.popleft()
        for di, dj, symbol in dirs:   # explore all directions
            i2 = i1 + di
            j2 = j1 + dj
            if not (0 <= i2 and i2 < rows and 0 <= j2 and j2 < cols):
                continue              # reached the bounds of the grid
            if grid[i2][j2] != ' ':   # inaccessible or already visited
                continue
            grid[i2][j2] = symbol     # mark visit
            if (i2, j2) == target:
                grid[i2][j2] = 't'    # goal is reached
                return
            Q.append((i2, j2))
421691
def _get_lat_lon_indices(lsm_lat_array, lsm_lon_array, lat, lon):
    
    if lsm_lat_array.ndim == 2 and lsm_lon_array.ndim == 2:
        lsm_lat_indices_from_lat, lsm_lon_indices_from_lat = \
            np.where((lsm_lat_array == lat))
        lsm_lat_indices_from_lon, lsm_lon_indices_from_lon = \
            np.where((lsm_lon_array == lon))

        index_lsm_grid_lat = np.intersect1d(lsm_lat_indices_from_lat,
                                            lsm_lat_indices_from_lon)[0]
        index_lsm_grid_lon = np.intersect1d(lsm_lon_indices_from_lat,
                                            lsm_lon_indices_from_lon)[0]

    elif lsm_lat_array.ndim == 1 and lsm_lon_array.ndim == 1:
        index_lsm_grid_lon = np.where(lsm_lon_array == lon)[0][0]
        index_lsm_grid_lat = np.where(lsm_lat_array == lat)[0][0]
    else:
        raise IndexError("Lat/Lon lists have invalid dimensions. "
                         "Only 1D or 2D arrays allowed ...")

    return index_lsm_grid_lat, index_lsm_grid_lon
42639
public static float[] gridIdxToPoint(Grid grid, int idx) {
        int[] gridIdx = new int[3];

        int ydiv = grid.getDivision().getX();
        int zdiv = ydiv * grid.getDivision().getY();

        gridIdx[2] = idx / zdiv;
        idx -= gridIdx[2] * zdiv;
        gridIdx[1] = idx / ydiv;
        idx -= gridIdx[1] * ydiv;
        gridIdx[0] = idx;

        Vec3f size = grid.getSize();
        float[] point = {
                gridIdx[0] * size.getX() + grid.getMin().getX(),
                gridIdx[1] * size.getY() + grid.getMin().getY(),
                gridIdx[2] * size.getZ() + grid.getMin().getZ()
        };
        return point;
    }
887068
def _parse_grid(self, grid):
        """"""
        chars = [c for c in grid if c in DIGITS or c in "0."]
        if len(chars) != 9**2:
            raise ValueError("expected 9x9 grid")
        return [self.litmap[self.X[i // 9 + 1, i % 9 + 1, int(c)]]
                for i, c in enumerate(chars) if c in DIGITS]
626815
@Override
	public Point2D getXY(int index) {
		Point2D pt = new Point2D();
		getXY(index, pt);
		return pt;
	}
534987
public static long getIndex(final long pMapTileIndex) {
        return getIndex(MapTileIndex.getX(pMapTileIndex), MapTileIndex.getY(pMapTileIndex), MapTileIndex.getZoom(pMapTileIndex));
    }
330378
function getRowBlocks(tableGrid) {
        var cols = range(0, tableGrid.grid.maxCols);
        var rows = range(0, tableGrid.grid.maxRows);

        return Tools.map(rows, function (row) {
          function getBlock() {
            var details = [];
            for (var i = 0; i < cols.length; i++) {
              var detail = tableGrid.getAt(row, i);
              if (detail && detail.rowIndex === row) {
                details.push(detail);
              }
            }
            return details;
          }

          function isSingle(detail) {
            return detail.rowspan === 1;
          }

          function getFallback() {
            return tableGrid.getAt(row, 0);
          }

          return decide(getBlock, isSingle, getFallback);
        });
      }
1108291
void getXY(int cluster, Point2D pt) {
		int vindex = getClusterVertexIndex_(cluster);
		m_shape.getXYWithIndex(vindex, pt);
	}
917552
def tc_at_grid_col(self, idx):
        
        grid_col = 0
        for tc in self.tc_lst:
            if grid_col == idx:
                return tc
            grid_col += tc.grid_span
            if grid_col > idx:
                raise ValueError('no cell on grid column %d' % idx)
        raise ValueError('index out of bounds')
1361160
def _get_cf_grid_mapping_var(self):
        """"""
        gmaps = ['fixedgrid_projection', 'goes_imager_projection',
                 'lambert_projection', 'polar_projection',
                 'mercator_projection']
        if 'grid_mapping' in self.filename_info:
            gmaps = [self.filename_info.get('grid_mapping')] + gmaps
        for grid_mapping in gmaps:
            if grid_mapping in self.nc:
                return self.nc[grid_mapping]
        raise KeyError("Can't find grid mapping variable in SCMI file")
588225
function getSingleMarkerEndPoint(data, idx, dims, seriesModel, api) {
    var coordSys = seriesModel.coordinateSystem;
    var itemModel = data.getItemModel(idx);

    var point;
    var xPx = numberUtil.parsePercent(itemModel.get(dims[0]), api.getWidth());
    var yPx = numberUtil.parsePercent(itemModel.get(dims[1]), api.getHeight());
    if (!isNaN(xPx) && !isNaN(yPx)) {
        point = [xPx, yPx];
    }
    else {
        // Chart like bar may have there own marker positioning logic
        if (seriesModel.getMarkerPosition) {
            // Use the getMarkerPoisition
            point = seriesModel.getMarkerPosition(
                data.getValues(dims, idx)
            );
        }
        else {
            var x = data.get(dims[0], idx);
            var y = data.get(dims[1], idx);
            var pt = [x, y];
            coordSys.clampData && coordSys.clampData(pt, pt);
            point = coordSys.dataToPoint(pt, true);
        }
        if (coordSys.type === 'cartesian2d') {
            var xAxis = coordSys.getAxis('x');
            var yAxis = coordSys.getAxis('y');
            var x = data.get(dims[0], idx);
            var y = data.get(dims[1], idx);
            if (isInifinity(x)) {
                point[0] = xAxis.toGlobalCoord(xAxis.getExtent()[dims[0] === 'x0' ? 0 : 1]);
            }
            else if (isInifinity(y)) {
                point[1] = yAxis.toGlobalCoord(yAxis.getExtent()[dims[1] === 'y0' ? 0 : 1]);
            }
        }

        // Use x, y if has any
        if (!isNaN(xPx)) {
            point[0] = xPx;
        }
        if (!isNaN(yPx)) {
            point[1] = yPx;
        }
    }

    return point;
}
1080215
def point_from_cols_vals(cols, vals):
        
        point = {}
        for col_index, col_name in enumerate(cols):
            point[col_name] = vals[col_index]

        return point
1110039
def get_axis_grid(self, ind):
        
        ng = self.dim
        num_pts = ng[ind]
        lengths = self.structure.lattice.abc
        return [i / num_pts * lengths[ind] for i in range(num_pts)]