get plantloop fields to diagram it
162496
def plantloopfields(data, commdct):
    """"""
    fieldlists = plantloopfieldlists(data)
    objkey = 'plantloop'.upper()
    return extractfields(data, commdct, objkey, fieldlists)
954505
def get_leaves(self):
        
        return self.fold_up(lambda n, fl, fg: fl + fg, lambda leaf: [leaf])
324409
public function getCMSFields()
    {
        // Obtain Field Objects (from parent):
        
        $fields = parent::getCMSFields();
        
        // Create Field Objects:
        
        $fields->fieldByName('Root.Options.TitleOptions')->push(
            CheckboxField::create(
                'UseLevelTitle',
                $this->fieldLabel('UseLevelTitle')
            )
        );
        
        // Answer Field Objects:
        
        return $fields;
    }
288488
function getFormFieldInfo(field) {

      var formFieldArr = [
        this.consts.avgSep,
        'Form Field Info: ',
      ];

      var name = field.getName() || '';

      if (!Boolean(autoGenRE.test(name))) {
        formFieldArr.push('getName(): ' + this.boldIf(name, name, 'darkgreen'));
      }

      tia.cU.dumpObj(field, [
        'getValue()',
        'getRawValue()',
        'getSubmitValue()',
        'getModelData()',
        'getSubmitData()',
        'getInputId()',
        'initialConfig.inputType',
        'initialConfig.boxLabel',
        'boxLabel',
        'inputType',
        'getFieldLabel()',
        'getActiveError()',
        'getErrors()',
      ], formFieldArr);

      var store;

      if (field.isPickerField) {
        var pickerComp = field.getPicker();
        formFieldArr = formFieldArr.concat([
          this.consts.tinySep,
          'Picker field info:']);

        tia.cU.dumpObj(pickerComp, ['$className'], formFieldArr);

        tia.cU.dumpObj(field, [
          'getConfig().displayField',
          'initialConfig.hiddenName',
        ], formFieldArr);

        formFieldArr.push(this.consts.tinySep);

        if (field.getStore) {
          store = field.getStore();
          formFieldArr = formFieldArr.concat(this.getStoreContent(store));
        }
      } else if (field.displayField) {
        formFieldArr = formFieldArr.concat([
          this.consts.tinySep,
          'Form field containing "displayField" info:']);

        tia.cU.dumpObj(field, ['$className'], formFieldArr);

        tia.cU.dumpObj(field, [
          'getConfig().displayField',
          'initialConfig.hiddenName',
        ], formFieldArr);

        formFieldArr.push(this.consts.tinySep);

        if (field.getStore) {
          store = field.getStore();
          formFieldArr = formFieldArr.concat(this.getStoreContent(store));
        }
      }

      formFieldArr.push(this.consts.avgSep);
      return formFieldArr;
    }
137451
def draw_columns
            @sections[:body][:fields].each do |field, settings|
                settings = [settings[0], @posY, (@defaults.merge (settings[1] || { }).symbolize_keys!)]
                settings[2][:style] = settings[2][:style].to_sym
                set_options settings[2]
                draw_line(@posY + @sections[:body][:settings][:height]/2)
                field = settings[2][:column] || field.to_s.split('_').inject('') do |str, part|
                    str << part.camelize << " "
                end
                draw_text field, settings
            end
            draw_line(@posY - @sections[:body][:settings][:height]/2)
            set_pos_y @sections[:body][:settings][:height]
        end
128115
private static void getLeafNodes(
        TreeModel treeModel, Object node, Collection<Object> leafNodes)
    {
        if (node == null)
        {
            return;
        }
        int childCount = treeModel.getChildCount(node);
        if (childCount == 0)
        {
            leafNodes.add(node);
        }
        else
        {
            for (int i = 0; i < childCount; i++)
            {
                Object child = treeModel.getChild(node, i);
                getLeafNodes(treeModel, child, leafNodes);
            }
        }
    }
