Build an edge predicate for edges whose annotations are super-dictionaries of the given dictionary.

    If no annotations are given, will always evaluate to true.

    :param annotations: The annotation query dict to match
974307
def build_annotation_dict_all_filter(annotations: Mapping[str, Iterable[str]]) -> EdgePredicate:
    
    if not annotations:
        return keep_edge_permissive

    @edge_predicate
    def annotation_dict_all_filter(edge_data: EdgeData) -> bool:
        """Check if the all of the annotations in the enclosed query match."""
        return _annotation_dict_all_filter(edge_data, query=annotations)

    return annotation_dict_all_filter
1071417
def _annotation_iter_helper(graph) -> Iterable[str]:
    
    return (
        key
        for _, _, data in graph.edges(data=True)
        if ANNOTATIONS in data
        for key in data[ANNOTATIONS]
    )
843970
def predicates(graph):
    
    seen = set()

    def _traverse(binding):
        if binding.path in seen:
            return
        seen.add(binding.path)

        if binding.is_object:
            for prop in binding.properties:
                yield (binding.path, prop.name, tuple(prop.types))
                for pred in _traverse(prop):
                    yield pred
        elif binding.is_array:
            for item in binding.items:
                for pred in _traverse(item):
                    yield pred

    schemas = graph.aliases.values()
    schemas.extend(graph.resolver.store)
    for schema_uri in graph.aliases.values():
        binding = graph.get_binding(schema_uri, None)
        for pred in _traverse(binding):
            if pred not in seen:
                yield pred
                seen.add(pred)
791078
def annotate(self, *args, **kwargs):
        
        obj = self._clone()

        for arg in args:
            if isinstance(arg, Facet):
                obj._facets.append(arg)
            elif isinstance(arg, six.string_types):
                obj._facets.append(TermFacet(arg.replace("__", ".")))
            elif isinstance(arg, Agg):
                obj._aggs.append(arg)
            elif isinstance(arg, six.string_types):
                obj._facets.append(TermFacet(arg.replace("__", ".")))
            else:
                raise NotImplementedError("invalid type")


        # Add the aggregates/facet to the query
        for name, field in kwargs.items():
            obj._facets.append(TermFacet(field=field.replace("__", "."), name=name.replace("__", ".")))
            obj._aggs.append(TermsAgg(field=field.replace("__", "."), name=name.replace("__", ".")))
        return obj
566378
def all_edges_with_verts(self, v_indices, as_boolean=False):
        '''
        
        '''
        included_vertices = np.zeros(self.v.shape[0], dtype=bool)
        included_vertices[v_indices] = True
        edges_with_verts = included_vertices[self.e].all(axis=1)
        if as_boolean:
            return edges_with_verts
        return np.nonzero(edges_with_verts)[0]
282524
def annotation_rows(prefix, annotations):
    
    ncol = len(annotations['Column Name'])
    return {name.replace(prefix, '', 1) : values + [''] * (ncol - len(values))
            for name, values in annotations.items() if name.startswith(prefix)}
853307
def get_annotations(self):
        
        try:
            obj_list = self.__dict__['annotations']
            return [Annotation(i) for i in obj_list]
        except KeyError:
            self._lazy_load()
            obj_list = self.__dict__['annotations']
            return [Annotation(i) for i in obj_list]
1195888
def build_upstream_edge_predicate(nodes: Iterable[BaseEntity]) -> EdgePredicate:
    """"""
    nodes = set(nodes)

    def upstream_filter(graph: BELGraph, u: BaseEntity, v: BaseEntity, k: str) -> bool:
        """Pass for relations for which one of the given nodes is the object."""
        return v in nodes and graph[u][v][k][RELATION] in CAUSAL_RELATIONS

    return upstream_filter
741348
def get_singleton(cls, annotators=None, **options):
        
        if annotators is not None:
            annotators = tuple(annotators)
        if annotators not in cls._singletons:
            cls._singletons[annotators] = cls(annotators, **options)
        return cls._singletons[annotators]
277740
@SuppressWarnings({"unchecked", "vararg"})
    public static Filter<InstanceField> annotatedBy(final Class<? extends Annotation>... annotations) {
        return new Filter<InstanceField>() {
            public boolean isOut(InstanceField instanceField) {
                Checks.checkNotNull(annotations, "Provide at least one annotation class");

                for (Class<? extends Annotation> annotation : annotations) {
                    if(instanceField.isAnnotatedBy(annotation)) {
                        return false;
                    }
                }
                return true;
            }
        };
    }
553938
private ImmutableSet<ASTAnnotation> getAnnotations(Annotation[] annotations) {

        ImmutableSet.Builder<ASTAnnotation> astAnnotationBuilder = ImmutableSet.builder();

        for (Annotation annotation : annotations) {
            astAnnotationBuilder.add(getAnnotation(annotation));
        }

        return astAnnotationBuilder.build();
    }
1021885
def _preprocess_edges_for_pydot(edges_with_data):
    """'"""
    for (source, target, attrs) in edges_with_data:
        if 'label' in attrs:
            yield (quote_for_pydot(source), quote_for_pydot(target),
                   {'label': quote_for_pydot(attrs['label'])})
        else:
            yield (quote_for_pydot(source), quote_for_pydot(target), {})
382813
def add_annotation_value(graph, annotation, value):
    
    if annotation not in graph.defined_annotation_keywords:
        raise ValueError('annotation not defined: {}'.format(annotation))

    for u, v, k in graph.edges(keys=True):
        if ANNOTATIONS not in graph[u][v][k]:
            continue

        if annotation not in graph[u][v][k][ANNOTATIONS]:
            graph[u][v][k][ANNOTATIONS][annotation] = {}

        graph[u][v][k][ANNOTATIONS][annotation][value] = True
1261507
def filter_edges(graph: BELGraph, edge_predicates: EdgePredicates) -> EdgeIterator:
    
    compound_edge_predicate = and_edge_predicates(edge_predicates=edge_predicates)
    for u, v, k in graph.edges(keys=True):
        if compound_edge_predicate(graph, u, v, k):
            yield u, v, k
656407
def p_annotation(self, p):
        ''''''

        if len(p) == 4:
            p[0] = ast.Annotation(p[1], p[3], lineno=p.lineno(1))
        else:
            p[0] = ast.Annotation(p[1], True, lineno=p.lineno(1))
116711
def get_annotation_values(graph, annotation: str) -> Set[str]:
    
    return set(iter_annotation_values(graph, annotation))
1021554
public static <T extends AnnotatedElement> Predicate<T> elementAnnotatedWith(Class<? extends Annotation>
            annotationClass, boolean includeMetaAnnotations) {
        return candidate -> {
            if (candidate == null) {
                return false;
            }
            Annotations.OnClass onClass = Annotations.on(candidate);
            if (includeMetaAnnotations) {
                onClass.includingMetaAnnotations();
            }
            return onClass.find(annotationClass).isPresent();
        };
    }