From 709e1068f75c8c10588d49af9331eac57a36e463 Mon Sep 17 00:00:00 2001 From: Ivano Bilenchi Date: Wed, 4 Sep 2024 17:34:40 +0200 Subject: [PATCH] Consider ontologies equal only if they are the same instance --- src/cowl_object.c | 2 -- src/cowl_ontology.c | 13 ------------- src/cowl_ontology_private.h | 2 -- test/tests/cowl_manager_tests.c | 3 ++- 4 files changed, 2 insertions(+), 18 deletions(-) diff --git a/src/cowl_object.c b/src/cowl_object.c index 2e03cbd..ba7ca94 100644 --- a/src/cowl_object.c +++ b/src/cowl_object.c @@ -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); } } diff --git a/src/cowl_ontology.c b/src/cowl_ontology.c index e2c50c1..b92421b 100644 --- a/src/cowl_ontology.c +++ b/src/cowl_ontology.c @@ -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; diff --git a/src/cowl_ontology_private.h b/src/cowl_ontology_private.h index 48419d6..d4c12e2 100644 --- a/src/cowl_ontology_private.h +++ b/src/cowl_ontology_private.h @@ -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 diff --git a/test/tests/cowl_manager_tests.c b/test/tests/cowl_manager_tests.c index 3dc842f..a30bd8f 100644 --- a/test/tests/cowl_manager_tests.c +++ b/test/tests/cowl_manager_tests.c @@ -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);