Skip to content

Commit

Permalink
Consider ontologies equal only if they are the same instance
Browse files Browse the repository at this point in the history
IvanoBilenchi committed Sep 4, 2024
1 parent 6fd61b5 commit 709e106
Showing 4 changed files with 2 additions and 18 deletions.
2 changes: 0 additions & 2 deletions src/cowl_object.c
Original file line number Diff line number Diff line change
@@ -327,7 +327,6 @@ bool cowl_equals(CowlAny *lhs, CowlAny *rhs) {
case COWL_OT_VECTOR: return cowl_vector_equals(lhs, rhs);
case COWL_OT_TABLE: return cowl_table_equals(lhs, rhs);
case COWL_OT_LITERAL: return cowl_literal_equals(lhs, rhs);
case COWL_OT_ONTOLOGY: return cowl_ontology_equals(lhs, rhs);
default: return lhs == rhs;
}
}
@@ -369,7 +368,6 @@ ulib_uint cowl_hash(CowlAny *object) {
case COWL_OT_VECTOR: return cowl_vector_hash(object);
case COWL_OT_TABLE: return cowl_table_hash(object);
case COWL_OT_LITERAL: return cowl_literal_hash(object);
case COWL_OT_ONTOLOGY: return cowl_ontology_hash(object);
default: return ulib_hash_alloc_ptr(object);
}
}
13 changes: 0 additions & 13 deletions src/cowl_ontology.c
Original file line number Diff line number Diff line change
@@ -151,19 +151,6 @@ CowlVector *cowl_ontology_get_annot(CowlOntology *onto) {
return onto->annot ? onto->annot : (onto->annot = cowl_vector_ordered_empty());
}

bool cowl_ontology_equals(CowlOntology *lhs, CowlOntology *rhs) {
if (lhs == rhs) return true;
if (!(lhs->iri || rhs->iri)) return false;
return lhs->iri == rhs->iri && lhs->version == rhs->version;
}

ulib_uint cowl_ontology_hash(CowlOntology *onto) {
if (!onto->iri) return 0;
ulib_uint hash = cowl_primitive_hash(onto->iri);
if (onto->version) hash = ulib_hash_combine(hash, cowl_primitive_hash(onto->version));
return hash;
}

ulib_uint cowl_ontology_axiom_count(CowlOntology *onto, bool imports) {
ulib_uint count = 0;

2 changes: 0 additions & 2 deletions src/cowl_ontology_private.h
Original file line number Diff line number Diff line change
@@ -41,8 +41,6 @@ struct CowlOntology {
CowlOntology *cowl_ontology(CowlManager *manager);
void cowl_ontology_free(CowlOntology *onto);
cowl_ret cowl_ontology_finalize(CowlOntology *onto);
COWL_PURE bool cowl_ontology_equals(CowlOntology *lhs, CowlOntology *rhs);
COWL_PURE ulib_uint cowl_ontology_hash(CowlOntology *onto);

COWL_END_DECLS

3 changes: 2 additions & 1 deletion test/tests/cowl_manager_tests.c
Original file line number Diff line number Diff line change
@@ -125,7 +125,8 @@ static bool cowl_test_manager_write_ontology_path(UString path) {
utest_assert_not_null(onto_out);

// Check that the written ontology is syntactically equal to the test ontology.
cowl_assert_equal(ontology, onto_in, onto_out);
utest_assert_ptr(cowl_ontology_get_iri(onto_in), ==, cowl_ontology_get_iri(onto_out));
utest_assert_ptr(cowl_ontology_get_version(onto_in), ==, cowl_ontology_get_version(onto_out));

UVec(CowlObjectPtr) imports_in = uvec(CowlObjectPtr);
CowlIterator iter = cowl_iterator_vec(&imports_in, false);

0 comments on commit 709e106

Please sign in to comment.