Refit (normalize) all of the nodes in the branch.
181805
def refitNodes(self):
        
        for n in self.branch:
            if n.prefix is not None:
                ns = n.namespace()
                if self.permit(ns):
                    n.prefix = self.prefixes[ns[1]]
            self.refitAttrs(n)
1184313
function all(config, parent) {
  var children = parent.children
  var length = children && children.length
  var index = -1
  var result = []
  var child
  var node
  var pos
  var prevEndLine
  var prevOffset
  var endLine

  while (++index < length) {
    node = children[index]
    pos = node.position
    endLine = position.start(node).line

    if (prevEndLine && endLine !== prevEndLine) {
      child = config.parser.tokenizeWhiteSpace(
        repeat(newline, endLine - prevEndLine)
      )
      patch(config, [child], prevOffset)

      if (child.value.length < 2) {
        child.value = repeat(newline, 2)
      }

      result.push(child)
    }

    child = one(config, node)

    if (child) {
      result = result.concat(child)
    }

    pos = position.end(node)
    prevEndLine = pos.line
    prevOffset = pos.offset
  }

  return result
}
1332429
function normalizeRelatedNodes(node, options) {
	'use strict';
	['any', 'all', 'none'].forEach(type => {
		if (!Array.isArray(node[type])) {
			return;
		}
		node[type]
			.filter(checkRes => Array.isArray(checkRes.relatedNodes))
			.forEach(checkRes => {
				checkRes.relatedNodes = checkRes.relatedNodes.map(relatedNode => {
					var res = {
						html: relatedNode.source
					};
					if (options.elementRef && !relatedNode.fromFrame) {
						res.element = relatedNode.element;
					}
					if (options.selectors !== false || relatedNode.fromFrame) {
						res.target = relatedNode.selector;
					}
					if (options.xpath) {
						res.xpath = relatedNode.xpath;
					}
					return res;
				});
			});
	});
}
580499
def remodelTreeRemovingRoot(root, node):
    
    import bioio
    assert root.traversalID.mid != node
    hash = {}
    def fn(bT):
        if bT.traversalID.mid == node:
            assert bT.internal == False
            return [ bT ]
        elif bT.internal:
            i = fn(bT.left)
            if i is None:
                i = fn(bT.right)
            if i is not None:
                hash[i[-1]]= bT
                i.append(bT)
            return  i
        return None
    l = fn(root)
    def fn2(i, j):
        if i.left == j:
            return i.right
        assert i.right == j
        return i.left
    def fn3(bT):
        if hash[bT] == root:
            s = '(' + bioio.printBinaryTree(fn2(hash[bT], bT), bT, True)[:-1] + ')'
        else:
            s = '(' + bioio.printBinaryTree(fn2(hash[bT], bT), bT, True)[:-1] + ',' + fn3(hash[bT]) + ')'
        return s + ":" + str(bT.distance)
    s = fn3(l[0]) + ';'
    t = bioio.newickTreeParser(s)
    return t
38109
def normalize_set(self, items, **kwargs):
        """"""
        values = set()
        for item in ensure_list(items):
            values.update(self.normalize(item, **kwargs))
        return list(values)
1071341
def refitPrefixes(self):
        
        for c in self.children:
            c.refitPrefixes()
        if self.prefix is not None:
            ns = self.resolvePrefix(self.prefix)
            if ns[1] is not None:
                self.expns = ns[1]
        self.prefix = None
        self.nsprefixes = {}
        return self
1363236
def normalize_features(features):
    """"""
    return (features - N.min(features)) / (N.max(features) - N.min(features))
743859
final public function normalize(): void
    {
        foreach ($this->props['items'] as &$item) {
            $item = array_replace($this->defaultItem, $item);
        }
        unset($item);
    }
1230161
def shrink_to_node(self, scc):
        """"""
        assert not self.final, 'Trying to mutate a final graph.'
        self.graph.add_node(scc)
        edges = list(self.graph.edges)
        for k, v in edges:
            if k not in scc and v in scc:
                self.graph.remove_edge(k, v)
                self.graph.add_edge(k, scc)
            elif k in scc and v not in scc:
                self.graph.remove_edge(k, v)
                self.graph.add_edge(scc, v)
        for node in scc.nodes:
            self.graph.remove_node(node)
