Find the difference between this cell and another cell
 Return a cell with Pseudo-Atoms whose positions are really the differences
970851
def delta(aCell)
      raise "Cells do not have the same number of atoms" unless self.atoms.size == aCell.atoms.size

      pseudo_atoms = []
      self.atoms.size.times {|i|
        a1 = self.atoms[i]
        a2 = aCell.atoms[i]
        raise "Species do not match" unless a1.species == a2.species
        a = Atom.new
        a.species = a1.species
        a.x = a1.x - a2.x
        a.y = a1.y - a2.y
        a.z = a1.z - a2.z
        pseudo_atoms << a
      }
      Geometry.new(pseudo_atoms)
    end
1357960
def difference(a: Iterable[Any], b: Container[Any]) -> List[Any]:
    
    d = []
    for item in a:
        if item not in b:
            d.append(item)
    return d
150346
function(or1, or2) {
			var d1 = set.difference(or1, or2.values[0]);
			var d2 = set.difference(or1, or2.values[1]);
			return set.intersection(d1, d2);
		}
822721
def merge(self, other_cell):
        
        tc, tc_2 = self._tc, other_cell._tc
        merged_tc = tc.merge(tc_2)
        return _Cell(merged_tc, self._parent)
653007
def intersection(self, other):
        

        inter = MOC()

        for (order, cells) in other:
            for cell in cells:
                for i in self._compare_operation(order, cell, True, 'inter'):
                    inter.add(*i)

        return inter
796237
def find_primitive(cell, symprec=1e-5, angle_tolerance=-1.0):
    
    _set_no_error()

    lattice, positions, numbers, _ = _expand_cell(cell)
    if lattice is None:
        return None

    num_atom_prim = spg.primitive(lattice,
                                  positions,
                                  numbers,
                                  symprec,
                                  angle_tolerance)
    _set_error_message()

    if num_atom_prim > 0:
        return (np.array(lattice.T, dtype='double', order='C'),
                np.array(positions[:num_atom_prim], dtype='double', order='C'),
                np.array(numbers[:num_atom_prim], dtype='intc'))
    else:
        return None
969439
def dot(self, other):
        """"""
        dot_product = 0
        a = self.elements
        b = other.elements
        a_len = len(a)
        b_len = len(b)
        i = j = 0

        while i < a_len and j < b_len:
            a_val = a[i]
            b_val = b[j]
            if a_val < b_val:
                i += 2
            elif a_val > b_val:
                j += 2
            else:
                dot_product += a[i + 1] * b[j + 1]
                i += 2
                j += 2

        return dot_product
1131479
def difference (b, a):
    
    a = set(a)
    result = []
    for item in b:
        if item not in a:
            result.append(item)
    return result
230690
def diffse(self, x1, x2):
        """""" 
        f1, f1se = self(x1)
        f2, f2se = self(x2)
        if self.paired:
            fx1 = np.array(self.cache[tuple(x1)])
            fx2 = np.array(self.cache[tuple(x2)])
            diffse = np.std(fx1-fx2, ddof=1)/self.N**.5 
            return diffse
        else:
            return (f1se**2 + f2se**2)**.5
361455
def get_cell_type(cell):
    '''
    
    '''
    cell_type = None
    if isinstance(cell, basestring) and cell:
        cell_type = basestring
    elif isinstance(cell, (int, float)):
        cell_type = (int, float)

    return cell_type
469458
def dr( self, cell_lengths ):
        
        half_cell_lengths = cell_lengths / 2.0
        this_dr = self.final_site.r - self.initial_site.r
        for i in range( 3 ):
            if this_dr[ i ] > half_cell_lengths[ i ]:
                this_dr[ i ] -= cell_lengths[ i ]
            if this_dr[ i ] < -half_cell_lengths[ i ]:
                this_dr[ i ] += cell_lengths[ i ]
        return this_dr
51727
private static Atom[] getAtoms(Atom[] ca, int[] positions, int length,
			boolean clone) {

		List<Atom> atoms = new ArrayList<Atom>();
		for (int i = 0; i < length; i++) {
			int p = positions[i];
			Atom a;
			if (clone) {
				a = (Atom) ca[p].clone();
				a.setGroup((Group) ca[p].getGroup().clone());
			} else {
				a = ca[p];
			}
			atoms.add(a);
		}
		return atoms.toArray(new Atom[atoms.size()]);
	}
898055
function calcToRemove(a, b)
{
	var subLengths = 0;
	for (var i = 0; i < a.table.length; i++)
	{
		subLengths += a.table[i].table.length;
	}
	for (var i = 0; i < b.table.length; i++)
	{
		subLengths += b.table[i].table.length;
	}

	var toRemove = a.table.length + b.table.length;
	return toRemove - (Math.floor((subLengths - 1) / M) + 1);
}
255589
function(or, and) {
			var aDiff = set.difference(or, and.values[0]);
			var bDiff = set.difference(or, and.values[1]);
			return set.union(aDiff, bDiff);
		}
824009
function(){
		var pos = this.getpos(0);
		if(this.prevPos.equals(pos)){ return;}

		var cell = this.prevPos.getc();
		if(!cell.isnull){
			if(cell.qnum!==-1){
				var dir = this.prevPos.getdir(pos,2);
				if(dir!==cell.NDIR){
					cell.setQdir(cell.qdir!==dir?dir:0);
					cell.draw();
				}
			}
		}
		this.prevPos = pos;
	}
899487
function(a, b)
{
    return (a.bb_l <= b.bb_r && b.bb_l <= a.bb_r && a.bb_b <= b.bb_t && b.bb_b <= a.bb_t);
}
495819
def get_D_square_min(atoms_now, atoms_old, i_now, j_now, delta_plus_epsilon=None):
    
    nat = len(atoms_now)
    assert len(atoms_now) == len(atoms_old)

    pos_now = atoms_now.positions
    pos_old = atoms_old.positions

    # Compute current and old distance vectors. Note that current distance
    # vectors cannot be taken from the neighbor calculation, because neighbors
    # are calculated from the sheared cell while these distance need to come
    # from the unsheared cell. Taking the distance from the unsheared cell
    # make periodic boundary conditions (and flipping of cell) a lot easier.
    dr_now = mic(pos_now[i_now] - pos_now[j_now], atoms_now.cell)
    dr_old = mic(pos_old[i_now] - pos_old[j_now], atoms_old.cell)

    # Sanity check: Shape needs to be identical!
    assert dr_now.shape == dr_old.shape

    if delta_plus_epsilon is None:
        # Get minimum strain tensor
        delta_plus_epsilon = get_delta_plus_epsilon(nat, i_now, dr_now, dr_old)

    # Spread epsilon out for each neighbor index
    delta_plus_epsilon_n = delta_plus_epsilon[i_now]

    # Compute D^2_min
    d_sq_n = np.sum(
        (
        dr_now-
        np.sum(delta_plus_epsilon_n.reshape(-1,3,3)*dr_old.reshape(-1,1,3),
               axis=2)
        )**2,
        axis=1)

    # For each atom, sum over all neighbors
    d_sq = np.bincount(i_now, weights=d_sq_n)

    return delta_plus_epsilon, d_sq