Check that all dicts within a list are identical.
436520
def validate_list_of_identical_dicts(self, list_of_dicts):
        """"""
        hashes = []
        for _dict in list_of_dicts:
            hashes.append(hash(frozenset(_dict.items())))

        self.log.debug('Hashes: {}'.format(hashes))
        if len(set(hashes)) == 1:
            self.log.debug('Dicts within list are identical')
        else:
            return 'Dicts within list are not identical'

        return None
402887
def how_similar_dicts(dict1, dict2):
    
    values = []
    for k in dict1:  # iterate keys
        if k in dict2 and dict1[k] and dict2[k]:
            values.append(
                how_similar_are(str(dict1[k]), str(dict2[k]))
            )
    return np.mean(values)
873113
def merge_dicts(dicts, deepcopy=False):
    
    assert isinstance(dicts, list) and all(isinstance(d, dict) for d in dicts)
    return dict(chain(*[copy.deepcopy(d).items() if deepcopy else d.items()
                        for d in dicts]))
627783
def uniqueify(my_list: Any) -> List[Any]:
    """"""
    if sys.version_info >= (3, 6):
        # An implementation specific detail of py3.6 is the retention of order
        # within a dictionary. In py3.7 this becomes the documented behaviour.
        return list(dict.fromkeys(my_list))

    # Slower method of order preserving unique list in older python versions
    seen = set()
    return [x for x in my_list if x not in seen and not seen.add(x)]
407129
async def check(self, *args):
        
        data = {}
        for target in self.targets:
            result = await target(*args)
            if not result:
                return False
            if isinstance(result, dict):
                data.update(result)
        if not data:
            return True
        return data
1266739
def index_lists_equal(a: List[Index], b: List[Index]) -> bool:
    
    n = len(a)
    if len(b) != n:
        return False
    for i in range(n):
        if not indexes_equal(a[i], b[i]):
            log.debug("Mismatch: {!r} != {!r}", a[i], b[i])
            return False
    return True
790548
def identical_blocks(self):
        
        identical_blocks = []
        for (func_a, func_b) in self.function_matches:
            identical_blocks.extend(self.get_function_diff(func_a, func_b).identical_blocks)
        return identical_blocks
543662
def issuperset(self, items):
        
        return all(_compat.map(self._seen.__contains__, items))
747649
def _recursive_compare(v1, v2):
    '''
    
    '''
    if isinstance(v1, list):
        if v2 is None:
            v2 = []
        if len(v1) != len(v2):
            return False
        v1.sort(key=_id_or_key)
        v2.sort(key=_id_or_key)
        for x, y in zip(v1, v2):
            if not _recursive_compare(x, y):
                return False
        return True
    elif isinstance(v1, dict):
        if v2 is None:
            v2 = {}
        v1 = dict(v1)
        v2 = dict(v2)
        if sorted(v1) != sorted(v2):
            return False
        for k in v1:
            if not _recursive_compare(v1[k], v2[k]):
                return False
        return True
    else:
        return v1 == v2
489727
def dict_update_overwrite_check(base, fresh):
    

    result = [
        (key, base[key], fresh[key])
        for key in set(base.keys()) & set(fresh.keys())
        if base[key] != fresh[key]
    ]
    base.update(fresh)
    return result
930574
def clean_dict(d):
    

    if not isinstance(d, (dict, list)):
        return d
    if isinstance(d, list):
        return [v for v in (clean_dict(v) for v in d) if v]
    return OrderedDict(
        [(k, v) for k, v in ((k, clean_dict(v)) for k, v in list(d.items())) if v]
    )
105278
def identical(self, other):
        
        return (self.equals(other) and
                all((getattr(self, c, None) == getattr(other, c, None)
                     for c in self._comparables)) and
                type(self) == type(other))
763621
def compare_dict(da, db):
    
    sa = set(da.items())
    sb = set(db.items())
    
    diff = sa & sb
    return dict(sa - diff), dict(sb - diff)