611111
function generateDiagram(title, diagram, filename) {
        // Generate content for sequences
		if (diagram._chartType == 'sequence') {
			var msg = diagram._messages;
			var convertedString = "";
			if (msg !== undefined) {	
				var size = Object.keys(msg).length;
				for (var i = 0; i < size; i++) {
					var m = msg[i+""];
					var s = "";
					if (m._type != "note") {
						var type = "->" ;
						if (m._type == "callback") 
							type = "-->"						
						s = m._origin + type + m._destination + ": " + m._message + "\\n";
					} else {
					    var location = m._location;
						if (m._location == "right" || m._location == "left") 	
							location = m._location + " of";
						s = "Note "+ location +" "+m._origin+ ": " + m._message + "\\n";
					}
					convertedString += s;
				};
			};
			var diagramData = {
				title: title,
				header: diagram._chartTitle,
				description: diagram._chartDesc,
				content: convertedString
			};      
			var diagramPath = path.join(outdir, filename), html = view.render('sequence-diagram.tmpl', diagramData);   			
			fs.writeFileSync(diagramPath, html, 'utf8');
		} else if (diagram._chartType == 'class') {
			
			var classes = {};
			for (var elem in diagram._entities) {
				var x = Math.floor((Math.random() * 400) + 1);
				var y = Math.floor((Math.random() * 300) + 1);
				classes[diagram._entities[elem].name] = {
				    type: diagram._entities[elem].type ,
					position: { x: x , y: y } ,
					size: { width: 240, height: 100 } ,
					name: diagram._entities[elem].name
				};
			}
			var relations = {};		
			for (var elem in diagram._relations) {
				var size = Object.keys(relations).length; 
				relations[size] = {
				    type: diagram._relations[elem].type ,
					source: diagram._relations[elem].source ,					
					target: diagram._relations[elem].target
				};
			}
			
			var diagramData = {
				title: title,
				header: diagram._chartTitle,
				description: diagram._chartDesc,
				content: JSON.stringify(diagram),
				relations: JSON.stringify(relations),
				entities: JSON.stringify(classes)
			};      
			var diagramPath = path.join(outdir, filename), html = view.render('class-diagram.tmpl', diagramData);   			
			fs.writeFileSync(diagramPath, html, 'utf8');
		}
    }
531993
private Multimap<String, I_CmsFormField> getFieldsByGroup(Collection<I_CmsFormField> fields) {

        Multimap<String, I_CmsFormField> result = ArrayListMultimap.create();
        for (I_CmsFormField field : fields) {
            String group = field.getLayoutData().get(LD_GROUP);
            result.put(group, field);
        }
        return result;
    }
711669
private Set<String> preprocessFields(Collection<I_CmsFormField> fields) {

        Set<String> displaySet = Sets.newHashSet();
        for (I_CmsFormField field : fields) {
            boolean hasValue = !CmsStringUtil.isEmpty(field.getWidget().getApparentValue());
            if (hasValue || Boolean.TRUE.toString().equals(field.getLayoutData().get(LD_DISPLAY_VALUE))) {
                String propName = field.getLayoutData().get(LD_PROPERTY);
                displaySet.add(propName);
            }
        }
        return displaySet;
    }
