Some aggregation types may need to update their max grade.

This must be executed after updating the weights as it relies on them.

@return void
776837
private function auto_update_max() {
        global $CFG, $DB;
        if ($this->aggregation != GRADE_AGGREGATE_SUM) {
            // not needed at all
            return;
        }

        // Find grade items of immediate children (category or grade items) and force site settings.
        $this->load_grade_item();
        $depends_on = $this->grade_item->depends_on();

        // Check to see if the gradebook is frozen. This allows grades to not be altered at all until a user verifies that they
        // wish to update the grades.
        $gradebookcalculationfreeze = 'gradebook_calculations_freeze_' . $this->courseid;
        $oldextracreditcalculation = isset($CFG->$gradebookcalculationfreeze) && ($CFG->$gradebookcalculationfreeze <= 20150627);
        // Only run if the gradebook isn't frozen.
        if (!$oldextracreditcalculation) {
            // Don't automatically update the max for calculated items.
            if ($this->grade_item->is_calculated()) {
                return;
            }
        }

        $items = false;
        if (!empty($depends_on)) {
            list($usql, $params) = $DB->get_in_or_equal($depends_on);
            $sql = "SELECT *
                      FROM {grade_items}
                     WHERE id $usql";
            $items = $DB->get_records_sql($sql, $params);
        }

        if (!$items) {

            if ($this->grade_item->grademax != 0 or $this->grade_item->gradetype != GRADE_TYPE_VALUE) {
                $this->grade_item->grademax  = 0;
                $this->grade_item->grademin  = 0;
                $this->grade_item->gradetype = GRADE_TYPE_VALUE;
                $this->grade_item->update('aggregation');
            }
            return;
        }

        //find max grade possible
        $maxes = array();

        foreach ($items as $item) {

            if ($item->aggregationcoef > 0) {
                // extra credit from this activity - does not affect total
                continue;
            } else if ($item->aggregationcoef2 <= 0) {
                // Items with a weight of 0 do not affect the total.
                continue;
            }

            if ($item->gradetype == GRADE_TYPE_VALUE) {
                $maxes[$item->id] = $item->grademax;

            } else if ($item->gradetype == GRADE_TYPE_SCALE) {
                $maxes[$item->id] = $item->grademax; // 0 = nograde, 1 = first scale item, 2 = second scale item
            }
        }

        if ($this->can_apply_limit_rules()) {
            // Apply droplow and keephigh.
            $this->apply_limit_rules($maxes, $items);
        }
        $max = array_sum($maxes);

        // update db if anything changed
        if ($this->grade_item->grademax != $max or $this->grade_item->grademin != 0 or $this->grade_item->gradetype != GRADE_TYPE_VALUE) {
            $this->grade_item->grademax  = $max;
            $this->grade_item->grademin  = 0;
            $this->grade_item->gradetype = GRADE_TYPE_VALUE;
            $this->grade_item->update('aggregation');
        }
    }
135008
private function updateLevel()
    {
        if (null === $this->output or OutputInterface::VERBOSITY_QUIET === ($verbosity = $this->output->getVerbosity())) {
            return false;
        }

        $this->setLevel(Logger::DEBUG);
        return true;
    }
1249643
public static <K> void updateWeights(double l1, double l2, double learningRate, Map<K, Double> weights, Map<K, Double> newWeights) {
        L2Regularizer.updateWeights(l2, learningRate, weights, newWeights);
        L1Regularizer.updateWeights(l1, learningRate, weights, newWeights);
    }
89630
public function update(Request $request)
    {
        $this->cache->tags('categories')->flush();

        $this->categoryOrdener->handle($request->get('categories'));
    }
425843
public function updateRelated()
    {
        foreach ($this->related as $name => $value) {
            if ($value instanceof Manager) {
                continue;
            }

            /** @var \Mindy\Orm\Fields\RelatedField $field */
            $field = $this->getField($name);
            if ($field instanceof HasManyField) {
                continue;
            }
            if (empty($value)) {
                $field->getManager()->clean();
            } else {
                $field->setValue($value);
            }
        }
        $this->related = [];
    }
664678
def update(self) -> None:
        """"""
        mask = self.mask
        weights = self.refweights[mask]
        self[~mask] = numpy.nan
        self[mask] = weights/numpy.sum(weights)