1216750
def all_versions_equal(self, versions):  # type: (Dict[str,str]) -> bool
        
        if len(versions) <= 1:
            return True

        semver = None
        for key, version in versions.items():
            if semver is None:
                try:
                    semver, _, __ = version_object_and_next(version)
                except ValueError:
                    logger.error("Invalid version at:" + unicode((key, version)))
                    return False
                continue
            try:
                version_as_version, _, __ = version_object_and_next(version)
            except:
                return False
            if version_as_version != semver:
                return False
        return True
136794
def dict_diff(dicts):
    
    diff_keys = set()

    for k in union(set(d.keys()) for d in dicts):
        values = []
        for d in dicts:
            if k not in d:
                diff_keys.add(k)
                break
            else:
                values.append(d[k])
                if nunique(values) > 1:
                    diff_keys.add(k)
                    break

    return [dict_subset(d, diff_keys) for d in dicts]
1125627
def compare_dicts(old_full, new_full, old_data, new_data, depth=0):
    
    depth = depth + 1
    indent = "  "*depth

    # Print with an indentation matching the nested-dictionary depth
    def my_print(str):
        print("{}{}".format(indent, str))

    old_keys = list(old_data.keys())
    # Compare data key by key, in *this* dictionary level
    # Note: since we're comparing by keys explicity, order doesnt matter
    for key in old_keys:
        # Remove elements as we go
        old_vals = old_data.pop(key)
        # Current key
        my_print("{}".format(key))
        # If `new_data` doesnt also have this key, return False
        if key not in new_data:
            my_print("Key '{}' not in new_data.".format(key))
            my_print("Old:")
            my_print(pprint(new_data))
            my_print("New:")
            my_print(pprint(new_data))
            return False

        # If it does have the key, extract the values (remove as we go)
        new_vals = new_data.pop(key)
        # If these values are a sub-dictionary, compare those
        if isinstance(old_vals, dict) and isinstance(new_vals, dict):
            # If the sub-dictionary are not the same, return False
            if not compare_dicts(old_full, new_full, old_vals, new_vals, depth=depth):
                return False
        # If these values are a list of sub-dictionaries, compare each of those
        elif (isinstance(old_vals, list) and isinstance(old_vals[0], dict) and
              isinstance(old_vals, list) and isinstance(old_vals[0], dict)):
            for old_elem, new_elem in zip_longest(old_vals, new_vals):
                # If one or the other has extra elements, print message, but
                # continue on
                if old_elem is None or new_elem is None:
                    my_print("Missing element!")
                    my_print("\tOld: '{}'".format(old_elem))
                    my_print("\tNew: '{}'".format(new_elem))
                else:
                    if not compare_dicts(old_full, new_full, old_elem, new_elem, depth=depth):
                        return False

        # At the lowest-dictionary level, compare the values themselves
        else:
            # Turn everything into a list for convenience (most things should be
            # already)
            if  (not isinstance(old_vals, list) and
                 not isinstance(new_vals, list)):
                old_vals = [old_vals]
                new_vals = [new_vals]

            # Sort both lists
            old_vals = sorted(old_vals)
            new_vals = sorted(new_vals)

            for oldv, newv in zip_longest(old_vals, new_vals):
                # If one or the other has extra elements, print message, but
                # continue on
                if oldv is None or newv is None:
                    my_print("Missing element!")
                    my_print("\tOld: '{}'".format(oldv))
                    my_print("\tNew: '{}'".format(newv))
                # If values match, continue
                elif oldv == newv:
                    my_print("Good Match: '{}'".format(key))
                # If values dont match, return False
                else:
                    my_print("Bad  Match: '{}'".format(key))
                    my_print("\tOld: '{}'".format(oldv))
                    my_print("\tNew: '{}'".format(newv))
                    return False

    return True
75040
def is_in_list(self, plane_list):
        
        for plane in plane_list:
            if self.is_same_plane_as(plane):
                return True
        return False