Given a relay cell at the given coordinate, return a list of the (x,y)
    coordinates of all TRN cells that project to it. This assumes a 3X3 fan-in.

    :param i, j: relay cell Coordinates

    :return:
546460
def _preSynapticTRNCells(self, i, j):
    
    xmin = max(i - 1, 0)
    xmax = min(i + 2, self.trnWidth)
    ymin = max(j - 1, 0)
    ymax = min(j + 2, self.trnHeight)
    trnCells = [
      (x, y) for x in range(xmin, xmax) for y in range(ymin, ymax)
    ]

    return trnCells
331056
def get_x(self, var, coords=None):
        
        if coords is None:
            coords = self.ds.coords
        # first we try the super class
        ret = super(UGridDecoder, self).get_x(var, coords)
        # but if that doesn't work because we get the variable name in the
        # dimension of `var`, we use the means of the triangles
        if ret is None or ret.name in var.dims:
            bounds = self.get_cell_node_coord(var, axis='x', coords=coords)
            if bounds is not None:
                centers = bounds.mean(axis=-1)
                x = self.get_nodes(self.get_mesh(var, coords), coords)[0]
                try:
                    cls = xr.IndexVariable
                except AttributeError:  # xarray < 0.9
                    cls = xr.Coordinate
                return cls(x.name, centers, attrs=x.attrs.copy())
163485
@Override
    public IAtomContainer get(int i) {
        Point3d[] tmp = coordinates.get(i);
        for (int j = 0; j < atomContainer.getAtomCount(); j++) {
            IAtom atom = atomContainer.getAtom(j);
            atom.setPoint3d(tmp[j]);
        }
        return atomContainer;
    }
527382
public void transfToOriginCell(Tuple3d pt) {
		transfToCrystal(pt);

		// convert all coordinates to [0,1) interval
		pt.x = pt.x<0 ? (pt.x%1.0 + 1.0)%1.0 : pt.x%1.0;
		pt.y = pt.y<0 ? (pt.y%1.0 + 1.0)%1.0 : pt.y%1.0;
		pt.z = pt.z<0 ? (pt.z%1.0 + 1.0)%1.0 : pt.z%1.0;

		transfToOrthonormal(pt);
	}
73766
def iterline(x1, y1, x2, y2):
    ''
    xdiff = abs(x2-x1)
    ydiff = abs(y2-y1)
    xdir = 1 if x1 <= x2 else -1
    ydir = 1 if y1 <= y2 else -1

    r = math.ceil(max(xdiff, ydiff))
    if r == 0:  # point, not line
        yield x1, y1
    else:
        x, y = math.floor(x1), math.floor(y1)
        i = 0
        while i < r:
            x += xdir * xdiff / r
            y += ydir * ydiff / r

            yield x, y
            i += 1
1018487
def _iter_coords(nsls):
    """"""
    # First convert all slices to ranges
    ranges = list()
    for nsl in nsls:
        if isinstance(nsl, int):
            ranges.append(range(nsl, nsl+1))
        else:
            ranges.append(range(nsl.start, nsl.stop))
    # Iterate through all matching coordinates
    yield from itertools.product(*ranges)
878109
private Coordinate[] getOrderedNodes( Coordinate c, Coordinate coordinate1, Coordinate coordinate2, Coordinate coordinate3 ) {
        double d = distance3d(c, coordinate1, null);
        Coordinate nearest = coordinate1;
        Coordinate c2 = coordinate2;
        Coordinate c3 = coordinate3;

        double d2 = distance3d(c, coordinate2, null);
        if (d2 < d) {
            nearest = coordinate2;
            d = d2;
            c2 = coordinate1;
            c3 = coordinate3;
        }
        double d3 = distance3d(c, coordinate3, null);
        if (d3 < d) {
            nearest = coordinate3;
            c2 = coordinate1;
            c3 = coordinate2;
        }
        return new Coordinate[]{nearest, c2, c3};
    }
3702
def getInterfaceAddresses(self, node, interface):
        '''
        
        '''
        intf = self.getNode(node)['nodeobj'].getInterface(interface)
        return intf.ethaddr,intf.ipaddr,intf.netmask
