Helper function to figure out what denom and palette to use, based on the
    kwargs and the grid being plotted. The optional (default: false) argument
    indicates whether the grid contains phenotypes, as opposed to resources.
342462
def get_kwargs(grid, kwargs, phenotypes=False):
    
    denom = None
    if "denom" in kwargs:
        denom = kwargs["denom"]

    if "palette" in kwargs:
        palette = kwargs["palette"]
        if denom is None:
            denom = len(palette)
    elif "environment" in kwargs or isinstance(grid, EnvironmentFile):
        if "environment" in kwargs:
            env = kwargs["environment"]
        else:
            env = grid

        if phenotypes:
            palette = env.task_palette
            if denom is None:
                denom = len(env.tasks)
        else:
            palette = env.resource_palette
            if denom is None:
                denom = len(env.resources)

    else:
        length = get_pallete_length(grid)
        palette = sns.hls_palette(length, s=1)
        denom = length

    return denom, palette
1348241
public static boolean findBooleanOption(String[] args, String option) {
        for (int i = 0; i<args.length; ++i) {
            if (args[i].equals(option)) return true;
        }
        return false;
    }
708603
def _get_true_palette_entry(self, name, digits):
        ''' 
        '''
        values = None
        type_digits = type(digits)
        is_fbterm = (env.TERM == 'fbterm')  # sigh

        if 'truecolor' in self._palette_support:  # build entry
            values = [self._start_codes_true]
            if type_digits is str:  # convert hex string
                if len(digits) == 3:
                    values.extend(str(int(ch + ch, 16)) for ch in digits)
                else:  # chunk 'BB00BB', to ints to 'R', 'G', 'B':
                    values.extend(str(int(digits[i:i+2], 16)) for i in (0, 2 ,4))
            else:  # tuple of str-digit or int, may not matter to bother:
                values.extend(str(digit) for digit in digits)

        # downgrade section
        elif 'extended' in self._palette_support:
            if type_digits is str:
                nearest_idx = find_nearest_color_hexstr(digits,
                                                       method=self._dg_method)
            else:  # tuple
                if type(digits[0]) is str:  # convert to ints
                    digits = tuple(int(digit) for digit in digits)
                nearest_idx = find_nearest_color_index(*digits,
                                                       method=self._dg_method)

            start_codes = self._start_codes_extended
            if is_fbterm:
                start_codes = self._start_codes_extended_fbterm

            values = [start_codes, str(nearest_idx)]

        elif 'basic' in self._palette_support:
            if type_digits is str:
                nearest_idx = find_nearest_color_hexstr(digits, color_table4,
                                                       method=self._dg_method)
            else:  # tuple
                if type(digits[0]) is str:  # convert to ints
                    digits = tuple(int(digit) for digit in digits)
                nearest_idx = find_nearest_color_index(*digits,
                                                       color_table=color_table4,
                                                       method=self._dg_method)
            values = self._index_to_ansi_values(nearest_idx)

        return (self._create_entry(name, values, fbterm=is_fbterm)
                if values else empty)
359838
def options(self, glob=False, **args):
        
        kwargs = {}
        for argname, argarg in args.items():
            if argname == "sort":
                argarg = self._getPattern(argarg)
            if argname not in ["done", "undone"]:
                kwargs[argname] = argarg
        if "done" in args or "undone" in args:
            kwargs["done"] = self._getDone(
                args.get("done"), args.get("undone")
            )

        self.model.setOptions(glob=glob, **kwargs)
612199
def detect_palette_support(basic_palette=None):
    ''' 
    '''
    result = col_init = win_enabled = None
    TERM = env.TERM or ''
    if os_name == 'nt':
        from .windows import (is_ansi_capable, enable_vt_processing,
                              is_colorama_initialized)
        if is_ansi_capable():
            win_enabled = all(enable_vt_processing())
        col_init = is_colorama_initialized()

    # linux, older Windows + colorama
    if TERM.startswith('xterm') or (TERM == 'linux') or col_init:
            result = 'basic'

    # xterm, fbterm, older Windows + ansicon
    if ('256color' in TERM) or (TERM == 'fbterm') or env.ANSICON:
        result = 'extended'

    # https://bugzilla.redhat.com/show_bug.cgi?id=1173688 - obsolete?
    if env.COLORTERM in ('truecolor', '24bit') or win_enabled:
        result = 'truecolor'

    # find the platform-dependent 16-color basic palette
    pal_name = 'Unknown'
    if result and not basic_palette:
        result, pal_name, basic_palette = _find_basic_palette(result)

    try:
        import webcolors
    except ImportError:
        webcolors = None

    log.debug(
        f'{result!r} ({os_name}, TERM={env.TERM or ""}, '
        f'COLORTERM={env.COLORTERM or ""}, ANSICON={env.ANSICON}, '
        f'webcolors={bool(webcolors)}, basic_palette={pal_name})'
    )
    return (result, basic_palette)