1361419
def makeplantloop(idf, loopname, sloop, dloop, testing=None):
    """"""
    # -------- <testing ---------
    testn = 0
    # -------- testing> ---------
    newplantloop = idf.newidfobject("PLANTLOOP", Name=loopname)
    # -------- <testing ---------
    testn = doingtesting(testing, testn, newplantloop)
    if testn == None:
        returnnone()
    # -------- testing> ---------
    fields = SomeFields.p_fields

    # for use in bunch
    flnames = [field.replace(' ', '_') for field in fields]

    # simplify naming
    fields1 = [field.replace('Plant Side', 'Supply') for field in fields]
    fields1 = [field.replace('Demand Side', 'Demand') for field in fields1]
    fields1 = [field[:field.find('Name') - 1] for field in fields1]
    fields1 = [field.replace(' Node', '') for field in fields1]
    fields1 = [field.replace(' List', 's') for field in fields1]

    # TODO : pop connectors if no parallel branches
    # make fieldnames in the plant loop
    fieldnames = ['%s %s' % (loopname, field) for field in fields1]
    for fieldname, thefield in zip(fieldnames, flnames):
        newplantloop[thefield] = fieldname
    # -------- <testing ---------
    testn = doingtesting(testing, testn, newplantloop)
    if testn == None:
        returnnone()
    # -------- testing> ---------

    # make the branch lists for this plant loop
    sbranchlist = idf.newidfobject(
        "BRANCHLIST",
        Name=newplantloop.Plant_Side_Branch_List_Name)
    # -------- <testing ---------
    testn = doingtesting(testing, testn, newplantloop)
    if testn == None:
        returnnone()
    # -------- testing> ---------
    dbranchlist = idf.newidfobject(
        "BRANCHLIST",
        Name=newplantloop.Demand_Side_Branch_List_Name)
    # -------- <testing ---------
    testn = doingtesting(testing, testn, newplantloop)
    if testn == None:
        returnnone()
    # -------- testing> ---------
    # add branch names to the branchlist
    sbranchnames = flattencopy(sloop)
    # sbranchnames = sloop[1]
    for branchname in sbranchnames:
        sbranchlist.obj.append(branchname)
    # -------- <testing ---------
    testn = doingtesting(testing, testn, newplantloop)
    if testn == None:
        returnnone()
    # -------- testing> ---------
    dbranchnames = flattencopy(dloop)
    # dbranchnames = dloop[1]
    for branchname in dbranchnames:
        dbranchlist.obj.append(branchname)
    # -------- <testing ---------
    testn = doingtesting(testing, testn, newplantloop)
    if testn == None:
        returnnone()
    # -------- testing> ---------

    # make a pipe branch for all branches in the loop

    # supply side
    sbranchs = []
    for bname in sbranchnames:
        branch = makepipebranch(idf, bname)
        sbranchs.append(branch)
    # -------- <testing ---------
    testn = doingtesting(testing, testn, newplantloop)
    if testn == None:
        returnnone()
    # -------- testing> ---------
    # rename inlet outlet of endpoints of loop
    anode = "Component_1_Inlet_Node_Name"
    sameinnode = "Plant_Side_Inlet_Node_Name"
    sbranchs[0][anode] = newplantloop[sameinnode]
    anode = "Component_1_Outlet_Node_Name"
    sameoutnode = "Plant_Side_Outlet_Node_Name"
    sbranchs[-1][anode] = newplantloop[sameoutnode]
    # -------- <testing ---------
    testn = doingtesting(testing, testn, newplantloop)
    if testn == None:
        returnnone()
    # -------- testing> ---------
    # rename inlet outlet of endpoints of loop - rename in pipe
    pname = sbranchs[0]['Component_1_Name']  # get the pipe name
    apipe = idf.getobject('Pipe:Adiabatic'.upper(), pname)  # get pipe
    apipe.Inlet_Node_Name = newplantloop[sameinnode]
    pname = sbranchs[-1]['Component_1_Name']  # get the pipe name
    apipe = idf.getobject('Pipe:Adiabatic'.upper(), pname)  # get pipe
    apipe.Outlet_Node_Name = newplantloop[sameoutnode]
    # -------- <testing ---------
    testn = doingtesting(testing, testn, newplantloop)
    if testn == None:
        returnnone()
    # -------- testing> ---------

    # demand side
    dbranchs = []
    for bname in dbranchnames:
        branch = makepipebranch(idf, bname)
        dbranchs.append(branch)
    # -------- <testing ---------
    testn = doingtesting(testing, testn, newplantloop)
    if testn == None:
        returnnone()
    # -------- testing> ---------
    # rename inlet outlet of endpoints of loop - rename in branch
    anode = "Component_1_Inlet_Node_Name"
    sameinnode = "Demand_Side_Inlet_Node_Name"
    dbranchs[0][anode] = newplantloop[sameinnode]
    anode = "Component_1_Outlet_Node_Name"
    sameoutnode = "Demand_Side_Outlet_Node_Name"
    dbranchs[-1][anode] = newplantloop[sameoutnode]
    # -------- <testing ---------
    testn = doingtesting(testing, testn, newplantloop)
    if testn == None:
        returnnone()
    # -------- testing> ---------
    # rename inlet outlet of endpoints of loop - rename in pipe
    pname = dbranchs[0]['Component_1_Name']  # get the pipe name
    apipe = idf.getobject('Pipe:Adiabatic'.upper(), pname)  # get pipe
    apipe.Inlet_Node_Name = newplantloop[sameinnode]
    pname = dbranchs[-1]['Component_1_Name']  # get the pipe name
    apipe = idf.getobject('Pipe:Adiabatic'.upper(), pname)  # get pipe
    apipe.Outlet_Node_Name = newplantloop[sameoutnode]
    # -------- <testing ---------
    testn = doingtesting(testing, testn, newplantloop)
    if testn == None:
        returnnone()
    # -------- testing> ---------


    # TODO : test if there are parallel branches
    # make the connectorlist an fill fields
    sconnlist = idf.newidfobject(
        "CONNECTORLIST",
        Name=newplantloop.Plant_Side_Connector_List_Name)
    sconnlist.Connector_1_Object_Type = "Connector:Splitter"
    sconnlist.Connector_1_Name = "%s_supply_splitter" % (loopname,)
    sconnlist.Connector_2_Object_Type = "Connector:Mixer"
    sconnlist.Connector_2_Name = "%s_supply_mixer" % (loopname,)
    dconnlist = idf.newidfobject(
        "CONNECTORLIST",
        Name=newplantloop.Demand_Side_Connector_List_Name)
    dconnlist.Connector_1_Object_Type = "Connector:Splitter"
    dconnlist.Connector_1_Name = "%s_demand_splitter" % (loopname,)
    dconnlist.Connector_2_Object_Type = "Connector:Mixer"
    dconnlist.Connector_2_Name = "%s_demand_mixer" % (loopname,)
    # -------- <testing ---------
    testn = doingtesting(testing, testn, newplantloop)
    if testn == None:
        returnnone()
    # -------- testing> ---------

    # make splitters and mixers
    s_splitter = idf.newidfobject(
        "CONNECTOR:SPLITTER",
        Name=sconnlist.Connector_1_Name)
    s_splitter.obj.extend([sloop[0]] + sloop[1])
    s_mixer = idf.newidfobject(
        "CONNECTOR:MIXER",
        Name=sconnlist.Connector_2_Name)
    s_mixer.obj.extend([sloop[-1]] + sloop[1])
    # -
    d_splitter = idf.newidfobject(
        "CONNECTOR:SPLITTER",
        Name=dconnlist.Connector_1_Name)
    d_splitter.obj.extend([dloop[0]] + dloop[1])
    d_mixer = idf.newidfobject(
        "CONNECTOR:MIXER",
        Name=dconnlist.Connector_2_Name)
    d_mixer.obj.extend([dloop[-1]] + dloop[1])
    # -------- <testing ---------
    testn = doingtesting(testing, testn, newplantloop)
    if testn == None:
        returnnone()
    # -------- testing> ---------

    return newplantloop
