Update parameters of the acquisition required to evaluate the function. In particular:
            * Sample representer points repr_points
            * Compute their log values repr_points_log
            * Compute belief locations logP
975434
def _update_parameters(self):
        
        self.repr_points, self.repr_points_log = self.sampler.get_samples(self.num_repr_points, self.proposal_function, self.burn_in_steps)

        if np.any(np.isnan(self.repr_points_log)) or np.any(np.isposinf(self.repr_points_log)):
            raise RuntimeError("Sampler generated representer points with invalid log values: {}".format(self.repr_points_log))

        # Removing representer points that have 0 probability of being the minimum (corresponding to log probability being minus infinity)
        idx_to_remove = np.where(np.isneginf(self.repr_points_log))[0]
        if len(idx_to_remove) > 0:
            idx = list(set(range(self.num_repr_points)) - set(idx_to_remove))
            self.repr_points = self.repr_points[idx, :]
            self.repr_points_log = self.repr_points_log[idx]

        # We predict with the noise as we need to make sure that var is indeed positive definite.
        mu, _ = self.model.predict(self.repr_points)
        # we need a vector
        mu = np.ndarray.flatten(mu)
        var = self.model.predict_covariance(self.repr_points)
        
        self.logP, self.dlogPdMu, self.dlogPdSigma, self.dlogPdMudMu = epmgp.joint_min(mu, var, with_derivatives=True)
        # add a second dimension to the array
        self.logP = np.reshape(self.logP, (self.logP.shape[0], 1))
982874
def add_live_points(self):
        """"""

        # Check if the remaining live points have already been added
        # to the output set of samples.
        if self.added_live:
            raise ValueError("The remaining live points have already "
                             "been added to the list of samples!")
        else:
            self.added_live = True

        # After N samples have been taken out, the remaining volume is
        # `e^(-N / nlive)`. The remaining points are distributed uniformly
        # within the remaining volume so that the expected volume enclosed
        # by the `i`-th worst likelihood is
        # `e^(-N / nlive) * (nlive + 1 - i) / (nlive + 1)`.
        logvols = self.saved_logvol[-1]
        logvols += np.log(1. - (np.arange(self.nlive)+1.) / (self.nlive+1.))
        logvols_pad = np.concatenate(([self.saved_logvol[-1]], logvols))
        logdvols = logsumexp(a=np.c_[logvols_pad[:-1], logvols_pad[1:]],
                             axis=1, b=np.c_[np.ones(self.nlive),
                                             -np.ones(self.nlive)])
        logdvols += math.log(0.5)

        # Defining change in `logvol` used in `logzvar` approximation.
        dlvs = logvols_pad[:-1] - logvols_pad[1:]

        # Sorting remaining live points.
        lsort_idx = np.argsort(self.live_logl)
        loglmax = max(self.live_logl)

        # Grabbing relevant values from the last dead point.
        logz = self.saved_logz[-1]
        logzvar = self.saved_logzvar[-1]
        h = self.saved_h[-1]
        loglstar = self.saved_logl[-1]
        if self._beyond_unit_bound(loglstar):
            bounditer = self.nbound - 1
        else:
            bounditer = 0

        # Add contributions from the remaining live points in order
        # from the lowest to the highest log-likelihoods.
        for i in range(self.nlive):

            # Grab live point with `i`-th lowest log-likelihood along with
            # ancillary quantities.
            idx = lsort_idx[i]
            logvol, logdvol, dlv = logvols[i], logdvols[i], dlvs[i]
            ustar = np.array(self.live_u[idx])
            vstar = np.array(self.live_v[idx])
            loglstar_new = self.live_logl[idx]
            boundidx = self.live_bound[idx]
            point_it = self.live_it[idx]

            # Compute relative contribution to results.
            logwt = np.logaddexp(loglstar_new, loglstar) + logdvol  # weight
            logz_new = np.logaddexp(logz, logwt)  # ln(evidence)
            lzterm = (math.exp(loglstar - logz_new) * loglstar +
                      math.exp(loglstar_new - logz_new) * loglstar_new)
            h_new = (math.exp(logdvol) * lzterm +
                     math.exp(logz - logz_new) * (h + logz) -
                     logz_new)  # information
            dh = h_new - h
            h = h_new
            logz = logz_new
            logzvar += dh * dlv  # var[ln(evidence)] estimate
            loglstar = loglstar_new
            logz_remain = loglmax + logvol  # remaining ln(evidence)
            delta_logz = np.logaddexp(logz, logz_remain) - logz  # dlogz

            # Save results.
            if self.save_samples:
                self.saved_id.append(idx)
                self.saved_u.append(ustar)
                self.saved_v.append(vstar)
                self.saved_logl.append(loglstar)
                self.saved_logvol.append(logvol)
                self.saved_logwt.append(logwt)
                self.saved_logz.append(logz)
                self.saved_logzvar.append(logzvar)
                self.saved_h.append(h)
                self.saved_nc.append(1)
                self.saved_boundidx.append(boundidx)
                self.saved_it.append(point_it)
                self.saved_bounditer.append(bounditer)
                self.saved_scale.append(self.scale)
            self.eff = 100. * (self.it + i) / self.ncall  # efficiency

            # Return our new "dead" point and ancillary quantities.
            yield (idx, ustar, vstar, loglstar, logvol, logwt,
                   logz, logzvar, h, 1, point_it, boundidx, bounditer,
                   self.eff, delta_logz)
