reverse convert a missing indexer, which is a dict
    return the scalar indexer and a boolean indicating if we converted
483405
def convert_missing_indexer(indexer):
    

    if isinstance(indexer, dict):

        # a missing key (but not a tuple indexer)
        indexer = indexer['key']

        if isinstance(indexer, bool):
            raise KeyError("cannot use a single bool to index into setitem")
        return indexer, True

    return indexer, False
255395
def _parse_tuple(tup):
    
    row_loc, col_loc = slice(None), slice(None)

    if is_tuple(tup):
        row_loc = tup[0]
        if len(tup) == 2:
            col_loc = tup[1]
        if len(tup) > 2:
            raise IndexingError("Too many indexers")
    else:
        row_loc = tup

    ndim = _compute_ndim(row_loc, col_loc)
    row_scaler = is_scalar(row_loc)
    col_scaler = is_scalar(col_loc)
    row_loc = [row_loc] if row_scaler else row_loc
    col_loc = [col_loc] if col_scaler else col_loc

    return row_loc, col_loc, ndim, row_scaler, col_scaler
728536
def numpy_scalar_to_python(scalar):
    
    scalar_type = type(scalar)
    if np.issubclass_(scalar_type, np.float_):
        return float(scalar)
    elif np.issubclass_(scalar_type, np.int_):
        return int(scalar)
    return scalar
711797
def inverse(self):
        
        result = G2Element()
        librelic.g2_neg_abi(byref(result), byref(self))
        return result
1288824
def _parse_scalars(scalars):
        
        scalar_dict = {}

        # Scalars are defined in a fixed two-level hierarchy within the definition file.
        # The first level contains the category name, while the second level contains the
        # probe name (e.g. "category.name: probe: ...").
        for category_name in scalars:
            category = scalars[category_name]

            for probe_name in category:
                # We found a scalar type. Go ahead and parse it.
                scalar_definition = category[probe_name]
                # We pass |strict_type_checks=False| as we don't want to do any check
                # server side. This includes skipping the checks for the required keys.
                scalar_info = ScalarType(category_name, probe_name, scalar_definition,
                                         strict_type_checks=False)
                scalar_dict[scalar_info.label] = scalar_info

        return scalar_dict
138346
def _convert_types(self, a):
        
        # No conversion for scalar type
        if a.dtype != 'object':
            return a, None

        # We can't infer the type of an empty array, so just
        # assume strings
        if len(a) == 0:
            return a.astype('U1'), None

        # Compute a mask of missing values. Replace NaNs and Nones with
        # empty strings so that type inference has a chance.
        mask = pd.isnull(a)
        if mask.sum() > 0:
            a = a.copy()
            np.putmask(a, mask, '')
        else:
            mask = None

        if infer_dtype(a, skipna=False) == 'mixed':
            # assume its a string, otherwise raise an error
            try:
                a = np.array([s.encode('ascii') for s in a])
                a = a.astype('O')
            except:
                raise ValueError("Column of type 'mixed' cannot be converted to string")

        type_ = infer_dtype(a, skipna=False)
        if type_ in ['unicode', 'string']:
            max_len = max_len_string_array(a)
            return a.astype('U{:d}'.format(max_len)), mask
        else:
            raise ValueError('Cannot store arrays with {} dtype'.format(type_))
687817
def as_indexable(array):
    
    if isinstance(array, ExplicitlyIndexed):
        return array
    if isinstance(array, np.ndarray):
        return NumpyIndexingAdapter(array)
    if isinstance(array, pd.Index):
        return PandasIndexAdapter(array)
    if isinstance(array, dask_array_type):
        return DaskIndexingAdapter(array)
    raise TypeError('Invalid array type: {}'.format(type(array)))
1085630
def _convert_key(self, key, is_setter=False):
        
        for a, i in zip(self.obj.axes, key):
            if not is_integer(i):
                raise ValueError("iAt based indexing can only have integer "
                                 "indexers")
        return key