1283616
def assign_fields(self):
        
        # We must fix fields at every level of the hierarchy separately
        # (otherwise fields of children won't be allowed to overlap). Here we
        # do a breadth-first iteration over the hierarchy to fix fields with
        # given starting positions; then we do depth-first to fix other fields.

        # Assign all fields with a fixed starting position in breadth first,
        # top-down order. The breadth-first ensures that children's fixed
        # position fields must fit around the fixed position fields of their
        # parents.
        queue = [(self.fields, {})]
        while queue:
            node, field_values = queue.pop(0)

            # Assign all fields at this level whose position is fixed
            self._assign_fields(node.fields, field_values,
                                assign_positions=False)

            # Breadth-first search through children
            for requirements, child in iteritems(node.children):
                requirements = dict(requirements)
                requirements.update(field_values)
                queue.append((child, requirements))

        # Assign all fields with movable starting positions in leaf-first,
        # depth-first order.  The depth first ordering for variable position
        # fields ensures that parents don't allocate fields in positions which
        # would collide with fixed and variable position fields their children
        # have already allocated.

        def recurse_assign_fields(node=self.fields, field_values={}):
            # Assign fields of child nodes first (allowing them to allocate
            # bits independently)
            for requirements, child in iteritems(node.children):
                child_field_values = dict(requirements)
                child_field_values.update(field_values)
                recurse_assign_fields(child, child_field_values)

            # Finally, assign all remaining fields at this level in the tree
            self._assign_fields(node.fields, field_values,
                                assign_positions=True)
        recurse_assign_fields()