282010
def replacebranch(idf, loop, branch,
                  listofcomponents, fluid=None,
                  debugsave=False,
                  testing=None):
    """"""
    if fluid is None:
        fluid = ''
    # -------- testing ---------
    testn = 0
    # -------- testing ---------

    # join them into a branch
    # -----------------------
    # np1_inlet -> np1 -> np1_np2_node -> np2 -> np2_outlet
        # change the node names in the component
        # empty the old branch
        # fill in the new components with the node names into this branch
    listofcomponents = _clean_listofcomponents(listofcomponents)

    components = [item[0] for item in listofcomponents]
    connectcomponents(idf, listofcomponents, fluid=fluid)
    if debugsave:
        idf.savecopy("hhh3.idf")
    # -------- testing ---------
    testn = doingtesting(testing, testn)
    if testn == None:
        returnnone()
    # -------- testing ---------
    fields = SomeFields.a_fields

    thebranch = branch
    componentsintobranch(idf, thebranch, listofcomponents, fluid=fluid)
    if debugsave:
        idf.savecopy("hhh4.idf")
    # -------- testing ---------
    testn = doingtesting(testing, testn)
    if testn == None:
        returnnone()
    # -------- testing ---------

    # # gather all renamed nodes
    # # do the renaming
    renamenodes(idf, 'node')
    if debugsave:
        idf.savecopy("hhh7.idf")
    # -------- testing ---------
    testn = doingtesting(testing, testn)
    if testn == None:
        returnnone()
    # -------- testing ---------

    # check for the end nodes of the loop
    if loop.key == 'AIRLOOPHVAC':
        fields = SomeFields.a_fields
    if loop.key == 'PLANTLOOP':
        fields = SomeFields.p_fields
    if loop.key == 'CONDENSERLOOP':
        fields = SomeFields.c_fields
    # for use in bunch
    flnames = [field.replace(' ', '_') for field in fields]

    if fluid.upper() == 'WATER':
        supplyconlistname = loop[flnames[3]]
        # Plant_Side_Connector_List_Name or Condenser_Side_Connector_List_Name
    elif fluid.upper() == 'AIR':
        supplyconlistname = loop[flnames[1]]  # Connector_List_Name'
    supplyconlist = idf.getobject('CONNECTORLIST', supplyconlistname)
    for i in range(1, 100000):  # large range to hit end
        try:
            fieldname = 'Connector_%s_Object_Type' % (i,)
            ctype = supplyconlist[fieldname]
        except bunch_subclass.BadEPFieldError:
            break
        if ctype.strip() == '':
            break
        fieldname = 'Connector_%s_Name' % (i,)
        cname = supplyconlist[fieldname]
        connector = idf.getobject(ctype.upper(), cname)
        if connector.key == 'CONNECTOR:SPLITTER':
            firstbranchname = connector.Inlet_Branch_Name
            cbranchname = firstbranchname
            isfirst = True
        if connector.key == 'CONNECTOR:MIXER':
            lastbranchname = connector.Outlet_Branch_Name
            cbranchname = lastbranchname
            isfirst = False
        if cbranchname == thebranch.Name:
            # rename end nodes
            comps = getbranchcomponents(idf, thebranch)
            if isfirst:
                comp = comps[0]
                inletnodename = getnodefieldname(
                    comp,
                    "Inlet_Node_Name", fluid)
                comp[inletnodename] = [
                    comp[inletnodename],
                    loop[flnames[0]]]  # Plant_Side_Inlet_Node_Name
            else:
                comp = comps[-1]
                outletnodename = getnodefieldname(
                    comp,
                    "Outlet_Node_Name", fluid)
                comp[outletnodename] = [
                    comp[outletnodename],
                    loop[flnames[1]]]  # .Plant_Side_Outlet_Node_Name
    # -------- testing ---------
    testn = doingtesting(testing, testn)
    if testn == None:
        returnnone()
    # -------- testing ---------

    if fluid.upper() == 'WATER':
        demandconlistname = loop[flnames[7]]  # .Demand_Side_Connector_List_Name
        demandconlist = idf.getobject('CONNECTORLIST', demandconlistname)
        for i in range(1, 100000):  # large range to hit end
            try:
                fieldname = 'Connector_%s_Object_Type' % (i,)
                ctype = demandconlist[fieldname]
            except bunch_subclass.BadEPFieldError:
                break
            if ctype.strip() == '':
                break
            fieldname = 'Connector_%s_Name' % (i,)
            cname = demandconlist[fieldname]
            connector = idf.getobject(ctype.upper(), cname)
            if connector.key == 'CONNECTOR:SPLITTER':
                firstbranchname = connector.Inlet_Branch_Name
                cbranchname = firstbranchname
                isfirst = True
            if connector.key == 'CONNECTOR:MIXER':
                lastbranchname = connector.Outlet_Branch_Name
                cbranchname = lastbranchname
                isfirst = False
            if cbranchname == thebranch.Name:
                # rename end nodes
                comps = getbranchcomponents(idf, thebranch)
                if isfirst:
                    comp = comps[0]
                    inletnodename = getnodefieldname(
                        comp,
                        "Inlet_Node_Name", fluid)
                    comp[inletnodename] = [
                        comp[inletnodename],
                        loop[flnames[4]]]  # .Demand_Side_Inlet_Node_Name
                if not isfirst:
                    comp = comps[-1]
                    outletnodename = getnodefieldname(
                        comp,
                        "Outlet_Node_Name", fluid)
                    comp[outletnodename] = [
                        comp[outletnodename],
                        loop[flnames[5]]]  # .Demand_Side_Outlet_Node_Name

    # -------- testing ---------
    testn = doingtesting(testing, testn)
    if testn == None:
        returnnone()
    # -------- testing ---------

    if debugsave:
        idf.savecopy("hhh8.idf")

    # # gather all renamed nodes
    # # do the renaming
    renamenodes(idf, 'node')
    # -------- testing ---------
    testn = doingtesting(testing, testn)
    if testn == None:
        returnnone()
    # -------- testing ---------
    if debugsave:
        idf.savecopy("hhh9.idf")
    return thebranch
