Applies contrast curve constraint to each population

        See :func:`vespa.stars.StarPopulation.apply_cc`;
        all arguments passed to that function for each population.
6037
def apply_cc(self, cc, **kwargs):
        
        if type(cc)==type(''):
            pass
        if cc.name not in self.constraints:
            self.constraints.append(cc.name)
        for pop in self.poplist:
            if not pop.is_specific:
                try:
                    pop.apply_cc(cc, **kwargs)
                except AttributeError:
                    logging.info('%s cc not applied to %s model' % (cc.name,pop.model))
145098
def _apply_BCs(self):
        
        """
        if 'pore.bc_rate' in self.keys():
            # Update b
            ind = np.isfinite(self['pore.bc_rate'])
            self.b[ind] = self['pore.bc_rate'][ind]
        if 'pore.bc_value' in self.keys():
            f = np.abs(self.A.data).mean()
            # Update b (impose bc values)
            ind = np.isfinite(self['pore.bc_value'])
            self.b[ind] = self['pore.bc_value'][ind] * f
            # Update b (substract quantities from b to keep A symmetric)
            x_BC = np.zeros(self.b.shape)
            x_BC[ind] = self['pore.bc_value'][ind]
            self.b[~ind] -= (self.A.tocsr() * x_BC)[~ind]
            # Update A
            P_bc = self.toindices(ind)
            indrow = np.isin(self.A.row, P_bc)
            indcol = np.isin(self.A.col, P_bc)
            self.A.data[indrow] = 0  # Remove entries from A for all BC rows
            self.A.data[indcol] = 0  # Remove entries from A for all BC cols
            datadiag = self.A.diagonal()  # Add diagonal entries back into A
            datadiag[P_bc] = np.ones_like(P_bc, dtype=np.float64) * f
            self.A.setdiag(datadiag)
            self.A.eliminate_zeros()
1091974
public void applyTo(Context ctx, GradientDrawable drawable) {
        if (mColorInt != 0) {
            drawable.setColor(mColorInt);
        } else if (mColorRes != -1) {
            drawable.setColor(ContextCompat.getColor(ctx, mColorRes));
        }
    }
480190
function (x0, y0, radius, color, c)
    {
        _c = c || _c
        if (color)
        {
            _c.fillStyle = color
        }
        x0 *= _scale
        y0 *= _scale
        radius *= _scale
        let x = radius
        let y = 0
        let decisionOver2 = 1 - x   // Decision criterion divided by 2 evaluated at x=r, y=0

        while (x >= y)
        {
            box(-x + x0, y + y0, x * 2, 1)
            box(-y + x0, x + y0, y * 2, 1)
            box(-x + x0, -y + y0, x * 2, 1)
            box(-y + x0, -x + y0, y * 2, 1)
            y++
            if (decisionOver2 <= 0)
            {
                decisionOver2 += 2 * y + 1 // Change in decision criterion for y -> y+1
            } else
            {
                x--
                decisionOver2 += 2 * (y - x) + 1 // Change for y -> y+1, x -> x-1
            }
        }
    }
1317016
def make_plot(self):
        
        # sets colormap for ratio comparison plot
        cmap = getattr(cm, self.colormap)

        # set values of ratio comparison contour
        normval = 2.0
        num_contours = 40  # must be even
        levels = np.linspace(-normval, normval, num_contours)
        norm = colors.Normalize(-normval, normval)

        # find Loss/Gain contour and Ratio contour
        self.set_comparison()
        diff_out, loss_gain_contour = self.find_difference_contour()

        cmap.set_bad(color='white', alpha=0.001)
        # plot ratio contours

        sc = self.axis.contourf(self.xvals[0], self.yvals[0], diff_out,
                                levels=levels, norm=norm,
                                extend='both', cmap=cmap)

        self.colorbar.setup_colorbars(sc)

        # toggle line contours of orders of magnitude of ratio comparisons
        if self.order_contour_lines:
                self.axis.contour(self.xvals[0], self.yvals[0], diff_out, np.array(
                    [-2.0, -1.0, 1.0, 2.0]), colors='black', linewidths=1.0)

        # plot loss gain contour
        if self.loss_gain_status is True:
            # if there is no loss/gain contours, this will produce an error,
            # so we catch the exception.
            try:
                # make hatching
                cs = self.axis.contourf(self.xvals[0], self.yvals[0],
                                        loss_gain_contour, levels=[-2, -0.5, 0.5, 2], colors='none',
                                        hatches=['x', None, '+'])
                # make loss/gain contour outline
                self.axis.contour(self.xvals[0], self.yvals[0],
                                  loss_gain_contour, 3, colors='black', linewidths=2)

            except ValueError:
                pass

        if self.add_legend:
            loss_patch = Patch(fill=None, label='Loss', hatch='x', linestyle='--', linewidth=2)
            gain_patch = Patch(fill=None, label='Gain', hatch='+', linestyle='-', linewidth=2)
            legend = self.axis.legend(handles=[loss_patch, gain_patch], **self.legend_kwargs)

        return
1270956
protected int[] rankUnfeasibleSolutions(List<S> population){
        int numberOfViolatedConstraintsBySolution1, numberOfViolatedConstraintsBySolution2;
        int indexOfFirstSolution, indexOfSecondSolution, indexOfWeight;
        double overallConstraintViolationSolution1, overallConstraintViolationSolution2;
        double minimumValueFirstSolution, minimumValueSecondSolution, value;
        int[] rank = new int[population.size()];
        Arrays.fill(rank, 0);

        //Iteration for each solution
        for (indexOfFirstSolution = 0; indexOfFirstSolution < population.size()-1; indexOfFirstSolution++ ) {
            //The current solution is compared with the following ones
            for (indexOfSecondSolution = indexOfFirstSolution + 1; indexOfSecondSolution < population.size(); indexOfSecondSolution++) {
                numberOfViolatedConstraintsBySolution1 = numberOfViolatedConstraints.getAttribute(population.get(indexOfFirstSolution));
                numberOfViolatedConstraintsBySolution2 = numberOfViolatedConstraints.getAttribute(population.get(indexOfSecondSolution));

                //The number of violated constraints is compared.
                //A solution with higher number of violated constraints has a worse (higher) rank
                if (numberOfViolatedConstraintsBySolution1 > numberOfViolatedConstraintsBySolution2) {
                    rank[indexOfFirstSolution]++;
                } else if (numberOfViolatedConstraintsBySolution1 < numberOfViolatedConstraintsBySolution2) {
                    rank[indexOfSecondSolution]++;
                } else {
                    //Because the solutions have a similar violated number of constraints, the overall constraint
                    //violation values are compared.
                    //Note that overall constraint values are negative in jMetal
                    overallConstraintViolationSolution1 = overallConstraintViolation.getAttribute(population.get(indexOfFirstSolution));
                    overallConstraintViolationSolution2 = overallConstraintViolation.getAttribute(population.get(indexOfSecondSolution));

                    //The overall constraint violation values are compared.
                    //Note that overall constraint values are negative in jMetal.
                    //Thus, a solution with higher value has a better (higher) rank
                    if (overallConstraintViolationSolution1 > overallConstraintViolationSolution2) {
                        rank[indexOfSecondSolution]++;
                    } else if (overallConstraintViolationSolution1 < overallConstraintViolationSolution2) {
                        rank[indexOfFirstSolution]++;
                    } else {
                        //Because the solutions have the same overall constraint violation values, we compare the
                        //the value of their utility functions. Lower values are better.
                        minimumValueFirstSolution = minimumValueSecondSolution = Double.POSITIVE_INFINITY;
                        for (indexOfWeight = 0; indexOfWeight < this.utilityFunctionsNadir.getSize(); indexOfWeight++) {
                            value = this.utilityFunctionsNadir.evaluate(population.get(indexOfFirstSolution), indexOfWeight);
                            if (value < minimumValueFirstSolution) {
                                minimumValueFirstSolution = value;
                            }

                            value = this.utilityFunctionsNadir.evaluate(population.get(indexOfSecondSolution), indexOfWeight);
                            if (value < minimumValueSecondSolution) {
                                minimumValueSecondSolution = value;
                            }
                        }
                        for (indexOfWeight = 0; indexOfWeight < this.utilityFunctionsUtopia.getSize(); indexOfWeight++) {
                            value = this.utilityFunctionsUtopia.evaluate(population.get(indexOfFirstSolution), indexOfWeight);
                            if (value < minimumValueFirstSolution) {
                                minimumValueFirstSolution = value;
                            }

                            value = this.utilityFunctionsUtopia.evaluate(population.get(indexOfSecondSolution), indexOfWeight);
                            if (value < minimumValueSecondSolution) {
                                minimumValueSecondSolution = value;
                            }
                        }

                        if (minimumValueFirstSolution < minimumValueSecondSolution) {
                            rank[indexOfSecondSolution]++;
                        } else {
                            rank[indexOfFirstSolution]++;
                        }
                    }
                }
            }
        }

        return rank;
    }
288170
def opacity_transfer_function(key, n_colors):
    
    transfer_func = {
        'linear': np.linspace(0, 255, n_colors, dtype=np.uint8),
        'linear_r': np.linspace(0, 255, n_colors, dtype=np.uint8)[::-1],
        'geom': np.geomspace(1e-6, 255, n_colors, dtype=np.uint8),
        'geom_r': np.geomspace(255, 1e-6, n_colors, dtype=np.uint8),
    }
    try:
        return transfer_func[key]
    except KeyError:
        raise KeyError('opactiy transfer function ({}) unknown.'.format(key))
169364
public static void applyToOrTransparent(ColorHolder colorHolder, Context ctx, GradientDrawable gradientDrawable) {
        if (colorHolder != null && gradientDrawable != null) {
            colorHolder.applyTo(ctx, gradientDrawable);
        } else if (gradientDrawable != null) {
            gradientDrawable.setColor(Color.TRANSPARENT);
        }
    }
61371
protected void perturbCenter( Cluster c , int x , int y ) {
		float best = Float.MAX_VALUE;
		int bestX=0,bestY=0;

		for( int dy = -1; dy <= 1; dy++ ) {
			for( int dx = -1; dx <= 1; dx++ ) {
				float d = gradient(x + dx, y + dy);
				if( d < best ) {
					best = d;
					bestX = dx;
					bestY = dy;
				}
			}
		}

		c.x = x+bestX;
		c.y = y+bestY;
		setColor(c.color,x+bestX,y+bestY);
	}
168858
def plot_density(population,  # pylint: disable=too-many-arguments, too-many-locals
                 bins=100, new_fig=True, subplot=111, levels=None, plane='xy',
                 colorlabel='Nodes per unit area', labelfontsize=16,
                 color_map='Reds', no_colorbar=False, threshold=0.01,
                 neurite_type=NeuriteType.basal_dendrite, **kwargs):
    '''
    '''
    fig, ax = common.get_figure(new_fig=new_fig, subplot=subplot)

    H1, xedges1, yedges1 = extract_density(population, plane=plane, bins=bins,
                                           neurite_type=neurite_type)

    mask = H1 < threshold  # mask = H1==0
    H2 = np.ma.masked_array(H1, mask)

    getattr(plt.cm, color_map).set_bad(color='white', alpha=None)

    plots = ax.contourf((xedges1[:-1] + xedges1[1:]) / 2,
                        (yedges1[:-1] + yedges1[1:]) / 2,
                        np.transpose(H2), # / np.max(H2),
                        cmap=getattr(plt.cm, color_map), levels=levels)

    if not no_colorbar:
        cbar = plt.colorbar(plots)
        cbar.ax.set_ylabel(colorlabel, fontsize=labelfontsize)

    kwargs['title'] = kwargs.get('title', '')
    kwargs['xlabel'] = kwargs.get('xlabel', plane[0])
    kwargs['ylabel'] = kwargs.get('ylabel', plane[1])

    return common.plot_style(fig=fig, ax=ax, **kwargs)
15631
def applyColorMap(gray, cmap='flame'):
    '''
    
    '''
    # TODO:implement more cmaps
    if cmap != 'flame':
        raise NotImplemented
    # TODO: make better
    mx = 256  # if gray.dtype==np.uint8 else 65535
    lut = np.empty(shape=(256, 3))
    cmap = (
        # taken from pyqtgraph GradientEditorItem
        (0, (0, 0, 0)),
        (0.2, (7, 0, 220)),
        (0.5, (236, 0, 134)),
        (0.8, (246, 246, 0)),
        (1.0, (255, 255, 255))
    )
    # build lookup table:
    lastval, lastcol = cmap[0]
    for step, col in cmap[1:]:
        val = int(step * mx)
        for i in range(3):
            lut[lastval:val, i] = np.linspace(
                lastcol[i], col[i], val - lastval)

        lastcol = col
        lastval = val

    s0, s1 = gray.shape
    out = np.empty(shape=(s0, s1, 3), dtype=np.uint8)

    for i in range(3):
        out[..., i] = cv2.LUT(gray, lut[:, i])
    return out
1059928
def _process_cmap_cbar_kwargs(func, kwargs, data):
    

    cmap = kwargs.pop('cmap', None)
    colors = kwargs.pop('colors', None)

    cbar_kwargs = kwargs.pop('cbar_kwargs', {})
    cbar_kwargs = {} if cbar_kwargs is None else dict(cbar_kwargs)

    levels = kwargs.pop('levels', None)
    if 'contour' in func.__name__ and levels is None:
        levels = 7  # this is the matplotlib default

    # colors is mutually exclusive with cmap
    if cmap and colors:
        raise ValueError("Can't specify both cmap and colors.")

    # colors is only valid when levels is supplied or the plot is of type
    # contour or contourf
    if colors and (('contour' not in func.__name__) and (not levels)):
        raise ValueError("Can only specify colors with contour or levels")

    # we should not be getting a list of colors in cmap anymore
    # is there a better way to do this test?
    if isinstance(cmap, (list, tuple)):
        warnings.warn("Specifying a list of colors in cmap is deprecated. "
                      "Use colors keyword instead.",
                      DeprecationWarning, stacklevel=3)

    cmap_kwargs = {'plot_data': data,
                   'levels': levels,
                   'cmap': colors if colors else cmap,
                   'filled': func.__name__ != 'contour'}

    cmap_args = getfullargspec(_determine_cmap_params).args
    cmap_kwargs.update((a, kwargs[a]) for a in cmap_args if a in kwargs)
    cmap_params = _determine_cmap_params(**cmap_kwargs)

    return cmap_params, cbar_kwargs
747883
def set_plot_CC_T_rho_new(self,fig='CC evol',linestyle=['-'],burn_limit=0.997,color=['r'],marker=['o'],markevery=500): 
		'''
			
		'''
		if len(linestyle)==0:
			linestyle=200*['-']
		plt.figure(fig)
                for i in range(len(self.runs_H5_surf)):
                        sefiles=se(self.runs_H5_out[i])
			t1_model=-1
                        mini=sefiles.get('mini')
			zini=sefiles.get('zini')
			label=str(mini)+'$M_{\odot}$, Z='+str(zini)
                        model=sefiles.se.cycles
                        model_list=[]
                        for k in range(0,len(model),1):
                                model_list.append(model[k])
			print 'REad Rho,T, this might take a while...'
                        rho1=sefiles.get(model_list,'rho')   #[:(t1_model-t0_model)]
                        T1=sefiles.get(model_list,'temperature')#[:(t1_model-t0_model)]
			print 'finished'
                        rho=[]
                        T=[]
			T_unit=sefiles.get('temperature_unit')
			labeldone=False
			for k in range(len(model_list)):
				#print 'test model ',model_list[k]
                                t9max=max(np.array(T1[k])*T_unit/1.e9)
                                #T.append(max(t9))
				rho1max=max(rho1[k])
				print 'model',model_list[k]
				print 'maxT, maxrho'
				print t9max,rho1max
				if k==0:
					t9_prev=t9max
					rho1_prev=rho1max
					idx_T=0
					idx_rho=0
					continue
				if t9max>t9_prev:
					idx_T=k
					t9_prev=t9max
				if rho1max>rho1_prev:
					idx_rho=k
					rho1_prev=rho1max
			print 'found highest rho',idx_rho,max(np.array(T1[idx_rho])*T_unit/1.0e9),max(rho1[idx_rho]),model_list[idx_rho]
			print 'found highest T',idx_T,max(np.array(T1[idx_T])*T_unit/1.0e9),max(rho1[idx_T]),model_list[idx_T]
			if idx_T==idx_rho:
				x=np.array(T1[idx_T])*T_unit/1e9
				y=rho1[idx_T]
				rho1=[]	
				T1=[]
				for k in range(len(x)):
				    if not y[k]==1.0:
			        	rho1.append(y[k])
        				T1.append(x[k])
				x=T1
				y=rho1
				plt.plot(x,y,label=label,color=color[i],marker=marker[i],linestyle=linestyle[i],markevery=markevery)
                                #rhoi.append(max(rho1[k]))	       
			else:
				#for max T
				x=np.array(T1[idx_T])*T_unit/1e9
				y=rho1[idx_T]
                                rho_temp=[]
                                T_temp=[]
                                for k in range(len(x)):
                                    if not y[k]==1.0:
                                        rho_temp.append(y[k])
                                        T_temp.append(x[k])
                                x=T_temp
                                y=rho_temp
				plt.plot(x,y,label=label,color=color[i],marker=marker[i],linestyle=linestyle[i],markevery=markevery)
				#for max rho
        			x=np.array(T1[idx_rho])*T_unit/1e9
				y=rho1[idx_rho]
                                rho_temp=[]
                                T_temp=[]
                                for k in range(len(x)):
                                    if not y[k]==1.0:
                                        rho_temp.append(y[k])
                                        T_temp.append(x[k])
                                x=T_temp
                                y=rho_temp
				plt.plot(x,y,color=color[i],marker=marker[i],linestyle=linestyle[i],markevery=markevery)
30615
def cos_c(self, N=None):  # percent=0.9,
		""""""

		if not hasattr(self, 'G') or self.G.shape[1] < self.rank:
			self.fs_c(N=self.rank)  # generate
		self.dc = norm(self.G, axis=1)**2
		# cheaper than diag(self.G.dot(self.G.T))?

		return apply_along_axis(lambda _: _/self.dc, 0, self.G[:, :N]**2)
930760
def generate_contrast(problem):
    

    num_vars = problem['num_vars']

    # Find the smallest n, such that num_vars < k
    k = [2 ** n for n in range(16)]
    k_chosen = 2 ** find_smallest(num_vars)

    # Generate the fractional factorial contrast
    contrast = np.vstack([hadamard(k_chosen), -hadamard(k_chosen)])

    return contrast
266617
def _draw_pr_curve(self, recall, precision, label=None):
        
        self.ax.step(
            recall, precision, alpha=self.line_opacity, where='post', label=label
        )
        if self.fill_area:
            self.ax.fill_between(recall, precision, step='post', alpha=self.fill_opacity)
876734
def constrain_property(self,prop,**kwargs):
        
        if prop not in self.constraints:
            self.constraints.append(prop)
        for pop in self.poplist:
            try:
                pop.constrain_property(prop,**kwargs)
            except AttributeError:
                logging.info('%s model does not have property stars.%s (constraint not applied)' % (pop.model,prop))