1195264
def get_segment(neuron, section_id, segment_id):
    '''
    '''
    sec = neuron.sections[section_id]
    return sec.points[segment_id:segment_id + 2][:, COLS.XYZR]
283350
def cell_centroids(self):
        
        if self._cell_centroids is None:
            self._cell_centroids = (
                numpy.sum(self.node_coords[self.cells["nodes"]], axis=1) / 3.0
            )
        return self._cell_centroids
1007455
def get_cell_node_coord(self, var, coords=None, axis='x', nans=None):
        
        if coords is None:
            coords = self.ds.coords

        idims = self.get_coord_idims(coords)

        def get_coord(coord):
            coord = coords.get(coord, self.ds.coords.get(coord))
            return coord.isel(**{d: sl for d, sl in idims.items()
                                 if d in coord.dims})

        mesh = self.get_mesh(var, coords)
        if mesh is None:
            return
        nodes = self.get_nodes(mesh, coords)
        if not len(nodes):
            raise ValueError("Could not find the nodes variables for the %s "
                             "coordinate!" % axis)
        vert = nodes[0 if axis == 'x' else 1]
        if vert is None:
            raise ValueError("Could not find the nodes variables for the %s "
                             "coordinate!" % axis)
        loc = var.attrs.get('location', 'face')
        if loc == 'node':
            # we assume a triangular grid and use matplotlibs triangulation
            from matplotlib.tri import Triangulation
            xvert, yvert = nodes
            triangles = Triangulation(xvert, yvert)
            if axis == 'x':
                bounds = triangles.x[triangles.triangles]
            else:
                bounds = triangles.y[triangles.triangles]
        elif loc in ['edge', 'face']:
            connectivity = get_coord(
                mesh.attrs.get('%s_node_connectivity' % loc, ''))
            if connectivity is None:
                raise ValueError(
                    "Could not find the connectivity information!")
            connectivity = connectivity.values
            bounds = vert.values[
                np.where(np.isnan(connectivity), connectivity[:, :1],
                         connectivity).astype(int)]
        else:
            raise ValueError(
                "Could not interprete location attribute (%s) of mesh "
                "variable %s!" % (loc, mesh.name))
        dim0 = '__face' if loc == 'node' else var.dims[-1]
        return xr.DataArray(
            bounds,
            coords={key: val for key, val in coords.items()
                    if (dim0, ) == val.dims},
            dims=(dim0, '__bnds', ),
            name=vert.name + '_bnds',  attrs=vert.attrs.copy())
1272809
private Vector2i getCellOf(Point3D coordinate) {
        int xCell = (int) ((coordinate.x - indexRegion.minX()) / x_size);
        int yCell = (int) ((coordinate.y - indexRegion.minY()) / y_size);
        return new Vector2i(xCell, yCell);
    }
49129
def get_junctions_string(self):
    
    self._initialize()
    return ';'.join([x.get_range_string() for x in self.junctions])
