Generator yielding only the high tides.
		Arguments:
		see Tide.extrema()
179138
def highs(self, *args):
		
		for t in ifilter(lambda e: e[2] == 'H', self.extrema(*args)):
			yield t
1038399
def max_curtailment(network, snapshots, curtail_max=0.03):
    
    
    renewables = ['wind_onshore', 'wind_offshore',
                  'solar']
    
    res = list(network.generators.index[
        (network.generators.carrier.isin(renewables))
        & (network.generators.bus.astype(str).isin(network.buses.index[network.buses.country_code == 'DE']))])
      
#    network.import_series_from_dataframe(pd.DataFrame(
#                index=network.generators_t.p_set.index,
#                columns=network.generators.index[
#                        network.generators.carrier=='biomass'],
#                data=1), "Generator", "p_max_pu")
    
    res_potential = (network.generators.p_nom[res]*network.generators_t.p_max_pu[res]).sum()
    
    snapshots = network.snapshots

    for gen in res:

        def _rule(m, gen):
            
            #import pdb; pdb.set_trace()
            re_n = sum(m.generator_p[gen, sn]
                                      for sn in snapshots)
            potential_n = res_potential[gen]

            return (re_n >= (1-curtail_max) * potential_n)
        setattr(network.model, "max_curtailment"+gen, Constraint(res, rule=_rule))
88160
def _maxlength(X):
    
    return np.fromiter((map(lambda x: len(x), X)), dtype=int).max()
982857
def softmax(xs):
    """"""
    ys = xs - np.max(xs)
    exps = np.exp(ys)
    return exps / exps.sum(axis=0)
116845
def asFloat(self, maxval=1.0):
        

        x,y,pixels,info = self.asDirect()
        sourcemaxval = 2**info['bitdepth']-1
        del info['bitdepth']
        info['maxval'] = float(maxval)
        factor = float(maxval)/float(sourcemaxval)
        def iterfloat():
            for row in pixels:
                yield map(factor.__mul__, row)
        return x,y,iterfloat(),info
875859
def max(self, default=None):
        
        return numpy.asscalar(numpy.max(self.values)) if self.values else default
580219
def nonlinear_tidal_spa(**kwds):
    

    from pycbc import waveform
    from pycbc.types import Array

    # We start with the standard TaylorF2 based waveform
    kwds.pop('approximant')
    hp, hc = waveform.get_fd_waveform(approximant="TaylorF2", **kwds)

    # Add the phasing difference from the nonlinear tides
    f = numpy.arange(len(hp)) * hp.delta_f
    pd =  Array(numpy.exp(-1.0j * nltides_fourier_phase_difference(f,
               hp.delta_f,
               kwds['f0'], kwds['amplitude'], kwds['n'],
               kwds['mass1'], kwds['mass2'])),
               dtype=hp.dtype)
    hp *= pd
    hc *= pd
    return hp, hc
120838
def dategenerator(start, end, step=1, desc=False):
    ''''''
    delta = timedelta(abs(step))
    end = max(start, end)
    if desc:
        dt = end
        while dt >= start:
            yield dt
            dt -= delta
    else:
        dt = start
        while dt <= end:
            yield dt
            dt += delta
559928
def decaying(start, stop, decay):
    """"""

    curr = float(start)
    while True:
        yield max(curr, stop)
        curr -= (decay)
1310035
def indim(self):
        
        indim = self.numOffbids * len(self.generators)

        if self.maxWithhold is not None:
            return indim * 2
        else:
            return indim
493517
private void softmax() {
        double max = Double.NEGATIVE_INFINITY;
        for (int i = 0; i < outputLayer.units; i++) {
            if (outputLayer.output[i] > max) {
                max = outputLayer.output[i];
            }
        }

        double sum = 0.0;
        for (int i = 0; i < outputLayer.units; i++) {
            double out = Math.exp(outputLayer.output[i] - max);
            outputLayer.output[i] = out;
            sum += out;
        }

        for (int i = 0; i < outputLayer.units; i++) {
            outputLayer.output[i] /= sum;
        }
    }
1198636
def _get_energy(self, x):
        
        return self.pd.get_hull_energy(self.comp1 * x + self.comp2 * (1-x)) - \
            self.e1 * x - self.e2 * (1-x)
124032
def peak_generation_per_technology(self):
        
        peak_generation = defaultdict(float)
        for gen in self.generators:
            peak_generation[gen.type] += gen.nominal_capacity

        return pd.Series(peak_generation)
1194304
def max(self, axis=None, dtype=None, out=None, keepdims=False):
        
        return self.elem.__array_ufunc__(
            np.maximum, 'reduce', self.elem,
            axis=axis, dtype=dtype, out=(out,), keepdims=keepdims)
193163
def through_maxima(*array_options, **options)
      @after_maxima ||= Command.output(itself: Unit) do |c|
        c.let :itself, self.to_s, *array_options, **options
      end[:itself]
    end
60
def _get_qgen_var(self, generators, base_mva):
        
        Qg = array([g.q / base_mva for g in generators])

        Qmin = array([g.q_min / base_mva for g in generators])
        Qmax = array([g.q_max / base_mva for g in generators])

        return Variable("Qg", len(generators), Qg, Qmin, Qmax)
469865
def fibonacci(cls, request,
                  limit: (Ptypes.path,
                          Integer('Upper limit of the series'))) -> [
            (200, 'Ok', FibonacciFragment)]:
        ''''''
        def fibonacci_generator():
            last_two = (0, 1)
            while last_two[1] <= limit:
                log.debug('Fibonacci number generated: {}'.format(last_two[1]))
                yield last_two[1]
                last_two = last_two[1], sum(last_two)
        log.info('Starting Fibonacci generation, max: {}'.format(limit))
        limit = int(limit)
        Respond(200, fibonacci_generator())