674446
def _get_join_indexers(self):
        

        def flip(xs):
            """ unlike np.transpose, this returns an array of tuples """
            labels = list(string.ascii_lowercase[:len(xs)])
            dtypes = [x.dtype for x in xs]
            labeled_dtypes = list(zip(labels, dtypes))
            return np.array(lzip(*xs), labeled_dtypes)

        # values to compare
        left_values = (self.left.index.values if self.left_index else
                       self.left_join_keys[-1])
        right_values = (self.right.index.values if self.right_index else
                        self.right_join_keys[-1])
        tolerance = self.tolerance

        # we require sortedness and non-null values in the join keys
        msg_sorted = "{side} keys must be sorted"
        msg_missings = "Merge keys contain null values on {side} side"

        if not Index(left_values).is_monotonic:
            if isnull(left_values).any():
                raise ValueError(msg_missings.format(side='left'))
            else:
                raise ValueError(msg_sorted.format(side='left'))

        if not Index(right_values).is_monotonic:
            if isnull(right_values).any():
                raise ValueError(msg_missings.format(side='right'))
            else:
                raise ValueError(msg_sorted.format(side='right'))

        # initial type conversion as needed
        if needs_i8_conversion(left_values):
            left_values = left_values.view('i8')
            right_values = right_values.view('i8')
            if tolerance is not None:
                tolerance = tolerance.value

        # a "by" parameter requires special handling
        if self.left_by is not None:
            # remove 'on' parameter from values if one existed
            if self.left_index and self.right_index:
                left_by_values = self.left_join_keys
                right_by_values = self.right_join_keys
            else:
                left_by_values = self.left_join_keys[0:-1]
                right_by_values = self.right_join_keys[0:-1]

            # get tuple representation of values if more than one
            if len(left_by_values) == 1:
                left_by_values = left_by_values[0]
                right_by_values = right_by_values[0]
            else:
                left_by_values = flip(left_by_values)
                right_by_values = flip(right_by_values)

            # upcast 'by' parameter because HashTable is limited
            by_type = _get_cython_type_upcast(left_by_values.dtype)
            by_type_caster = _type_casters[by_type]
            left_by_values = by_type_caster(left_by_values)
            right_by_values = by_type_caster(right_by_values)

            # choose appropriate function by type
            func = _asof_by_function(self.direction)
            return func(left_values,
                        right_values,
                        left_by_values,
                        right_by_values,
                        self.allow_exact_matches,
                        tolerance)
        else:
            # choose appropriate function by type
            func = _asof_function(self.direction)
            return func(left_values,
                        right_values,
                        self.allow_exact_matches,
                        tolerance)
412574
def _reassign_quantity_indexer(data, indexers):
    """"""
    def _to_magnitude(val, unit):
        try:
            return val.to(unit).m
        except AttributeError:
            return val

    for coord_name in indexers:
        # Handle axis types for DataArrays
        if (isinstance(data, xr.DataArray) and coord_name not in data.dims
                and coord_name in readable_to_cf_axes):
            axis = coord_name
            coord_name = next(data.metpy.coordinates(axis)).name
            indexers[coord_name] = indexers[axis]
            del indexers[axis]

        # Handle slices of quantities
        if isinstance(indexers[coord_name], slice):
            start = _to_magnitude(indexers[coord_name].start, data[coord_name].metpy.units)
            stop = _to_magnitude(indexers[coord_name].stop, data[coord_name].metpy.units)
            step = _to_magnitude(indexers[coord_name].step, data[coord_name].metpy.units)
            indexers[coord_name] = slice(start, stop, step)

        # Handle quantities
        indexers[coord_name] = _to_magnitude(indexers[coord_name],
                                             data[coord_name].metpy.units)

    return indexers
1027989
def es_indexers(cls, base_class, **kwargs):
        
        indexer_list = []
        ranges = cls.rdfs_range # pylint: disable=no-member
        rng_defs = get_prop_range_defs(cls.class_names, cls.kds_rangeDef)
        rng_def = get_prop_range_def(rng_defs)
        if rng_def.get("kds_esIndexClass"):
            ranges = rng_def['kds_esIndexClass'].copy()
        idx_types = get_idx_types(rng_def, ranges)
        if 'es_Ignored' in idx_types:
            return []
        if 'es_Nested' in idx_types:
            if (kwargs.get('depth', 0) >= 1 and \
                    kwargs.get('class') == ranges[0]) or \
                    kwargs.get('depth', 0) > 2:
                return []
            indexer_list = getattr(MODULE.rdfclass,
                                   ranges[0]).es_indexers(base_class,
                                                          'es_Nested',
                                                          **kwargs)
        return indexer_list
1353288
def get_index(self, key: Hashable) -> pd.Index:
        
        if key not in self.dims:
            raise KeyError(key)

        try:
            return self.indexes[key]
        except KeyError:
            # need to ensure dtype=int64 in case range is empty on Python 2
            return pd.Index(range(self.sizes[key]), name=key, dtype=np.int64)
733300
def _reverse_lookup(dictionary, value):
    '''
    
    '''
    value_index = -1
    for idx, dict_value in enumerate(dictionary.values()):
        if type(dict_value) == list:
            if value in dict_value:
                value_index = idx
                break
        elif value == dict_value:
            value_index = idx
            break

    return list(dictionary)[value_index]
929229
def _replace_scalar(self, scalar):
        
        if not is_arg_scalar(scalar):
            return scalar
        name = scalar[1:]
        return self.get_scalar_value(name)
371642
def get_index(self, key):
        
        try:
            return self[self.index_lookup.get(key)]

        except TypeError:
            raise KeyError
384179
def _convert_to_indexer(self, obj, axis=None, is_setter=False):
        
        if axis is None:
            axis = self.axis or 0

        # make need to convert a float key
        if isinstance(obj, slice):
            return self._convert_slice_indexer(obj, axis)

        elif is_float(obj):
            return self._convert_scalar_indexer(obj, axis)

        try:
            self._validate_key(obj, axis)
            return obj
        except ValueError:
            raise ValueError("Can only index by location with "
                             "a [{types}]".format(types=self._valid_types))
630983
function indexer ( str, find ) {
    return ( str.indexOf( find ) > 0 ) ? str.indexOf( find ) : false;
  }