input: a list of coordinates in the format:
    [
      [ (x, y, z), (x, y, z), (x, y, z) ], # atoms in model 1
      [ (x, y, z), (x, y, z), (x, y, z) ], # atoms in model 2
      # etc.
    ]
322968
def bakan_bahar_ensemble_align(coords, tolerance = 0.001, verbose = False ):
    '''
    
    '''
    rmsd_tolerance = float("inf")
    average_struct_coords = np.array( random.choice(coords) )
    cycle_count = 0
    while( rmsd_tolerance > tolerance ):
        if verbose:
            print 'Cycle %d alignment, current tolerance: %.4f (threshold %.4f)' % (cycle_count, rmsd_tolerance, tolerance)
        old_average_struct_coords = average_struct_coords
        coords = np.array([ kabsch( average_struct_coords, x ) for x in coords ])
        average_struct_coords = np.mean( coords, axis = 0 )
        rmsd_tolerance = rmsd( old_average_struct_coords, average_struct_coords )
        cycle_count += 1
    return coords
604532
def index_to_coordinates(self, index):
        
        self.validate_index(index)
        x = int(index % self.length)
        y = int((index - x) / self.length)
        return x, y
1029267
def _match_data_sets(x,y):
    
    # Handle the None for x or y
    if x is None: 
        # If x is none, y can be either [1,2] or [[1,2],[1,2]]
        if _fun.is_iterable(y[0]):
            # make an array of arrays to match
            x = []
            for n in range(len(y)):
                x.append(list(range(len(y[n]))))
        else: x = list(range(len(y)))
    
    if y is None: 
        # If x is none, y can be either [1,2] or [[1,2],[1,2]]
        if _fun.is_iterable(x[0]):
            # make an array of arrays to match
            y = []
            for n in range(len(x)):
                y.append(list(range(len(x[n]))))
        else: y = list(range(len(x)))
    
    # At this point they should be matched, but may still be 1D
    # Default behavior: if all elements are numbers in both, assume they match
    if _fun.elements_are_numbers(x) and _fun.elements_are_numbers(y):
        x = [x]
        y = [y]
           
    # Second default behavior: shared array [1,2,3], [[1,2,1],[1,2,1]] or vis versa
    if _fun.elements_are_numbers(x) and not _fun.elements_are_numbers(y): x = [x]*len(y)
    if _fun.elements_are_numbers(y) and not _fun.elements_are_numbers(x): y = [y]*len(x)

    # Clean up any remaining Nones
    for n in range(len(x)):
        if x[n] is None: x[n] = list(range(len(y[n])))
        if y[n] is None: y[n] = list(range(len(x[n])))
    
    return x, y
204892
def format_geometry_in
      output = ""
      if self.lattice_vectors
        output << self.lattice_vectors.collect{|v| "lattice_vector #{v[0]} #{v[1]} #{v[2]}"}.join("\n")
        output << "\n"
      end
      output << self.atoms.collect{|a| a.format_geometry_in}.join("\n")

      output
    end
819792
def centers_list(self):
        
        center = set()
        adj = defaultdict(set)
        for n, atom in self.atoms():
            if atom._reactant != atom._product:
                center.add(n)

        for n, m, bond in self.bonds():
            if bond._reactant != bond._product:
                adj[n].add(m)
                adj[m].add(n)
                center.add(n)
                center.add(m)

        out = []
        while center:
            n = center.pop()
            if n in adj:
                c = set(self.__plain_bfs(adj, n))
                out.append(list(c))
                center.difference_update(c)
            else:
                out.append([n])

        return out
142893
def get_coords(self):
        """"""
        out_list = []
        for i in range(len(self.x_coord_list)):
            out_list.append((self.x_coord_list[i],self.y_coord_list[i],self.z_coord_list[i],))
        return out_list
155385
def to_list(self):
        
        return [self.i, self.Ω, self.e, self.ω, self.M, self.n]
1175133
def from_rdkit_molecule(data):
    
    m = MoleculeContainer()
    atoms, mapping = [], []
    for a in data.GetAtoms():
        atom = {'element': a.GetSymbol(), 'charge': a.GetFormalCharge()}
        atoms.append(atom)
        mapping.append(a.GetAtomMapNum())

        isotope = a.GetIsotope()
        if isotope:
            atom['isotope'] = isotope
        radical = a.GetNumRadicalElectrons()
        if radical:
            atom['multiplicity'] = radical + 1

    conformers = data.GetConformers()
    if conformers:
        for atom, (x, y, z) in zip(atoms, conformers[0].GetPositions()):
            atom['x'] = x
            atom['y'] = y
            atom['z'] = z

    for atom, mapping in zip(atoms, mapping):
        a = m.add_atom(atom)
        if mapping:
            m.atom(a)._parsed_mapping = mapping

    for bond in data.GetBonds():
        m.add_bond(bond.GetBeginAtomIdx() + 1, bond.GetEndAtomIdx() + 1, _rdkit_bond_map[bond.GetBondType()])

    return m