472896
def scenario(args):
    
    p = OptionParser(__doc__)
    opts, args = p.parse_args()

    fig = plt.figure(1, (5, 5))
    root = fig.add_axes([0, 0, 1, 1])

    root.set_xlim(0, 1)
    root.set_ylim(0, 1)
    root.set_axis_off()

    # Layout format: (x, y, label, (chr lengths))
    anc = (.5, .9, "Ancestor", (1,))
    s1 = (.2, .6, "Genome I", (1,))
    s2 = (.5, .6, "Genome II", (1,))
    s3 = (.8, .6, "Genome III", (1,))
    tetra = (.35, .4, "Tetraploid I / II", (.5, .9))
    hexa = (.5, .1, "Hexaploid I / II / III", (.36, .46, .9))
    labels = (anc, s1, s2, s3, tetra, hexa)
    connections = ((anc, s1), (anc, s2), (anc, s3),\
            (s1, tetra), (s2, tetra),
            (tetra, hexa), (s3, hexa))

    xinterval = .02
    yratio = .05
    for xx, yy, label, chrl in labels:
        #RoundLabel(root, xx, yy, label)
        root.text(xx, yy, label, ha="center", va="center")
        offset = len(label) * .012
        for i, c in enumerate(chrl):
            ya = yy + yratio * c
            yb = yy - yratio * c
            Chromosome(root, xx - offset + i * xinterval, ya, yb, width=.01)

    # Comments
    comments = ((.15, .33, "II dominant"),
                (.25, .03, "III dominant"))

    for xx, yy, c in comments:
        root.text(xx, yy, c, size=9, ha="center", va="center")

    # Branches
    tip = .04
    for a, b in connections:
        xa, ya, la, chra = a
        xb, yb, lb, chrb = b
        plt.plot((xa, xb), (ya - tip, yb + 2 * tip), 'k-', lw=2, alpha=.5)

    figname = fname() + ".pdf"
    savefig(figname, dpi=300)
692775
def plotOptMod(verNObg3gray, VERgray):
    
    if VERgray is None and verNObg3gray is None:
        return

    fg = figure()
    ax2 = fg.gca()  # summed (as camera would see)

    if VERgray is not None:
        z = VERgray.alt_km
        Ek = VERgray.energy_ev.values

