compare triple to ontology, return error or None
337287
def _check_triple(self, triple):
        """"""
        subj, pred, obj = triple

        if self._should_ignore_predicate(pred):
            log.info("Ignoring triple with predicate '{}'"
                     .format(self._field_name_from_uri(pred)))
            return

        classes = []
        log.warning("Possible member %s found" % pred)

        pred = self._expand_qname(pred)

        if self._namespace_from_uri(pred) not in self.allowed_namespaces:
            log.info("Member %s does not use an allowed namespace", pred)
            return

        instanceof = self._is_instance((subj, pred, obj))
        if type(instanceof) == rt.URIRef:
            instanceof = self._expand_qname(instanceof)

        if hasattr(self.schema_def, "attributes_by_class") and \
           not self.schema_def.attributes_by_class:
            log.info("Parsed ontology not found. Parsing...")
            self.schema_def.parse_ontology()

        class_invalid = self._validate_class(instanceof)
        if class_invalid:
            log.warning("Invalid class %s" % instanceof)
            return class_invalid
        # TODO - the above sometimes fails when a single object has more than
        # one rdfa type (eg <span property="schema:creator rnews:creator"
        # typeof="schema:Person rnews:Person">
        # Graph chooses the type in an arbitrary order, so it's unreliable
        # eg: http://semanticweb.com/the-impact-of-rdfa_b35003

        classes = self._superclasses_for_subject(self.graph, instanceof)
        classes.append(instanceof)

        member_invalid = self._validate_member(pred, classes, instanceof)
        if member_invalid:
            log.warning("Invalid member of class")
            return member_invalid

        dupe_invalid = self._validate_duplication((subj, pred), instanceof)
        if dupe_invalid:
            log.warning("Duplication found")
            return dupe_invalid

        # collect a list of checked attributes
        self.checked_attributes.append((subj, pred))
        log.warning("successfully validated triple, no errors")
        return
850425
public void prapareForInferred() {
        log.info("Adding additional axioms to calculate inferred axioms");
        int key = 0;
        
        int numNf3 = 0;
        int numNf8 = 0;
        for(final IntIterator itr = ontologyNF2.keyIterator(); itr.hasNext();) {
            MonotonicCollection<NF2> nf2s = ontologyNF2.get(itr.next());
            for(final Iterator<NF2> itr2 = nf2s.iterator(); itr2.hasNext();) {
                NF2 nf2 = itr2.next();
                
                // TODO remove
                if(factory.lookupConceptId(nf2.lhsA).equals("287402001")) {
                    System.err.println(nf2);
                    
                    key = nf2.rhsB;
                    
                }
                // TODO remove
                
                // The problem is likely to be in this method call!
                if(!containsExistentialInNF3s(nf2.rhsR, nf2.rhsB, nf2.lhsA)) {
                    NF3 nnf = NF3.getInstance(nf2.rhsR, nf2.rhsB, factory.getConcept(new Existential(nf2.rhsR, 
                            new au.csiro.snorocket.core.model.Concept(nf2.rhsB))));
                    //as.addAxiom(nnf); // Needed for incremental
                    addTerm(nnf);
                    numNf3++;
                    
                    
                    if(factory.lookupConceptId(nf2.lhsA).equals("287402001")) {
                        System.err.println("Added "+nnf);
                    }
                    
                    
                }
            }
        }
        
        System.out.println(key);
        // TODO remove
        for(NF2 nn : ontologyNF2.get(key)) {
            System.err.println(nn);
        }
        // TODO remove
        
        for(final IntIterator itr = ontologyNF7.keyIterator(); itr.hasNext();) {
            MonotonicCollection<NF7> nf7s = ontologyNF7.get(itr.next());
            for(final Iterator<NF7> itr2 = nf7s.iterator(); itr2.hasNext();) {
                NF7 nf7 = itr2.next();
                
                Datatype rhs = nf7.getD();
                if(!containsDatatypeInNF8s(rhs)) {
                    NF8 nnf = NF8.getInstance(rhs, factory.getConcept(rhs));
                    //as.addAxiom(nnf); // Needed for incremental
                    addTerm(nnf);
                    numNf8++;
                }
            }
        }
        
        log.info("Added "+numNf3+" NF3 axioms and "+numNf8+" NF8 axioms.");
        
        // FIXME: there seems to be an issue with incremental classification and these axioms. For now these will be
        // excluded because there is no need for these for SNOMED CT and AMT.    
        
        /*
        // try introducing a new axiom for each NF1b new concept [ A1 + A2 - add the conjunction object as key
        for(NF1b nf1b : getNF1bs()) {
            Object a1 = factory.lookupConceptId(nf1b.lhsA1());
            Object a2 = factory.lookupConceptId(nf1b.lhsA2());
            
            AbstractConcept ac1 = null;
            AbstractConcept ac2 = null;
            
            // We assume these are either Strings or Existentials
            if(a1 instanceof String) {
                ac1 = new au.csiro.snorocket.core.model.Concept(nf1b.lhsA1());
            } else {
                // This will throw a ClassCastException if an object outside of the internal model is found
                ac1 = (AbstractConcept) a1;
            }
            
            if(a2 instanceof String) {
                ac2 = new au.csiro.snorocket.core.model.Concept(nf1b.lhsA2());
            } else {
                // This will throw a ClassCastException if an object outside of the internal model is found
                ac2 = (AbstractConcept) a2;
            }
            
            Conjunction con = new Conjunction(new AbstractConcept[] { ac1, ac2 });
            int nid = factory.getConcept(con);
            NF1a nf1a1 = NF1a.getInstance(nid, nf1b.lhsA1());
            NF1a nf1a2 = NF1a.getInstance(nid, nf1b.lhsA2());
            addTerm(nf1a1);
            addTerm(nf1a2);
        }
        */
    }