897434
def normalize(self):
        
        order = [
            'sld:Title', 'ogc:Filter', 'sld:MinScaleDenominator',
            'sld:MaxScaleDenominator', 'sld:PolygonSymbolizer',
            'sld:LineSymbolizer', 'sld:TextSymbolizer', 'sld:PointSymbolizer']
        for item in order:
            xpath = self._node.xpath(item, namespaces=SLDNode._nsmap)
            for xitem in xpath:
                # move this to the end
                self._node.remove(xitem)
                self._node.append(xitem)
1227024
def transform_dot(self, node, results):
        """"""
        module_dot = results.get("bare_with_attr")
        member = results.get("member")
        new_name = None
        if isinstance(member, list):
            member = member[0]
        for change in MAPPING[module_dot.value]:
            if member.value in change[1]:
                new_name = change[0]
                break
        if new_name:
            module_dot.replace(Name(new_name,
                                    prefix=module_dot.prefix))
        else:
            self.cannot_convert(node, "This is an invalid module element")
800472
def mutate(self, node, index):
        """"""
        assert index == 0
        assert isinstance(node, ForStmt)

        empty_list = parso.parse(' []')
        node.children[3] = empty_list
        return node
742288
def normalize_yaml(yaml):
    
    if isinstance(yaml, list):
        # Normalize the roles YAML data
        normalized_yaml = [(x['name'], x['src'], x.get('version', 'HEAD'))
                           for x in yaml]
    else:
        # Extract the project names from the roles YAML and create a list of
        # tuples.
        projects = [x[:-9] for x in yaml.keys() if x.endswith('git_repo')]
        normalized_yaml = []
        for project in projects:
            repo_url = yaml['{0}_git_repo'.format(project)]
            commit_sha = yaml['{0}_git_install_branch'.format(project)]
            normalized_yaml.append((project, repo_url, commit_sha))

    return normalized_yaml
361160
def _normalize_branch_node(self, node):
        # sys.stderr.write('nbn\n')
        
        not_blank_items_count = sum(1 for x in range(17) if node[x])
        assert not_blank_items_count >= 1

        if not_blank_items_count > 1:
            self._encode_node(node)
            return node

        # now only one item is not blank
        not_blank_index = [i for i, item in enumerate(node) if item][0]

        # the value item is not blank
        if not_blank_index == 16:
            o = [pack_nibbles(with_terminator([])), node[16]]
            self._encode_node(o)
            return o

        # normal item is not blank
        sub_node = self._decode_to_node(node[not_blank_index])
        sub_node_type = self._get_node_type(sub_node)

        if is_key_value_type(sub_node_type):
            # collape subnode to this node, not this node will have same
            # terminator with the new sub node, and value does not change
            self._delete_node_storage(sub_node)
            new_key = [not_blank_index] + \
                unpack_to_nibbles(sub_node[0])
            o = [pack_nibbles(new_key), sub_node[1]]
            self._encode_node(o)
            return o
        if sub_node_type == NODE_TYPE_BRANCH:
            o = [pack_nibbles([not_blank_index]),
                 node[not_blank_index]]
            self._encode_node(o)
            return o
        assert False
468358
def normalize(self):
        
        maximum = self.max()
        if maximum:
            self.values = [value / maximum for value in self.values]
1242161
def normalize_node(node, headers=None):
    """"""
    headers = {} if headers is None else headers
    if isinstance(node, str):
        url = normalize_url(node)
        return {'endpoint': url, 'headers': headers}

    url = normalize_url(node['endpoint'])
    node_headers = node.get('headers', {})
    return {'endpoint': url, 'headers': {**headers, **node_headers}}