1261596
def sampling_params(self):
        
        if self.sampling_transforms is None:
            sampling_params = self.variable_params
        else:
            sampling_params = self.sampling_transforms.sampling_params
        return sampling_params
64136
def step(self, observations, state, argmax_sampling=False):
        
        action_pd_params, value_output, new_state = self(observations, state)
        actions = self.action_head.sample(action_pd_params, argmax_sampling=argmax_sampling)

        # log likelihood of selected action
        logprobs = self.action_head.logprob(actions, action_pd_params)

        return {
            'actions': actions,
            'values': value_output,
            'logprobs': logprobs,
            'state': new_state
        }
965655
def _update_estimate_and_sampler(self, ell, ell_hat, weight, extra_info,
                                     **kwargs):
        """"""

        stratum_idx = extra_info['stratum']

        if 'calc_rates' in kwargs:
            calc_rates = kwargs['calc_rates']
        else:
            calc_rates = True

        self._TP_st[stratum_idx,:] += ell_hat * ell * weight
        self._PP_st[stratum_idx,:] += ell_hat * weight
        self._P_st[stratum_idx,:] += ell * weight

        if calc_rates:
            self._P_rates = self._P_st/self.strata._n_sampled[:,np.newaxis]
            self._TP_rates = self._TP_st/self.strata._n_sampled[:,np.newaxis]
            self._PP_rates = self._PP_st/self.strata._n_sampled[:,np.newaxis]

        #: Update model estimate (with prior)
        self._estimate[self.t_], self._F_num, self._F_den = \
            self._calc_estimate(self._TP_rates, self._PP_rates, \
                                self._P_rates, return_num_den=True)
1067967
def _update_functions(self):
        

        self.f             = []
        self.bg            = []
        self._fnames       = []
        self._bgnames      = []
        self._odr_models   = [] # Like f, but different parameters, for use in ODR


        f  = self._f_raw
        bg = self._bg_raw

        # make sure f and bg are lists of matching length
        if not _s.fun.is_iterable(f) : f  = [f]
        if not _s.fun.is_iterable(bg): bg = [bg]
        while len(bg) < len(f): bg.append(None)

        # get a comma-delimited string list of parameter names for the "normal" function
        pstring = 'x, ' + ', '.join(self._pnames)
        
        # get the comma-delimited string for the ODR function
        pstring_odr = 'x, '
        for n in range(len(self._pnames)): pstring_odr = pstring_odr+'p['+str(n)+'], '

        # update the globals for the functions
        # the way this is done, we must redefine the functions
        # every time we change a constant
        for cname in self._cnames: self._globals[cname] = self[cname]

        # loop over all the functions and create the master list
        for n in range(len(f)):

            # if f[n] is a string, define a function on the fly.
            if isinstance(f[n], str):
                
                # "Normal" least squares function (y-error bars only)
                self.f.append( eval('lambda ' + pstring + ': ' + f[n],  self._globals))
                self._fnames.append(f[n])
            
                # "ODR" compatible function (for x-error bars), based on self.f
                self._odr_models.append( _odr.Model(eval('lambda p,x: self.f[n]('+pstring_odr+')', dict(self=self, n=n))))
            
            # Otherwise, just append it.
            else:
                self.f.append(f[n])
                self._fnames.append(f[n].__name__)

            # if bg[n] is a string, define a function on the fly.
            if isinstance(bg[n], str):
                self.bg.append(eval('lambda ' + pstring + ': ' + bg[n], self._globals))
                self._bgnames.append(bg[n])
            else:
                self.bg.append(bg[n])
                if bg[n] is None: self._bgnames.append("None")
                else:             self._bgnames.append(bg[n].__name__)

        # update the format of all the settings
        for k in list(self._settings.keys()): self[k] = self[k]

        # make sure we don't think our fit results are valid!
        self.clear_results()
188347
def set_parameters(self):
        
        for key in dir(self):
            if key.startswith('REQUIRES_'):
                setattr(self, key, getattr(self.gmpe, key))
            if key.startswith('DEFINED_'):
                if not key.endswith('FOR_INTENSITY_MEASURE_TYPES'):
                    setattr(self, key, getattr(self.gmpe, key))