473983
def _find_palettes(stream):
    '''  '''
    chosen = choose_palette(stream=stream)
    palettes = get_available_palettes(chosen)
    fg = ForegroundPalette(palettes=palettes)
    fx = EffectsPalette(palettes=palettes)
    return fg, fx, chosen
1060775
def plotER(self,*args,**kwargs):
        
        if kwargs.pop('normed',False):
            kwargs['d2']= 'ERnorm'
        else:
            kwargs['d2']= 'ER'
        return self.plot(*args,**kwargs)
814516
def show_grid(self, **kwargs):
        
        kwargs.setdefault('grid', 'back')
        kwargs.setdefault('location', 'outer')
        kwargs.setdefault('ticks', 'both')
        return self.show_bounds(**kwargs)
256851
def check_arguments(cls, conf):
        
        # Checking the specified list of basic health monitor plugins, which
        # should be run by the multi plugin.
        if not conf.get('multi_plugins'):
            raise ArgsError("A specification of health monitor plugins "
                            "is required (--multi_plugins).")

        # Now check parameters for all sub-plugins. We use the list of classes
        # for sub-plugins that we discovered earlier while adding parameters
        # for those sub-plugins.
        for mpc in cls.multi_plugin_classes:
            mpc.check_arguments(conf)
1270380
def __args_check(self, valid, args=None, kwargs=None):
        '''
        
        '''
        if not isinstance(valid, list):
            valid = [valid]
        for cond in valid:
            if not isinstance(cond, dict):
                # Invalid argument
                continue
            # whitelist args, kwargs
            cond_args = cond.get('args', [])
            good = True
            for i, cond_arg in enumerate(cond_args):
                if args is None or len(args) <= i:
                    good = False
                    break
                if cond_arg is None:  # None == '.*' i.e. allow any
                    continue
                if not self.match_check(cond_arg, six.text_type(args[i])):
                    good = False
                    break
            if not good:
                continue
            # Check kwargs
            cond_kwargs = cond.get('kwargs', {})
            for k, v in six.iteritems(cond_kwargs):
                if kwargs is None or k not in kwargs:
                    good = False
                    break
                if v is None:  # None == '.*' i.e. allow any
                    continue
                if not self.match_check(v, six.text_type(kwargs[k])):
                    good = False
                    break
            if good:
                return True
        return False
1089218
function (options) {
		var ret,
			series = this.series,
			pointArrayMap = series.pointArrayMap || ['y'],
			valueCount = pointArrayMap.length,
			firstItemType,
			i = 0,
			j = 0;

		if (typeof options === 'number' || options === null) {
			ret = { y: options };

		} else if (isArray(options)) {
			ret = {};
			// with leading x value
			if (options.length > valueCount) {
				firstItemType = typeof options[0];
				if (firstItemType === 'string') {
					ret.name = options[0];
				} else if (firstItemType === 'number') {
					ret.x = options[0];
				}
				i++;
			}
			while (j < valueCount) {
				ret[pointArrayMap[j++]] = options[i++];
			}			
		} else if (typeof options === 'object') {
			ret = options;

			// This is the fastest way to detect if there are individual point dataLabels that need 
			// to be considered in drawDataLabels. These can only occur in object configs.
			if (options.dataLabels) {
				series._hasPointLabels = true;
			}

			// Same approach as above for markers
			if (options.marker) {
				series._hasPointMarkers = true;
			}
		}
		return ret;
	}
30811
def _get_cmap(kwargs: dict) -> colors.Colormap:
    
    from matplotlib.colors import ListedColormap

    cmap = kwargs.pop("cmap", default_cmap)
    if isinstance(cmap, list):
        return ListedColormap(cmap)
    if isinstance(cmap, str):
        try:
            cmap = plt.get_cmap(cmap)
        except BaseException as exc:
            try:
                # Try to use seaborn palette
                import seaborn as sns
                sns_palette = sns.color_palette(cmap, n_colors=256)
                cmap = ListedColormap(sns_palette, name=cmap)
            except ImportError:
                raise exc
    return cmap
