Create TransformedStructure from SNL.

        Args:
            snl (StructureNL): Starting snl

        Returns:
            TransformedStructure
502452
def from_snl(cls, snl):
        
        hist = []
        for h in snl.history:
            d = h.description
            d['_snl'] = {'url': h.url, 'name': h.name}
            hist.append(d)
        return cls(snl.structure, history=hist)
297745
def apply_transformation(self, structure, return_ranked_list=False):
        

        if not structure.is_ordered:
            raise ValueError("This transformation is for disordered structures only.")

        partitions = self._partition_species(structure.composition,
                                             max_components=self.max_sites_to_merge)
        disorder_mappings = self._get_disorder_mappings(structure.composition, partitions)

        disordered_structures = []
        for mapping in disorder_mappings:
            disordered_structure = structure.copy()
            disordered_structure.replace_species(mapping)
            disordered_structures.append({'structure': disordered_structure,
                                          'mapping': mapping})

        if len(disordered_structures) == 0:
            return None
        elif not return_ranked_list:
            return disordered_structures[0]['structure']
        else:
            if len(disordered_structures) > return_ranked_list:
                disordered_structures = disordered_structures[0:return_ranked_list]
            return disordered_structures
158104
def makenode(clss, symbol, *nexts):
        
        result = clss(symbol)
        for i in nexts:
            if i is None:
                continue
            if not isinstance(i, clss):
                raise NotAnAstError(i)
            result.appendChild(i)

        return result
612568
def reorient_z(structure):
    
    struct = structure.copy()
    sop = get_rot(struct)
    struct.apply_operation(sop)
    return struct
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)
725416
def transform(self, crs):
        
        new_crs = CRS(crs)

        geometry = self.geometry
        if new_crs is not self.crs:
            project = functools.partial(pyproj.transform, self.crs.projection(), new_crs.projection())
            geometry = shapely.ops.transform(project, geometry)

        return Geometry(geometry, crs=new_crs)
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)
1167731
def createNewICM():
    
    data = json.loads(request.data)
    G = AnalysisGraph.from_uncharted_json_serialized_dict(data)
    G.assemble_transition_model_from_gradable_adjectives()
    G.sample_from_prior()
    G.to_sql(app=current_app)
    _metadata = ICMMetadata.query.filter_by(id=G.id).first().deserialize()
    del _metadata["model_id"]
    return jsonify(_metadata)
113836
function (json, lib) {

        // Create skeletons and joints
        util$1.each(json.skins, function (skinInfo, idx) {
            var skeleton = new Skeleton({
                name: skinInfo.name
            });
            for (var i = 0; i < skinInfo.joints.length; i++) {
                var nodeIdx = skinInfo.joints[i];
                var node = lib.nodes[nodeIdx];
                var joint = new Joint({
                    name: node.name,
                    node: node,
                    index: skeleton.joints.length
                });
                skeleton.joints.push(joint);
            }
            skeleton.relativeRootNode = lib.nodes[skinInfo.skeleton] || this.rootNode;
            if (skinInfo.inverseBindMatrices) {
                var IBMInfo = json.accessors[skinInfo.inverseBindMatrices];
                var buffer = lib.bufferViews[IBMInfo.bufferView];

                var offset = IBMInfo.byteOffset || 0;
                var size = IBMInfo.count * 16;

                var array = new vendor.Float32Array(buffer, offset, size);

                skeleton.setJointMatricesArray(array);
            }
            else {
                skeleton.updateJointMatrices();
            }
            lib.skeletons[idx] = skeleton;
        }, this);

        function enableSkinningForMesh(mesh, skeleton, jointIndices) {
            mesh.skeleton = skeleton;
            mesh.joints = jointIndices;

            if (!skeleton.boundingBox) {
                skeleton.updateJointsBoundingBoxes(mesh.geometry);
            }
        }

        function getJointIndex(joint) {
            return joint.index;
        }

        util$1.each(json.nodes, function (nodeInfo, nodeIdx) {
            if (nodeInfo.skin != null) {
                var skinIdx = nodeInfo.skin;
                var skeleton = lib.skeletons[skinIdx];

                var node = lib.nodes[nodeIdx];
                var jointIndices = skeleton.joints.map(getJointIndex);
                if (node instanceof Mesh) {
                    enableSkinningForMesh(node, skeleton, jointIndices);
                }
                else {
                    // Mesh have multiple primitives
                    var children = node.children();
                    for (var i = 0; i < children.length; i++) {
                        enableSkinningForMesh(children[i], skeleton, jointIndices);
                    }
                }
            }
        }, this);
    }