214047
def compute_batch(self, duplicate_manager=None, context_manager=None):
        
        from ...acquisitions import AcquisitionLP
        assert isinstance(self.acquisition, AcquisitionLP)

        self.acquisition.update_batches(None,None,None)

        # --- GET first element in the batch
        X_batch = self.acquisition.optimize()[0]
        k=1

        if self.batch_size >1:
            # ---------- Approximate the constants of the the method
            L = estimate_L(self.acquisition.model.model,self.acquisition.space.get_bounds())
            Min = self.acquisition.model.model.Y.min()

        # --- GET the remaining elements
        while k<self.batch_size:
            self.acquisition.update_batches(X_batch,L,Min)
            new_sample = self.acquisition.optimize()[0]
            X_batch = np.vstack((X_batch,new_sample))
            k +=1

        # --- Back to the non-penalized acquisition
        self.acquisition.update_batches(None,None,None)
        return X_batch
1033570
def _update_metrics(self,
                        metric_train: mx.metric.EvalMetric,
                        metric_val: mx.metric.EvalMetric):
        
        checkpoint_metrics = {"epoch": self.state.epoch,
                              "learning-rate": self.model.optimizer.learning_rate,
                              "gradient-norm": self.state.gradient_norm,
                              "time-elapsed": time.time() - self.state.start_tic}
        gpu_memory_usage = utils.get_gpu_memory_usage(self.model.context)
        checkpoint_metrics['used-gpu-memory'] = sum(v[0] for v in gpu_memory_usage.values())
        checkpoint_metrics['converged'] = self.state.converged
        checkpoint_metrics['diverged'] = self.state.diverged

        for name, value in metric_train.get_name_value():
            checkpoint_metrics["%s-train" % name] = value
        for name, value in metric_val.get_name_value():
            checkpoint_metrics["%s-val" % name] = value

        self.state.metrics.append(checkpoint_metrics)
        utils.write_metrics_file(self.state.metrics, self.metrics_fname)

        tf_metrics = checkpoint_metrics.copy()
        tf_metrics.update({"%s_grad" % n: v for n, v in self.state.gradients.items()})
        tf_metrics.update(self.model.params)
        self.tflogger.log_metrics(metrics=tf_metrics, checkpoint=self.state.checkpoint)
921213
def _update_params(self, constants):
        """"""
        constants = np.max(np.min(constants, 1))
        self.params['r']['value'] = max([self.params['r']['value'],
                                         constants])
        epsilon = constants / self.params['r']['value']
        influence = self._calculate_influence(epsilon)
        # Account for learning rate
        return influence * epsilon
1372147
def update(self, pointvol):
        """"""

        # Check if we should use the provided pool for updating.
        if self.use_pool_update:
            pool = self.pool
        else:
            pool = None

        # Update the ellipsoid.
        self.ell.update(self.live_u, pointvol=pointvol, rstate=self.rstate,
                        bootstrap=self.bootstrap, pool=pool)
        if self.enlarge != 1.:
            self.ell.scale_to_vol(self.ell.vol * self.enlarge)

        return copy.deepcopy(self.ell)
1058292
def set_parameters(self):
        
        for key in (ADMITTED_STR_PARAMETERS + ADMITTED_FLOAT_PARAMETERS +
                    ADMITTED_SET_PARAMETERS):
            try:
                val = getattr(self.gmpe, key)
            except AttributeError:
                pass
            else:
                setattr(self, key, val)
1124971
def updateCalibration(self):
        """"""
        if self.samplerate() != self._calibration_fs:
            self.setCalibration(self._attenuationVector, self._calFrequencies, self._calFrange)
215050
def _updateEmissionProbabilities(self):
        
        observations_by_state = [self.model.collect_observations_in_state(self.observations, state)
                                 for state in range(self.model.nstates)]
        self.model.output_model.sample(observations_by_state)
1348946
def _update(self):
        
        aps = []
        for k, v in self.records.items():
            recall, prec = self._recall_prec(v, self.counts[k])
            ap = self._average_precision(recall, prec)
            aps.append(ap)
            if self.num is not None and k < (self.num - 1):
                self.sum_metric[k] = ap
                self.num_inst[k] = 1
        if self.num is None:
            self.num_inst = 1
            self.sum_metric = np.mean(aps)
        else:
            self.num_inst[-1] = 1
            self.sum_metric[-1] = np.mean(aps)
95046
def _assess_approximation(self, boundary_points, derivs, funcs, nodes, problem):
        
        interior_residuals = self._compute_interior_residuals(derivs, funcs,
                                                              nodes, problem)
        boundary_residuals = self._compute_boundary_residuals(boundary_points,
                                                              funcs, problem)
        return np.hstack(interior_residuals + boundary_residuals)
550730
def _update_plotting_params(self, **kwargs):
        
        scalars = kwargs.get('scalars', None)
        if scalars is not None:
            old = self.display_params['scalars']
            self.display_params['scalars'] = scalars
            if old != scalars:
                self.plotter.subplot(*self.loc)
                self.plotter.remove_actor(self._data_to_update, reset_camera=False)
                self._need_to_update = True
                self.valid_range = self.input_dataset.get_data_range(scalars)
                # self.display_params['rng'] = self.valid_range
        cmap = kwargs.get('cmap', None)
        if cmap is not None:
            self.display_params['cmap'] = cmap