#        ax1.semilogx(VERgray, z, marker='',label='filt', color='b')
        props = {'boxstyle': 'round', 'facecolor': 'wheat', 'alpha': 0.5}
        fgs, axs = fg.subplots(6, 6, sharex=True, sharey='row')
        axs = axs.ravel()  # for convenient iteration
        fgs.subplots_adjust(hspace=0, wspace=0)
        fgs.suptitle('filtered VER/flux')
        fgs.text(0.04, 0.5, 'Altitude [km]', va='center', rotation='vertical')
        fgs.text(0.5, 0.04, 'Beam energy [eV]', ha='center')
        for i, e in enumerate(Ek):
            axs[i].semilogx(VERgray.loc[:, e], z)
            axs[i].set_xlim((1e-3, 1e4))

# place a text box in upper left in axes coords
            axs[i].text(0.95, 0.95, '{:0.0f}'.format(e)+'eV',
                        transform=axs[i].transAxes, fontsize=12,
                        va='top', ha='right', bbox=props)
        for i in range(33, 36):
            axs[i].axis('off')

        ax2.semilogx(VERgray.sum(axis=1), z, label='filt', color='b')

        # specific to energies
        ax = figure().gca()
        for e in Ek:
            ax.semilogx(VERgray.loc[:, e], z, marker='', label='{:.0f} eV'.format(e))
        ax.set_title('filtered VER/flux')
        ax.set_xlabel('VER/flux')
        ax.set_ylabel('altitude [km]')
        ax.legend(loc='best', fontsize=8)
        ax.set_xlim((1e-5, 1e5))
        ax.grid(True)

    if verNObg3gray is not None:
        ax1 = figure().gca()  # overview
        z = verNObg3gray.alt_km
        Ek = verNObg3gray.energy_ev.values

        ax1.semilogx(verNObg3gray, z, marker='', label='unfilt', color='r')
        ax2.semilogx(verNObg3gray.sum(axis=1), z, label='unfilt', color='r')

        ax = figure().gca()
        for e in Ek:
            ax.semilogx(verNObg3gray.loc[:, e], z, marker='', label='{:.0f} eV'.format(e))
        ax.set_title('UNfiltered VER/flux')
        ax.set_xlabel('VER/flux')
        ax.set_ylabel('altitude [km]')
        ax.legend(loc='best', fontsize=8)
        ax.set_xlim((1e-5, 1e5))
        ax.grid(True)

        ax1.set_title('VER/flux, one profile per beam')
        ax1.set_xlabel('VER/flux')
        ax1.set_ylabel('altitude [km]')
        ax1.grid(True)

    ax2.set_xlabel('VER/flux')
    ax2.set_ylabel('altitude [km]')
    ax2.set_title('VER/flux summed over all energy beams \n (as the camera would see)')
    ax2.legend(loc='best')
    ax2.grid(True)
960977
function getColumnByField(field) {
    for (var i = 0; i < this.gridCompColumnArr.length; i++) {
        if (this.gridCompColumnArr[i].options.field == field) {
            return this.gridCompColumnArr[i];
        }
    }
    for (var i = 0; i < this.gridCompColumnFixedArr.length; i++) {
        if (this.gridCompColumnFixedArr[i].options.field == field) {
            return this.gridCompColumnFixedArr[i];
        }
    }

    return null;
}
1088107
@Override
    public void renderLoop( PositionedText target, double x, double y, Size size, Diagram.Figure forward,
                            Diagram.Figure backward, String description, boolean forwardDirection )
    {
        throw new UnsupportedOperationException( "not implemented" );
    }
32698
void mergeFields() {
        for (int k = 0; k < fields.size(); ++k) {
            HashMap fd = ((AcroFields)fields.get(k)).getFields();
            mergeWithMaster(fd);
        }
    }
1304257
def get_field_mapping(self):
        
        field_mapping = self.field_mapping_widget.get_field_mapping()
        for k, v in list(field_mapping['values'].items()):
            if not v:
                field_mapping['values'].pop(k)
        for k, v in list(field_mapping['fields'].items()):
            if not v:
                field_mapping['fields'].pop(k)
        return field_mapping