provide another way to define the layers (stack)

        Parameters:
        ===========
        formula: string
           ex: 'CoAg2'
           ex: 'Al'
        thickness: float (in mm)
        density: float (g/cm3)
967951
def add_layer(self, formula='', thickness=np.NaN, density=np.NaN):
        
        if formula == '':
            return

        _new_stack = _utilities.formula_to_dictionary(formula=formula,
                                                      thickness=thickness,
                                                      density=density,
                                                      database=self.database)
        # check if density has been defined
        self.__lock_density_if_defined(stack=_new_stack)

        new_stack = self.__update_stack_with_isotopes_infos(stack=_new_stack)
        self.stack = {**self.stack, **new_stack}

        # calculate stack_sigma, layer density, atoms_per_cm3 ...
        self.__math_on_stack()
1058766
def parameters(self, value):
        
    
        if len(value) != self.n_parameters:
            raise ValueError("Incorrect length of parameter vector. "
                             "Model has %d parameters, but got %d" %
                             (self.n_parameters, len(value)))

        i = 0
        for hl in self.hidden_layers:
            hl.parameters = value[i:i + hl.n_parameters]
            i += hl.n_parameters

        self.top_layer.parameters = value[-self.top_layer.n_parameters:]
69026
def material_formula(self):
        
        try:
            form = self.header.formula
        except IndexError:
            form = 'No formula provided'
        return "".join(map(str, form))
1355450
def _yCellParams(self):
        '''
        
        '''
        #cell type specific parameters going into LFPy.Cell        
        yCellParams = {}
        for layer, morpho, _, _ in self.y_zip_list:
            yCellParams.update({layer : self.cellParams.copy()})
            yCellParams[layer].update({
                'morphology' : os.path.join(self.PATH_m_y, morpho),
            })
        return yCellParams
443848
def parameters(self):
        
        if self._parameters is None:
            self.__init()
        for param in self._parameters:
            if not isinstance(param['defaultValue'], BaseGPObject):
                if param['dataType'] == "GPFeatureRecordSetLayer":
                    param['defaultValue'] = GPFeatureRecordSetLayer.fromJSON(json.dumps(param))
                elif param['dataType'] == "GPString":
                    param['defaultValue'] = GPString.fromJSON(json.dumps(param))
                elif param['dataType'] == "GPLong":
                    param['defaultValue'] = GPLong.fromJSON(json.dumps(param))
                elif param['dataType'] == "GPDouble":
                    param['defaultValue'] = GPDouble.fromJSON(json.dumps(param))
                elif param['dataType'] == "GPDate":
                    param['defaultValue'] = GPDate.fromJSON(json.dumps(param))
                elif param['dataType'] == "GPBoolean":
                    param['defaultValue'] = GPBoolean.fromJSON(json.dumps(param))
                elif param['dataType'] == "GPDataFile":
                    param['defaultValue'] = GPDataFile.fromJSON(json.dumps(param))
                elif param['dataType'] == "GPLinearUnit":
                    param['defaultValue'] = GPLinearUnit.fromJSON(json.dumps(param))
                elif param['dataType'] == "GPMultiValue":
                    param['defaultValue'] = GPMultiValue.fromJSON(json.dumps(param))
                elif param['dataType'] == "GPRasterData":
                    param['defaultValue'] = GPRasterData.fromJSON(json.dumps(param))
                elif param['dataType'] == "GPRasterDataLayer":
                    param['defaultValue'] = GPRasterDataLayer.fromJSON(json.dumps(param))
                elif param['dataType'] == "GPRecordSet":
                    param['defaultValue'] = GPRecordSet.fromJSON(json.dumps(param))
        return self._parameters
1212576
def add_aux_param(self, param_name, layer_index, blob_index):
        
        self.add_param('aux:%s' % param_name, layer_index, blob_index)
261257
def procMat(materials, max_thickness, min_thickness):
    
    newmat = []
    newthickness = []
    k = materials.layerThermalCond
    Vhc = materials.layerVolHeat

    if len(materials.layerThickness) > 1:

        for j in range(len(materials.layerThickness)):
            # Break up each layer that's more than max thickness (0.05m)
            if materials.layerThickness[j] > max_thickness:
                nlayers = math.ceil(materials.layerThickness[j]/float(max_thickness))
                for i in range(int(nlayers)):
                    newmat.append(Material(k[j], Vhc[j], name=materials._name))
                    newthickness.append(materials.layerThickness[j]/float(nlayers))
            # Material that's less then min_thickness is not added.
            elif materials.layerThickness[j] < min_thickness:
                print("WARNING: Material '{}' layer found too thin (<{:.2f}cm), ignored.").format(
                    materials._name, min_thickness*100)
            else:
                newmat.append(Material(k[j], Vhc[j], name=materials._name))
                newthickness.append(materials.layerThickness[j])

    else:

        # Divide single layer into two (uwg assumes at least 2 layers)
        if materials.layerThickness[0] > max_thickness:
            nlayers = math.ceil(materials.layerThickness[0]/float(max_thickness))
            for i in range(int(nlayers)):
                newmat.append(Material(k[0], Vhc[0], name=materials._name))
                newthickness.append(materials.layerThickness[0]/float(nlayers))
        # Material should be at least 1cm thick, so if we're here,
        # should give warning and stop. Only warning given for now.
        elif materials.layerThickness[0] < min_thickness*2:
            newthickness = [min_thickness/2., min_thickness/2.]
            newmat = [Material(k[0], Vhc[0], name=materials._name),
                      Material(k[0], Vhc[0], name=materials._name)]
            print("WARNING: a thin (<2cm) single material '{}' layer found. May cause error.".format(
                materials._name))
        else:
            newthickness = [materials.layerThickness[0]/2., materials.layerThickness[0]/2.]
            newmat = [Material(k[0], Vhc[0], name=materials._name),
                      Material(k[0], Vhc[0], name=materials._name)]
    return newmat, newthickness