1193676
def pose_to_list(pose):
    
    if type(pose) == geometry_msgs.msg.PoseStamped:
        return [[
            pose.pose.position.x, pose.pose.position.y, pose.pose.position.z
        ], [
            pose.pose.orientation.x, pose.pose.orientation.y,
            pose.pose.orientation.z, pose.pose.orientation.w
        ]]
    elif type(pose) == geometry_msgs.msg.Pose:
        return [[pose.position.x, pose.position.y, pose.position.z], [
            pose.orientation.x, pose.orientation.y, pose.orientation.z,
            pose.orientation.w
        ]]
    else:
        raise Exception("pose_to_list: parameter of type %s unexpected",
                        str(type(pose)))
781053
List<Coordinate> allMatches() {
        List<Coordinate> pairs = new ArrayList<>();
        int rows = rowList().size();
        int cols = columnList().size();
        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                VariantGraph.Vertex vertex = vertexAt(i, j);
                if (vertex != null) pairs.add(new Coordinate(i, j, new Match(vertex, null)));
            }
        }
        return pairs;
    }
117859
def split_coords_3d(seq):
    
    lons, lats, depths = [], [], []
    for i, el in enumerate(seq):
        if i % 3 == 0:
            lons.append(valid.longitude(el))
        elif i % 3 == 1:
            lats.append(valid.latitude(el))
        elif i % 3 == 2:
            depths.append(valid.depth(el))
    return list(zip(lons, lats, depths))
151523
def molecules2symbols(molecules, add_hydrogen=True):
    
    symbols = sorted(
        list(set(
            ase.symbols.string2symbols(''.join(
                map(
                    lambda _x:
                    ''.join(ase.symbols.string2symbols(_x)), molecules)
            ))
        )),
        key=lambda _y: ase.data.atomic_numbers[_y])

    if add_hydrogen and 'H' not in symbols:
        symbols.insert(0, 'H')

    return symbols
933048
def bbox(self):
        bbox = self._df[['id', 'x1', 'y1', 'x2', 'y2']].copy()
        # TODO: Fix this to become x, y, w, h
        if self.bbox_with_size:
            bbox['y2'] -= bbox['y1']
            bbox['x2'] -= bbox['x1']

        

        return to_array_list(bbox)
794759
private List<Coordinate> getCoordinates(List<Geometry> geometries) {
		List<Coordinate> coordinates = new ArrayList<Coordinate>();
		for (Geometry geometry : geometries) {
			Coordinate[] geometryCoordinates = geometry.getCoordinates();
			for (int i = 0; i < geometryCoordinates.length; i++) {
				coordinates.add(geometryCoordinates[i]);
			}
		}
		return coordinates;
	}
489456
def match_positions(shape, list_of_coords):
    
    match_array = np.zeros(shape)
    try:
        # excpetion hit on this line if nothing in list_of_coords- i.e. no matches
        match_array[list_of_coords[:,0],list_of_coords[:,1]] = 1
        labelled = label(match_array)
        objects = find_objects(labelled[0])
        coords = [{'x':(slice_x.start, slice_x.stop),'y':(slice_y.start, slice_y.stop)} for (slice_y,slice_x) in objects]
        final_positions = [(int(np.mean(coords[i]['x'])),int(np.mean(coords[i]['y']))) for i in range(len(coords))]
        return final_positions
    except IndexError:
        print 'no matches found'
        # this error occurs if no matches are found
        return []
843524
def __geomToPointList(self, geom):
        
        if arcpyFound and isinstance(geom, arcpy.Polyline):
            feature_geom = []
            fPart = []
            wkt = None
            wkid = None
            for part in geom:
                fPart = []
                for pnt in part:
                    if geom.spatialReference is None:
                        if self._wkid is None and self._wkt is not None:
                            wkt = self._wkt
                        else:
                            wkid = self._wkid
                    else:
                        wkid = geom.spatialReference.factoryCode
                    fPart.append(Point(coord=[pnt.X, pnt.Y],
                          wkid=wkid,
                          wkt=wkt,
                          z=pnt.Z, m=pnt.M))
                feature_geom.append(fPart)
            return feature_geom
261127
def to_list(self):
        """"""
        output = []
        for i in range(1, len(self.elements), 2):
            output.append(self.elements[i])
        return output