234199
def assertrepr_compare(config, op, left, right):
    """"""
    width = 80 - 15 - len(op) - 2  # 15 chars indentation, 1 space around op
    left_repr = py.io.saferepr(left, maxsize=int(width//2))
    right_repr = py.io.saferepr(right, maxsize=width-len(left_repr))

    summary = u('%s %s %s') % (ecu(left_repr), op, ecu(right_repr))

    issequence = lambda x: (isinstance(x, (list, tuple, Sequence)) and
                            not isinstance(x, basestring))
    istext = lambda x: isinstance(x, basestring)
    isdict = lambda x: isinstance(x, dict)
    isset = lambda x: isinstance(x, (set, frozenset))

    def isiterable(obj):
        try:
            iter(obj)
            return not istext(obj)
        except TypeError:
            return False

    verbose = config.getoption('verbose')
    explanation = None
    try:
        if op == '==':
            if istext(left) and istext(right):
                explanation = _diff_text(left, right, verbose)
            else:
                if issequence(left) and issequence(right):
                    explanation = _compare_eq_sequence(left, right, verbose)
                elif isset(left) and isset(right):
                    explanation = _compare_eq_set(left, right, verbose)
                elif isdict(left) and isdict(right):
                    explanation = _compare_eq_dict(left, right, verbose)
                if isiterable(left) and isiterable(right):
                    expl = _compare_eq_iterable(left, right, verbose)
                    if explanation is not None:
                        explanation.extend(expl)
                    else:
                        explanation = expl
        elif op == 'not in':
            if istext(left) and istext(right):
                explanation = _notin_text(left, right, verbose)
    except Exception:
        _logger.exception("dessert: representation of details failed.  "
                          "Probably an object has a faulty __repr__.")

    if not explanation:
        return None

    return [summary] + explanation
1193941
function is(store, uri, type) {
  var ret = false

  var types = store.findTypeURIs($rdf.sym(uri))

  if (types && types[type]) {
    ret = true
  }

  return ret
}
292487
@Override 
    public List<SemanticError> check(Doc doc) {
    	logger.fine("Checking semantic constraints in document from " + doc.srcInfo);
        final List<SemanticError> errors = new ArrayList<SemanticError>();
        final Set<String> dataTypeNames = new HashSet<String>();
        for (DataType dataType : doc.dataTypes) {
            if (dataTypeNames.contains(dataType.name)) {
            	logger.info("Duplicate data type name " + dataType.name + ".");
                errors.add(_DuplicateDataType(dataType.name));
            } else {
                dataTypeNames.add(dataType.name);
            }
            errors.addAll(check(dataType));
        }
        return errors;
    }
572607
def compare(self, dn, attr, value):
        
        return self.connection.compare_s(dn, attr, value) == 1
98949
function (/*util*/) {

      function compare(actual, expected) {
        return {
          pass: actual instanceof Error && ('' + actual).indexOf(expected) >= 0
        }
      }

      return {compare: compare}
    }
179229
def check(self, version):  # Ignore PyDocStyleBear
        

        def _compare_spec(spec):
            if len(spec) == 1:
                spec = ("=", spec[0])

            token = Tokens.operators.index(spec[0])
            comparison = compare_version(version, spec[1])
            if token in [Tokens.EQ1, Tokens.EQ2]:
                return comparison == 0
            elif token == Tokens.GT:
                return comparison == 1
            elif token == Tokens.LT:
                return comparison == -1
            elif token == Tokens.GTE:
                return comparison >= 0
            elif token == Tokens.LTE:
                return comparison <= 0
            elif token == Tokens.NEQ:
                return comparison != 0
            else:
                raise ValueError("Invalid comparison token")

        results, intermediaries = False, False
        for spec in self.spec:
            if isinstance(spec, list):
                intermediary = True
                for sub in spec:
                    intermediary &= _compare_spec(sub)
                intermediaries |= intermediary
            elif isinstance(spec, tuple):
                results |= _compare_spec(spec)

        return results or intermediaries
455608
def _validate_none_or_type(t):
    
    def _validate(setting):
        """
        Check the setting to make sure it's the right type.

        Args:
            setting (object): The setting to check.

        Returns:
            object: The unmodified object if it's the proper type.

        Raises:
            ValueError: If the setting is the wrong type.
        """
        if setting is not None and not isinstance(setting, t):
            raise ValueError('"{}" is not "{}"'.format(setting, t))
        return setting
    return _validate
143751
def is_canonical(version, loosedev=False):  # type: (str, bool) -> bool
    
    if loosedev:
        return loose440re.match(version) is not None
    return pep440re.match(version) is not None
1185213
@Override
  public int compareTo(IVersion other)
  {
    if (other instanceof SemanticVersion) {
      SemanticVersion sv = (SemanticVersion) other;
      // If neither is named, then compare them as semantic values
      return this.head.compareTo(sv.head);
    }
    else {
      // Fall back to simple string comparison
      return toString().compareTo(other.toString());
    }
  }
500830
def _assert_type_bounds_are_not_conflicting(current_type_bound, previous_type_bound,
                                            location, match_query):
    """"""
    if all((current_type_bound is not None,
            previous_type_bound is not None,
            current_type_bound != previous_type_bound)):
        raise AssertionError(
            u'Conflicting type bounds calculated at location {}: {} vs {} '
            u'for query {}'.format(location, previous_type_bound, current_type_bound, match_query))
125205
def get_value(self, subject=None, predicate=None, object_=None):
        """"""

        for triple in self.triples:

            # Filter out non-matches
            if (subject and triple['subject'] != subject) or \
               (predicate and triple['predicate'] != predicate) or \
               (object_ and triple['object'] != object_):  # pragma: no cover
                continue

            # Return the first found.
            return triple

        return None
1186092
def compare(a, b):
    
    assertType(a, BigInt)
    b = coerceBigInt(b)
    if not b:
        return NotImplemented

    return librelic.bn_cmp(byref(a), byref(b))
390515
def checkversion(version):
    """"""
    try:
        for refversion, responseversion in zip([int(x) for x in REQUIREFOLIADOCSERVE.split('.')], [int(x) for x in version.split('.')]):
            if responseversion > refversion:
                return 1 #response is newer than library
            elif responseversion < refversion:
                return -1 #response is older than library
        return 0 #versions are equal
    except ValueError:
        raise ValueError("Unable to parse version, invalid syntax")
47101
def IS(instance, other):  # noqa
    
    try:
        instance = instance._redpipe_future_result  # noqa
    except AttributeError:
        pass

    try:
        other = other._redpipe_future_result
    except AttributeError:
        pass

    return instance is other
512587
def matchesExpr(cntxt: Context, T: RDFGraph, expr: ShExJ.tripleExpr, _: DebugContext) -> bool:
    

    if isinstance(expr, ShExJ.OneOf):
        return matchesOneOf(cntxt, T, expr)
    elif isinstance(expr, ShExJ.EachOf):
        return matchesEachOf(cntxt, T, expr)
    elif isinstance(expr, ShExJ.TripleConstraint):
        return matchesCardinality(cntxt, T, expr)
    elif isinstance_(expr, ShExJ.tripleExprLabel):
        return matchesTripleExprRef(cntxt, T, expr)
    else:
        raise Exception("Unknown expression")