Given a structure, returns back the structure scaled to predicted
        volume.
        Args:
            structure (Structure): structure w/unknown volume

        Returns:
            a Structure object with predicted volume
8730
def get_predicted_structure(self, structure, icsd_vol=False):
        
        new_structure = structure.copy()
        new_structure.scale_lattice(self.predict(structure, icsd_vol=icsd_vol))
        return new_structure
368785
def _get_value(data_structure, key):
    
    if len(key) == 0:
        raise KeyError()
    value = data_structure[key[0]]
    if len(key) > 1:
        return _get_value(value, key[1:])
    return value
46240
def scaledBy(self, scale):
        
        scaled = deepcopy(self)
    
        if type(scaled.value) in (int, float):
            scaled.value *= scale
        elif isinstance(scaled.value, numbers):
            scaled.value.values = tuple(v * scale for v in scaled.value.values)

        return scaled
1303076
def to_volume(volume):
        
        from sevenbridges.models.volume import Volume
        if not volume:
            raise SbgError('Volume is required!')
        elif isinstance(volume, Volume):
            return volume.id
        elif isinstance(volume, six.string_types):
            return volume
        else:
            raise SbgError('Invalid volume parameter!')
706742
def read(self, structure):
        
        start = self.offset
        self.skip(structure.size)
        return structure.read(self.buf, start)
69161
def S(self):
        
        S = np.array([[self._plane_width / self._vol_width, 0, 0],
                      [0, self._plane_height / self._vol_height, 0],
                      [0, 0, self._depth_scale / self._vol_depth]])
        return S
1048866
def _preprocess(self, struct1, struct2, niggli=True):
        
        struct1 = struct1.copy()
        struct2 = struct2.copy()

        if niggli:
            struct1 = struct1.get_reduced_structure(reduction_algo="niggli")
            struct2 = struct2.get_reduced_structure(reduction_algo="niggli")

        # primitive cell transformation
        if self._primitive_cell:
            struct1 = struct1.get_primitive_structure()
            struct2 = struct2.get_primitive_structure()

        if self._supercell:
            fu, s1_supercell = self._get_supercell_size(struct1, struct2)
        else:
            fu, s1_supercell = 1, True
        mult = fu if s1_supercell else 1/fu

        # rescale lattice to same volume
        if self._scale:
            ratio = (struct2.volume / (struct1.volume * mult)) ** (1 / 6)
            nl1 = Lattice(struct1.lattice.matrix * ratio)
            struct1.lattice = nl1
            nl2 = Lattice(struct2.lattice.matrix / ratio)
            struct2.lattice = nl2

        return struct1, struct2, fu, s1_supercell
298458
def apply_to_structure(self, structure):
        
        def_struct = structure.copy()
        old_latt = def_struct.lattice.matrix
        new_latt = np.transpose(np.dot(self, np.transpose(old_latt)))
        def_struct.lattice = Lattice(new_latt)
        return def_struct
799797
def get_current_structure(self):
        

        struct = self.__class__.get_structure()
        struct.update(self.__field_types__)
        return struct
883640
def _helper_for_model(self, model_type):
        
        if model_type is models.containers.Container:
            return self.containers
        if model_type is models.images.Image:
            return self.images
        if model_type is models.networks.Network:
            return self.networks
        if model_type is models.volumes.Volume:
            return self.volumes

        raise ValueError('Unknown model type {}'.format(model_type))
1303912
def apply_transformation(self, structure):
        
        sga = SpacegroupAnalyzer(structure, symprec=self.symprec,
                                 angle_tolerance=self.angle_tolerance)
        return sga.get_conventional_standard_structure(international_monoclinic=self.international_monoclinic)
385019
def _process_structures(structures):
        
        input_structures = structures
        structures = [input_structures[0]]
        for s in input_structures[1:]:
            prev = structures[-1]
            for i in range(len(s)):
                t = np.round(prev[i].frac_coords - s[i].frac_coords)
                if np.any(np.abs(t) > 0.5):
                    s.translate_sites([i], t, to_unit_cell=False)
            structures.append(s)
        return structures
638577
def volume(self):
        
        volume = float(np.product(self.primitive.extents))
        return volume
523693
public static final void translate (Structure structure, Vector3d v) {

		for (int n=0; n<structure.nrModels();n++) {
			for (Chain c : structure.getChains(n)) {
				translate(c, v);
			}
		}
	}
1321379
def apply_transformation(self, structure):
        
        if structure.is_ordered:
            return structure

        species = [dict(sp) for sp in structure.species_and_occu]

        for sp in species:
            for k, v in sp.items():
                old_occ = sp[k]
                new_occ = float(
                    Fraction(old_occ).limit_denominator(self.max_denominator))
                if self.fix_denominator:
                    new_occ = around(old_occ*self.max_denominator)\
                        / self.max_denominator
                if round(abs(old_occ - new_occ), 6) > self.tol:
                    raise RuntimeError(
                        "Cannot discretize structure within tolerance!")
                sp[k] = new_occ

        return Structure(structure.lattice, species, structure.frac_coords)
1130575
def get_structure_from_dict(d):
    

    species = []
    frac_coords = []
    masses = []
    if 'points' in d:
        for p in d['points']:
            species.append(p['symbol'])
            frac_coords.append(p['coordinates'])
            masses.append(p['mass'])
    elif 'atoms' in d:
        for p in d['atoms']:
            species.append(p['symbol'])
            frac_coords.append(p['position'])
            masses.append(p['mass'])
    else:
        raise ValueError('The dict does not contain structural information')

    return Structure(d['lattice'], species, frac_coords,
                     site_properties={"phonopy_masses": masses})
1205826
def unpack_struct(self, struct):
        

        size = struct.size

        if not self.data:
            raise UnpackException(struct.format, size, 0)

        buff = self.data.read(size)
        if len(buff) < size:
            raise UnpackException(struct.format, size, len(buff))

        return struct.unpack(buff)