865046
def is_argument(self, name):
        
        if name == self.vararg:
            return True
        if name == self.kwarg:
            return True
        return (
            self.find_argname(name, True)[1] is not None
            or self.kwonlyargs
            and _find_arg(name, self.kwonlyargs, True)[1] is not None
        )
866175
def colors(self, p_hint_possible=True):
        
        lookup = {
            'false': 0,
            'no': 0,
            '0': 0,
            '1': 16,
            'true': 16,
            'yes': 16,
            '16': 16,
            '256': 256,
        }

        try:
            forced = self.cp.get('topydo', 'force_colors') == '1'
        except ValueError:
            forced = self.defaults['topydo']['force_colors'] == '1'

        try:
            colors = lookup[self.cp.get('topydo', 'colors').lower()]  # pylint: disable=no-member
        except ValueError:
            colors = lookup[self.defaults['topydo']['colors'].lower()]  # pylint: disable=no-member
        except KeyError:
            # for invalid values or 'auto'
            colors = 16 if p_hint_possible else 0

        # disable colors when no colors are enforced on the commandline and
        # color support is determined automatically
        return 0 if not forced and not p_hint_possible else colors
215964
def handle_program_options():
    """"""
    parser = argparse.ArgumentParser(description="Calculate the alpha diversity\
                                     of a set of samples using one or more \
                                     metrics and output a kernal density \
                                     estimator-smoothed histogram of the \
                                     results.")
    parser.add_argument("-m", "--map_file",
                        help="QIIME mapping file.")
    parser.add_argument("-i", "--biom_fp",
                        help="Path to the BIOM table")
    parser.add_argument("-c", "--category",
                        help="Specific category from the mapping file.")
    parser.add_argument("-d", "--diversity", default=["shannon"], nargs="+",
                        help="The alpha diversity metric. Default \
                             value is 'shannon', which will calculate the Shannon\
                             entropy. Multiple metrics can be specified (space separated).\
                             The full list of metrics is available at:\
                             http://scikit-bio.org/docs/latest/generated/skbio.diversity.alpha.html.\
                             Beta diversity metrics will be supported in the future.")
    parser.add_argument("--x_label", default=[None], nargs="+",
                        help="The name of the diversity metric to be displayed on the\
                        plot as the X-axis label. If multiple metrics are specified,\
                        then multiple entries for the X-axis label should be given.")
    parser.add_argument("--color_by",
                        help="A column name in the mapping file containing\
                              hexadecimal (#FF0000) color values that will\
                              be used to color the groups. Each sample ID must\
                              have a color entry.")
    parser.add_argument("--plot_title", default="",
                        help="A descriptive title that will appear at the top \
                        of the output plot. Surround with quotes if there are\
                        spaces in the title.")
    parser.add_argument("-o", "--output_dir", default=".",
                        help="The directory plots will be saved to.")
    parser.add_argument("--image_type", default="png",
                        help="The type of image to save: png, svg, pdf, eps, etc...")
    parser.add_argument("--save_calculations",
                        help="Path and name of text file to store the calculated "
                        "diversity metrics.")
    parser.add_argument("--suppress_stats", action="store_true", help="Do not display "
                        "significance testing results which are shown by default.")
    parser.add_argument("--show_available_metrics", action="store_true",
                        help="Supply this parameter to see which alpha diversity metrics "
                             " are available for usage. No calculations will be performed"
                             " if this parameter is provided.")
    return parser.parse_args()
1102586
function SetErrorBarColors($which_data) {

   //Set the data to be displayed in a particular color

   if ($which_data) {
    $this->error_bar_color = $which_data;  //an array
    unset($this->ndx_error_bar_color);
    reset($this->error_bar_color);  //data_color can be an array of colors, one for each thing plotted
    $i = 0;
    while (list(, $col) = each($this->error_bar_color)) {
      $this->ndx_error_bar_color[$i] = $this->SetIndexColor($col);
      $i++;
    }
    return true;
    }
    return false;
  }
114972
function checkPaletteValid(name, map) {
    var missingColors = VALID_HUE_VALUES.filter(function(field) {
      return !map[field];
    });
    if (missingColors.length) {
      throw new Error("Missing colors %1 in palette %2!"
                      .replace('%1', missingColors.join(', '))
                      .replace('%2', name));
    }

    return map;
  }