313605
def structure_changes_from(current_structure = nil)
      new_structure = column
     
      if current_structure
        # General RDBMS data loss scenarios
        if new_structure[:limit] && current_structure[:limit].to_i != new_structure[:limit].to_i ||
           new_structure[:type] != current_structure[:type] ||
           !new_structure[:default].nil? && column_default_changed?(current_structure[:default], new_structure[:default])

           column
        else
          nil # No changes
        end
      else
        column
      end
    end
1186723
def apply_filter(self, structure_filter):
        

        def test_transformed_structure(ts):
            return structure_filter.test(ts.final_structure)

        self.transformed_structures = list(filter(test_transformed_structure,
                                                  self.transformed_structures))
        for ts in self.transformed_structures:
            ts.append_filter(structure_filter)
289259
def create(cls, source, *, transform_args=None):
    
    if transform_args is None:
      transform_args = cls.transform_args

    return cls(get_obj(source, *transform_args))
427321
def transform(self, data):
        
        with timer('transform %s' % self.name, logging.DEBUG):
            transformed = super(NestedUnique, self).transform(self.unnest(data))
            return transformed.reshape((len(data), self.sequence_length))
69870
def transform_flask_bare_import(node):
    '''
    '''

    new_names = []
    for (name, as_name) in node.names:
        match = re.match(r'flask\.ext\.(.*)', name)
        from_name = match.group(1)
        actual_module_name = 'flask_{}'.format(from_name)
        new_names.append((actual_module_name, as_name))

    new_node = nodes.Import()
    copy_node_info(node, new_node)
    new_node.names = new_names
    mark_transformed(new_node)
    return new_node
1347423
def from_poscar_string(poscar_string, transformations=None):
        
        p = Poscar.from_string(poscar_string)
        if not p.true_names:
            raise ValueError("Transformation can be craeted only from POSCAR "
                             "strings with proper VASP5 element symbols.")
        raw_string = re.sub(r"'", "\"", poscar_string)
        s = p.structure
        source_info = {"source": "POSCAR",
                       "datetime": str(datetime.datetime.now()),
                       "original_file": raw_string}
        return TransformedStructure(s, transformations, history=[source_info])
958354
def transform(self, callback):
        
        self._items = self.map(callback).all()

        return self
1132277
def transform_from_chomsky_normal_form(root):
    # type: (Nonterminal) -> Nonterminal
    
    # Transforms leaves
    items = Traversing.post_order(root)
    items = filter(lambda x: isinstance(x, (ChomskyTermRule, ChomskyTerminalReplaceRule)), items)
    de = deque(items)
    while de:
        rule = de.popleft()
        if isinstance(rule, ChomskyTermRule):
            upper_nonterm = rule.from_symbols[0]  # type: Nonterminal
            term = rule.to_symbols[0]
            Manipulations.replaceNode(upper_nonterm, term)
        elif isinstance(rule, ChomskyTerminalReplaceRule):
            created_rule = rule.from_rule()  # type: Rule
            Manipulations.replaceRule(rule, created_rule)
            de.append(created_rule)

    # Transform inner nodes
    items = Traversing.post_order(root)
    items = filter(lambda x: isinstance(x, ChomskySplitRule), items)
    de = deque(items)
    while de:
        rule = de.popleft()
        if isinstance(rule, ChomskySplitRule):
            created_rule = rule.from_rule()  # type: Rule
            # parent nonterminals
            for p in rule.from_symbols:  # type: Nonterminal
                p._set_to_rule(created_rule)
                created_rule._from_symbols.append(p)
            # left child
            left_child = rule.to_symbols[0]  # type: Nonterminal
            left_child._set_from_rule(created_rule)
            created_rule._to_symbols.append(left_child)
            # right childs
            for ch in rule.to_symbols[1].to_rule.to_symbols:  # type: Nonterminal
                ch._set_from_rule(created_rule)
                created_rule.to_symbols.append(ch)
            # add back if the rules is ChomskySplitRule again
            de.appendleft(created_rule)
    return root