652359
def fill_layer_combo(self):
        """"""
        project = QgsProject.instance()
        # MapLayers returns a QMap<QString id, QgsMapLayer layer>
        layers = list(project.mapLayers().values())

        extensions = tuple(extension_siblings.keys())
        for layer in layers:
            if layer.source().lower().endswith(extensions):
                icon = layer_icon(layer)
                self.layers.addItem(icon, layer.name(), layer.id())
670867
function(l){
        if(l.layersContext){
            for (var i = 0, len = l.layersContext.length; i < len; i++) {
                var layerContext = l.layersContext[i];
                var nPath = [];
                var nTitle = l.title || "";
                if(l.metadata && l.metadata.nestingPath){
                    nPath = l.metadata.nestingPath.slice();
                }
                if (nTitle != "") {
                    nPath.push(nTitle);
                }
                layerContext.metadata.nestingPath = nPath;
                if(layerContext.layersContext){
                    this.setNestingPath(layerContext);
                }
            }
        }
    }
1175369
function(item) {
    if ('values' in item && layerName in item.values && item.values[layerName]) {
      return parseFloat(item.values[layerName]);
    }
    throw new Error('Unexpected');
  }
415782
private void addCNF(final Formula formula, int weight) {
    switch (formula.type()) {
      case TRUE:
        break;
      case FALSE:
      case LITERAL:
      case OR:
        this.addClause(formula, weight);
        break;
      case AND:
        for (Formula op : formula)
          this.addClause(op, weight);
        break;
      default:
        throw new IllegalArgumentException("Input formula ist not a valid CNF: " + formula);
    }
  }
1315744
function(id, parentId, x, y, width, height, borderWidth, depth, _class, visual, values) {

           if (borderWidth === undefined)
               borderWidth = 0;
           if (depth === undefined)
               depth = 0;
           if (_class === undefined)
               _class = 0;
           if (visual === undefined)
               visual = 0;
           if (values === undefined)
               values = {}

           var format = 'CCSLLssSSSSLL';

           // TODO: slice from function arguments?

           // TODO: the code is a little bit mess
           // additional values need to be packed in the following way:
           // bitmask (bytes #24 to #31 in the packet) - 32 bit indicating what adittional arguments we supply
           // values list (bytes #32 .. #32+4*num_values) in order of corresponding bits TODO: it's actually not 4*num. Some values are 4b ytes, some - 1 byte

           var vals = packValueMask('CreateWindow', values);
           var packetLength = 8 + (values ? vals[2].length : 0);
           var args = [1, depth, packetLength, id, parentId, x, y, width, height, borderWidth, _class, visual];
           format += vals[0];
           args.push(vals[1]);
           args = args.concat(vals[2]);
           return [format, args];
       }
618104
@Override
    public long numParams(boolean backwards) {
        int length = 0;
        for (int i = 0; i < layers.length; i++)
            length += layers[i].numParams(backwards);

        return length;
    }
261778
def toString(self):
        
        string = "Layer '%s': (Kind: %s, Size: %d, Active: %d, Frozen: %d)\n" % (
            self.name, self.kind, self.size, self.active, self.frozen) 
        if (self.type == 'Output'):
            string += toStringArray('Target    ', self.target, self.displayWidth)
        string += toStringArray('Activation', self.activation, self.displayWidth) 
        if (self.type != 'Input' and self._verbosity > 1):
            string += toStringArray('Error     ', self.error, self.displayWidth)
        if (self._verbosity > 4 and self.type != 'Input'):
            string +=  toStringArray('weight    ', self.weight, self.displayWidth)
            string +=  toStringArray('dweight   ', self.dweight, self.displayWidth)
            string +=  toStringArray('delta     ', self.delta, self.displayWidth)
            string +=  toStringArray('netinput  ', self.netinput, self.displayWidth)
            string +=  toStringArray('wed       ', self.wed, self.displayWidth)
        return string
379246
def _do_stack(self, cmd, args):
        
        if not args:
            self.__dump_stack()
            return
        if len(args) > 1:
            self.stderr.write('stack: too many arguments: {}\n'.format(args))
            return
        try:
            depth = int(args[0])
        except ValueError:
            self.stderr.write("stack: depth is not an integer: '{}'\n".format(args[0]))
            return
        if depth < 0:
            self.stderr.write('stack: negative depth: {}\n'.format(depth))
            return
        return depth
645412
def get_layer(self, x, layer, **kwargs):
    
    return self.fprop(x, **kwargs)[layer]
449559
function Layer(name, fn) {
  this.length = fn.length;
  this.name = name;
  this.fn = fn;
}