Add multiple variables to the model simultaneously
490540
def add_variables(vars)
      # Allocate space for the new variables
      ret = LPSolve.resize_lp(@ptr, @constraints.length,
                              @variables.length + vars.length)
      fail if ret != 1

      # Store all the variables in the model
      vars.each { |var| store_variable var }
    end
107193
def append(values)
      coa!
      if values.is_a?(VarSet)
        values.send(:coa!)
        @coa_vars = values.instance_variable_get(:@coa_vars) + @coa_vars
      else
        @my_vars = deep_dup(values)
      end
      self
    end
763480
def _add_mixing_variable_names_to_individual_vars(self):
        
        assert isinstance(self.ind_var_names, list)
        # Note that if one estimates a mixed logit model, then the mixing
        # variables will be added to individual vars. And if one estimates
        # the model again (perhaps from different starting values), then
        # an error will be raised when creating the coefs series because we
        # will have added the mixing variables twice. The condition below
        # should prevent this error.
        already_included = any(["Sigma " in x for x in self.ind_var_names])

        if self.mixing_vars is not None and not already_included:
            new_ind_var_names = ["Sigma " + x for x in self.mixing_vars]
            self.ind_var_names += new_ind_var_names
        return None
562254
def addVars(filename, varNamesStr, outOf=None):
    """
    filename, varnames, outOf = __saveVarsHelper(filename, varNamesStr, outOf)
    f = None
    try:
        f = open(filename, "rb")
        h = cPickle.load(f)
        f.close()

        h.update(dict(zip(varnames, atIndices(outOf, varnames))))
        f = open(filename, "wb")
        cPickle.dump( h, f , 1 )
    finally:
        if f: f.close()
1133066
def _add_variable_proxy_methods(var, proxy_tensor):
  
  proxy_tensor.read_value = lambda: tf.identity(proxy_tensor)
  proxy_tensor.assign_sub = var.assign_sub
  proxy_tensor.assign = var.assign
  proxy_tensor.initialized_value = var.initialized_value
474667
def _expand_rec_to_vars(var_items, rec_items, input_order, items_by_key, parallel):
    
    num_items = var_items
    var_items = list(var_items)[0]
    if rec_items:
        for rec_key in (k for (k, t) in input_order.items() if t == "record"):
            rec_vals = items_by_key[rec_key]
            if len(rec_vals) == 1 and var_items > 1:
                items_by_key[rec_key] = rec_vals * var_items
            else:
                assert var_items == len(rec_vals), (var_items, rec_vals)
    return items_by_key, num_items
414850
def _add_variable(self, variable):
        
        # TODO: Add feature for accepting additional properties of states.
        variable_data = self.data['probnet']['Variables'][variable]
        variable_element = etree.SubElement(self.variables, 'Variable', attrib={'name': variable,
                                                                                'type': variable_data['type'],
                                                                                'role': variable_data['role']})

        try:
            etree.SubElement(variable_element, 'Comment').text = variable_data['Comment']
        except KeyError:
            pass
        try:
            etree.SubElement(variable_element, 'Coordinates', variable_data['Coordinates'])
        except KeyError:
            pass

        try:
            for key, value in sorted(variable_data['AdditionalProperties'].items()):
                etree.SubElement(variable_element, 'Property', attrib={'name': key, 'value': value})
        except KeyError:
            etree.SubElement(variable_element, 'AdditionalProperties')
        states = etree.SubElement(variable_element, 'States')
        for s in sorted(variable_data['States']):
            state = etree.SubElement(states, 'State', attrib={'name': s})
            try:
                self._add_additional_properties(state, variable_data['States'][s]['AdditionalProperties'])
            except KeyError:
                etree.SubElement(state, 'AdditionalProperties')
965726
def add(self, v):
    """"""
    self._vals_added += 1
    if self._mean is None:
      self._mean = v
    self._mean = self._mean + ((v - self._mean) / float(self._vals_added))
907149
def add_constraint(self, func, variables, default_values=None):
        
        self._constraints.append((func, variables, default_values or ()))
1229992
def updateModel(self, X_all, Y_all, X_new, Y_new):
        
        self.X = X_all
        self.Y = Y_all
        if self.model is None:
            self._create_model(X_all, Y_all)
        else:
            self.model.fit(X_all, Y_all.flatten())
216145
def _AddVariable(self, variable):
        
        if isinstance(variable, Signal):
            if not variable in self.signals:
                self.signals.append(variable)
        elif isinstance(variable, Variable):
            if not variable in self.variables:
                self.variables.append(variable)
        else:
            raise TypeError
        self._utd_graph = False
2194
function(model, options) {
      options || (options = {});
      model = this._prepareModel(model, options);
      if (!model) return false;
      var already = this.getByCid(model) || this.get(model);
      if (already) throw new Error(["Can't add the same model to a set twice", already.id]);
      this._byId[model.id] = model;
      this._byCid[model.cid] = model;
      var index = options.at != null ? options.at :
                  this.comparator ? this.sortedIndex(model, this.comparator) :
                  this.length;
      this.models.splice(index, 0, model);
      model.bind('all', this._onModelEvent);
      this.length++;
      if (!options.silent) model.trigger('add', model, this, options);
      return model;
    }
237014
def _append_base_arguments(self):
        
        if self.exc and self.only:
            raise PackerException('Cannot provide both "except" and "only"')
        elif self.exc:
            self._add_opt('-except={0}'.format(self._join_comma(self.exc)))
        elif self.only:
            self._add_opt('-only={0}'.format(self._join_comma(self.only)))
        for var, value in self.vars.items():
            self._add_opt("-var")
            self._add_opt("{0}={1}".format(var, value))
        if self.var_file:
            self._add_opt('-var-file={0}'.format(self.var_file))
1018118
def add_variables(*vars)
      # create bound variables for each variable
      bound_vars = vars.collect do |v|
        BoundVariable.new v, self
      end

      # add all the bound variables to the variables hash
      keys = vars.collect(&:name)
      append_hash = Hash[ keys.zip(bound_vars) ]
      @variables_hash.merge!(append_hash) do |key, oldval, newval|
        oldval # the first bound variable
      end
    end
213429
def on_add(self, widget, data=None):
        """"""
        if isinstance(self.model, ContainerStateModel):
            try:
                scoped_var_ids = gui_helper_state_machine.add_scoped_variable_to_selected_states(selected_states=[self.model])
                if scoped_var_ids:
                    self.select_entry(scoped_var_ids[self.model.state])
            except ValueError as e:
                logger.warning("The scoped variable couldn't be added: {0}".format(e))
                return False

            return True
46938
def update_model(self, model):
        
        for k, v in self.parse_form().items():
            setattr(model, k, v)
664125
def expand_and_merge_variables(objs, priority_arg=None):
    
    expanded = expand_variable_dicts(objs)
    priority_vars = _get_priority_vars(objs, priority_arg)
    variables = merge_variables(expanded, priority_vars)
    return variables