356664
public function upgrade(): void
    {
        // This table was previously created by the googlemap module in 1.7.9.
        // These migrations are now part of the core code.

        if (!DB::schema()->hasTable('placelocation')) {
            DB::schema()->create('placelocation', static function (Blueprint $table): void {
                $table->integer('pl_id')->primary();
                $table->integer('pl_parent_id');
                $table->integer('pl_level');
                $table->string('pl_place', 255);
                $table->string('pl_long', 30)->nullable();
                $table->string('pl_lati', 30)->nullable();
                $table->integer('pl_zoom')->nullable();
                $table->string('pl_icon', 255)->nullable();

                $table->index('pl_place');
                $table->unique(['pl_parent_id', 'pl_place']);
            });
        }

        if (DB::schema()->hasColumn('placelocation', 'pl_media')) {
            DB::schema()->table('placelocation', static function (Blueprint $table): void {
                $table->dropColumn('pl_media');
                $table->dropColumn('sv_long');
                $table->dropColumn('sv_lati');
                $table->dropColumn('sv_bearing');
                $table->dropColumn('sv_elevation');
                $table->dropColumn('sv_zoom');
            });
        }
    }
1016250
public function updateTotals()
    {
        if (is_array($this->totals)) {
            foreach ($this->totals as $key => $val) {
                if (is_object($this->current_row[$key])) {
                    continue;
                }
                $this->totals[$key] = $val + $this->current_row[$key];
            }
        }
    }
805597
private function defaultLevelIncrement(): void
  {
    if (!empty($this->defaultLevel))
    {
      $this->defaultLevel[sizeof($this->defaultLevel) - 1]++;
    }
  }
265173
public function update()
    {
        if (!$this->checkForUpdates()) {
            return;
        }
        if (!$this->subModuleUpdater) {
            $this->site->getVariables()->setValue("last_updated", time());
        }
        $this->exec("git fetch origin");
        $this->exec("git reset --hard origin/{$this->currentBranch()}");
        /** @var $updater Updater */
        foreach ($this->subUpdaters as $updater) {
            $updater->update();
        }
        $this->exec("make update");
        $this->canBeUpdated = false;
        $this->site->getVariables()->setValue("can_be_updated", 0);
        $this->site->modify();
        $this->currentVersion = null;

    }
1160594
public function updateOrderStatus()
    {
        $orderUpdated = false;
        $order = $this->getOrder();

        if (!is_null($order)) {
            $orderPayment = $this->getOrderPayment();
            $order = $this->recalculateAmounts($order);
            $newOrderStatus = $this->calculateOrderStatus($orderPayment, $order);
            $this->persistNewOrderStatus($order, $newOrderStatus);
            $orderUpdated = true;
        }

        return $orderUpdated;
    }
553852
protected function _update()
    {
        $this->oxnews__oxdate->setValue(\OxidEsales\Eshop\Core\Registry::getUtilsDate()->formatDBDate($this->oxnews__oxdate->value, true));

        parent::_update();
    }
506783
private void updateMinMax() {
    if(values.length == 0) {
      return; // Keep invalid.
    }
    min = max = values[0];
    for(int i = 1; i < values.length; i++) {
      int v = values[i];
      min = min < v ? min : v;
      max = max > v ? max : v;
    }
  }
963246
protected function updateGroupStack(array $attributes)
    {
        if (! empty($this->groupStack)) {
            $old = last($this->groupStack);

            $attributes = static::mergeGroup($attributes, $old);
        }

        $this->groupStack[] = $attributes;
    }
1219621
private void update() {
                if (!uptodate) {
                        summary.clear();
                        distinctTraces.clear();
                        traces.clear();
                        addTraces(allTraces, false);
                        uptodate = true;
                }
        }
928122
public function updateTotals()
    {
        foreach ($this->totals_plan as $key => $val) {

            // if value is array, then we treat it as built-in or callable aggregate method
            if (is_array($val)) {
                $f = $val[0]; // shortcut

                // initial value is always 0
                if (!isset($this->totals[$key])) {
                    $this->totals[$key] = 0;
                }

                // closure support
                // arguments - current value, key, \atk4\ui\Table object
                if ($f instanceof \Closure) {
                    $this->totals[$key] += ($f($this->model[$key], $key, $this) ?: 0);
                }
                // built-in methods
                elseif (is_string($f)) {
                    switch ($f) {
                        case 'sum':
                            $this->totals[$key] += $this->model[$key];
                            break;
                        case 'count':
                            $this->totals[$key] += 1;
                            break;
                        case 'min':
                            if ($this->model[$key] < $this->totals[$key]) {
                                $this->totals[$key] = $this->model[$key];
                            }
                            break;
                        case 'max':
                            if ($this->model[$key] > $this->totals[$key]) {
                                $this->totals[$key] = $this->model[$key];
                            }
                            break;
                        default:
                            throw new Exception(['Aggregation method does not exist', 'method' => $f]);
                    }
                }
            }
        }
    }
1110142
protected function _resetTotalValues()
    {
        $this->_iTotalCnn = 0;
        $this->_iTotalCrapIndex = 0;
        $this->_iTotalNPath = 0;
        $this->_iTotalLLOC = 0;
        $this->_aStats = array();
    }