Makes the (linear) consumption function for this period.

        Parameters
        ----------
        none

        Returns
        -------
        none
770384
def makePFcFunc(self):
        '''
        
        '''
        # Calculate human wealth this period (and lower bound of m)
        self.hNrmNow = (self.PermGroFac/self.Rfree)*(self.solution_next.hNrm + 1.0)
        self.mNrmMin = -self.hNrmNow
        # Calculate the (constant) marginal propensity to consume
        PatFac       = ((self.Rfree*self.DiscFacEff)**(1.0/self.CRRA))/self.Rfree
        self.MPC     = 1.0/(1.0 + PatFac/self.solution_next.MPCmin)
        # Construct the consumption function
        self.cFunc   = LinearInterp([self.mNrmMin, self.mNrmMin+1.0],[0.0, self.MPC])
        # Add two attributes to enable calculation of steady state market resources
        self.ExIncNext = 1.0 # Perfect foresight income of 1
        self.mNrmMinNow = self.mNrmMin
1142295
def def_linear(fun):
    """"""
    defjvp_argnum(fun, lambda argnum, g, ans, args, kwargs:
                  fun(*subval(args, argnum, g), **kwargs))
816815
def _build_func(eq, **args):
    
    '''
    eq_prime = eq.diff(args['x'])
    s1 = eq_prime
    s2 = eq - eq_prime*args['x']
    EQ = _syp.lambdify(args.values(), expr=eq, modules='numpy')
    S1 = _syp.lambdify(args.values(), expr=s1, modules='numpy')
    S2 = _syp.lambdify(args.values(), expr=s2, modules='numpy')
    return EQ, S1, S2
1193142
def create(self, price_estimate):
        
        kwargs = {}
        try:
            previous_price_estimate = price_estimate.get_previous()
        except ObjectDoesNotExist:
            pass
        else:
            configuration = previous_price_estimate.consumption_details.configuration
            kwargs['configuration'] = configuration
        month_start = core_utils.month_start(datetime.date(price_estimate.year, price_estimate.month, 1))
        kwargs['last_update_time'] = month_start
        return super(ConsumptionDetailsQuerySet, self).create(price_estimate=price_estimate, **kwargs)
1125397
def create(optimizer, max_lr, min_lr, cycles, cycle_len=1, cycle_mult=1, interpolate='linear', init_lr=0, init_iter=0):
    
    return CyclePhase(
        max_lr=max_lr,
        min_lr=min_lr,
        cycles=cycles,
        cycle_len=cycle_len,
        cycle_mult=cycle_mult,
        interpolate=interpolate,
        optimizer_factory=optimizer,
        init_lr=init_lr,
        init_iter=init_iter,
    )
166824
def rigid_linear_interpolate_by_datetime(datetime_axis, y_axis, datetime_new_axis):
    
    numeric_datetime_axis = [
        totimestamp(a_datetime) for a_datetime in datetime_axis
    ]

    numeric_datetime_new_axis = [
        totimestamp(a_datetime) for a_datetime in datetime_new_axis
    ]

    return rigid_linear_interpolate(
        numeric_datetime_axis, y_axis, numeric_datetime_new_axis)
785076
def acquisition_function(self,x):
        
        f_acqu = self._compute_acq(x)
        cost_x, _ = self.cost_withGradients(x)
        return -(f_acqu*self.space.indicator_constraints(x))/cost_x
38666
def pass_none(func):
	
	@functools.wraps(func)
	def wrapper(param, *args, **kwargs):
		if param is not None:
			return func(param, *args, **kwargs)
	return wrapper
651475
def one_or_none(self):
        
        # Sanity check: Has consumption of this query already started?
        # If it has, then this is an exception.
        if self._metadata is not None:
            raise RuntimeError(
                "Can not call `.one` or `.one_or_none` after "
                "stream consumption has already started."
            )

        # Consume the first result of the stream.
        # If there is no first result, then return None.
        iterator = iter(self)
        try:
            answer = next(iterator)
        except StopIteration:
            return None

        # Attempt to consume more. This should no-op; if we get additional
        # rows, then this is an error case.
        try:
            next(iterator)
            raise ValueError("Expected one result; got more.")
        except StopIteration:
            return answer
273569
def all(self, usage_type, usage_period_id, api, query=None, *args, **kwargs):
        

        if query is None:
            query = {}

        mandatory_query = {
            'filters[usagePeriod]': usage_period_id,
            'filters[metric]': api
        }

        mandatory_query.update(query)

        return self.client._get(
            self._url(usage_type),
            mandatory_query,
            headers={
                'x-contentful-enable-alpha-feature': 'usage-insights'
            }
        )
1306813
def click_estimate_slope():
    

    c1 = _pylab.ginput()
    if len(c1)==0:
        return None

    c2 = _pylab.ginput()
    if len(c2)==0:
        return None

    return (c1[0][1]-c2[0][1])/(c1[0][0]-c2[0][0])
371742
def times(self, func, *args):
        
        n = self.obj
        i = 0
        while n is not 0:
            n -= 1
            func(i)
            i += 1

        return self._wrap(func)
511245
def detrended_price_oscillator(data, period):
    
    catch_errors.check_for_period_error(data, period)
    period = int(period)
    dop = [data[idx] - np.mean(data[idx+1-(int(period/2)+1):idx+1]) for idx in range(period-1, len(data))]
    dop = fill_for_noncomputable_vals(data, dop)
    return dop
832206
def _cost_func(x, kernel_options, tuning_options, runner, results, cache):
    

    error_time = 1e20
    logging.debug('_cost_func called')
    logging.debug('x: ' + str(x))

    x_key = ",".join([str(i) for i in x])
    if x_key in cache:
        return cache[x_key]

    #snap values in x to nearest actual value for each parameter unscale x if needed
    if tuning_options.scaling:
        params = unscale_and_snap_to_nearest(x, tuning_options.tune_params, tuning_options.eps)
    else:
        params = snap_to_nearest_config(x, tuning_options.tune_params)

    logging.debug('params ' + str(params))

    x_int = ",".join([str(i) for i in params])
    if x_int in cache:
        return cache[x_int]

    #check if this is a legal (non-restricted) parameter instance
    if tuning_options.restrictions:
        legal = util.check_restrictions(tuning_options.restrictions, params, tuning_options.tune_params.keys(), tuning_options.verbose)
        if not legal:
            cache[x_int] = error_time
            cache[x_key] = error_time
            return error_time

    #compile and benchmark this instance
    res, _ = runner.run([params], kernel_options, tuning_options)

    #append to tuning results
    if res:
        results.append(res[0])
        cache[x_int] = res[0]['time']
        cache[x_key] = res[0]['time']
        return res[0]['time']

    cache[x_int] = error_time
    cache[x_key] = error_time
    return error_time
638107
def default_estimate(
    opt_meth: Type[OptimizationMethod], mo_prob: MOProblem, dp: int = 2
) -> Tuple[List[float], List[float]]:
    
    return round_off(estimate_payoff_table(opt_meth, mo_prob), dp)
1279435
def consumed_in_month(self):
        
        month_end = core_utils.month_end(datetime.date(self.price_estimate.year, self.price_estimate.month, 1))
        return self._get_consumed(month_end)
1231370
def linear_interpolate_by_datetime(datetime_axis, y_axis, datetime_new_axis,
                                   enable_warning=True):
    
    numeric_datetime_axis = [
        totimestamp(a_datetime) for a_datetime in datetime_axis
    ]

    numeric_datetime_new_axis = [
        totimestamp(a_datetime) for a_datetime in datetime_new_axis
    ]

    return linear_interpolate(
        numeric_datetime_axis, y_axis, numeric_datetime_new_axis,
        enable_warning=enable_warning)