581745
public void getEachCellContent(int YNum, int cc, TableCandidate tc) {
    	int footnoteLineIndex = tc.getFootnoteBeginRow();
    	String[] contentsInRows = new String[footnoteLineIndex];
    	float[] leftX_tableColumns = tc.getLeftX_tableColumns();
    	float[] rightX_tableColumns = tc.getRightX_tableColumns();
    	String[][] cells = new String[YNum][cc];
		boolean[][] crossCells = new boolean[YNum][cc];
		for (int tt=0; tt<tc.getRows().size(); tt++) {
			for (int qq=0; qq<cc; qq++) {
				cells[tt][qq] = "";
				crossCells[tt][qq]=false; 
			}
		}
    	for (int tt=0; tt<footnoteLineIndex; tt++) {
			String cellsThisLine = "";
			TableRow row = tc.getRows().get(tt);
			int cellThisLine = row.getCells().size(); //  pmoj.objectNum_eachY[tt];
			for (int zz=0; zz<cellThisLine; zz++) {
				for (int qq=0; qq<cc; qq++) {
					if ( (row.getCells().get(zz).getX()>=leftX_tableColumns[qq]) 
					&& (row.getCells().get(zz).getEndX()<=rightX_tableColumns[qq]) ) 
							cells[tt][qq] =cells[tt][qq] + row.getCells().get(zz).getText() + " ";
					if ((row.getCells().get(zz).getX()<leftX_tableColumns[qq]) 
					&&(leftX_tableColumns[qq]<=row.getCells().get(zz).getEndX()) )
							cells[tt][qq] = cells[tt][qq] +  row.getCells().get(zz).getText() + " ";
					if ((leftX_tableColumns[qq]>=row.getCells().get(zz).getX()) 
					&& (row.getCells().get(zz).getX()>=rightX_tableColumns[qq]) 
					&&(rightX_tableColumns[qq]<row.getCells().get(zz).getEndX()) )
						cells[tt][qq] = cells[tt][qq] +  row.getCells().get(zz).getText() + " ";
				}
			}
			for (int zz=0; zz<cellThisLine; zz++) {
				int crossCellBegin = 1000;
				int crossCellEnd=0;
				for (int qq=0; qq<cc; qq++) {
					if ( (qq>0) && (cells[tt][qq-1].length()==0) 
					&& (row.getCells().get(zz).getX()<=rightX_tableColumns[qq-1]) 
					&& (row.getCells().get(zz).getX()<leftX_tableColumns[qq]) 
					&& (leftX_tableColumns[qq]<=row.getCells().get(zz).getEndX()) ) {
						crossCells[tt][qq]=true;
						crossCells[tt][qq-1]=true;
						cells[tt][qq-1] = row.getCells().get(zz).getText();
						crossCellBegin=qq-1;
					}
					if ((qq<(cc-1)) && (cells[tt][qq+1].length()==0) 
					&& (row.getCells().get(zz).getEndX()>=leftX_tableColumns[qq+1]) 
					&& (row.getCells().get(zz).getX()<=rightX_tableColumns[qq]) 
					&& (rightX_tableColumns[qq]<row.getCells().get(zz).getEndX()) ) {
						crossCells[tt][qq]=true;
						crossCells[tt][qq+1]=true;
						cells[tt][qq+1] = row.getCells().get(zz).getText();
						crossCellEnd=qq+1;
					}
				}
			}
			for (int qq=0; qq<cc; qq++) {
				cellsThisLine = cellsThisLine + cells[tt][qq] + "; ";
			}
			contentsInRows[tt]=cellsThisLine;
		}
    	tc.setCells(cells);
    	tc.setCrossCells(crossCells);
    }
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
1068131
def compute(self, egocentricLocation):
    
    offsetInCellFields = (np.matmul(self.rotationMatrix, egocentricLocation) *
                          self.cellFieldsPerUnitDistance)

    np.mod(offsetInCellFields, self.cellDimensions, out=offsetInCellFields)
    self.activeCells = np.unique(
      np.ravel_multi_index(np.floor(offsetInCellFields).T.astype('int'),
                           self.cellDimensions))
15120
def get_T_yX(fname, y, y_in_Y, x_in_X, F_y):
    '''
     
    
    '''
    def _get_k_yX_mul_F_y(y, y_index, X_index):
        # Load data from json dictionary
        f = open(fname, 'r')
        data = json.load(f)
        f.close()
    
        #init variables
        k_yX = 0.
        
        for l in [str(key) for key in data['data'][y]['syn_dict'].keys()]:
            for x in x_in_X[X_index]:
                p_yxL = data['data'][y]['syn_dict'][l][x] / 100.
                k_yL = data['data'][y]['syn_dict'][l]['number of synapses per neuron']
                k_yX +=  p_yxL * k_yL
        
        return k_yX * F_y[y_index]


    #container
    T_yX = np.zeros((len(y), len(x_in_X)))
    
    #iterate over postsynaptic cell types
    for i, y_value in enumerate(y):
        #iterate over presynapse population inds
        for j in range(len(x_in_X)):
            k_yX_mul_F_y = 0
            for k, yy in enumerate(sum(y_in_Y, [])):                
                if y_value in yy:
                    for yy_value in yy:
                        ii = np.where(np.array(y) == yy_value)[0][0]
                        k_yX_mul_F_y += _get_k_yX_mul_F_y(yy_value, ii, j)
            
            
            if k_yX_mul_F_y != 0:
                T_yX[i, j] = _get_k_yX_mul_F_y(y_value, i, j) / k_yX_mul_F_y
            
    return T_yX