Skip to content

Commit

Permalink
fixed issue with constraints not getting propagated correctly and upd…
Browse files Browse the repository at this point in the history
…ated python tests
  • Loading branch information
ifadams committed Sep 25, 2024
1 parent bd2e9c6 commit bf82fb0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
6 changes: 4 additions & 2 deletions src/DescriptorsCommand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -960,11 +960,13 @@ int FindDescriptor::construct_protobuf(PMGDQuery &query,

Json::Value node_constraints = constraints;
cp_result["ids_array"] = ids_array;
//TODO QUERY REFACTOR MODS-Still queries for link_to_set
for (int i = 0; i < ids.size(); ++i){
for (int i = 0; i < ids.size(); ++i){
printf("IDS!\n");
Json::Value k_node_constraints;

//Theoretically this makes a deep copy
k_node_constraints = constraints;

// Create a vector with a string and an integer
std::vector<Json::Value> values;
values.push_back("==");
Expand Down
33 changes: 17 additions & 16 deletions tests/python/TestDescriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,10 +648,9 @@ def test_findDescByBlobUnusedRef(self):
response, blob_array = db.query(all_queries, [descriptor_blob])

# Check success
self.assertEqual(response[0]["FindDescriptor"]["status"], 0)
self.assertEqual(response[0]["FindDescriptor"]["returned"], kn)
self.assertEqual(len(blob_array), kn)
self.assertEqual(descriptor_blob[0], blob_array[0])
self.assertEqual(response[0]["status"], -1)
self.assertEqual(response[0]["info"], "_ref is not supported for KNN search")

self.disconnect(db)

# @unittest.skip("Skipping class until fixed")
Expand Down Expand Up @@ -785,23 +784,25 @@ def test_findDescByBlobWithLink(self):
all_queries.append(query)

response, blob_array = db.query(all_queries, [descriptor_blob])
self.assertEqual(response[0]["status"], -1)
self.assertEqual(response[0]["info"], "_ref is not supported for KNN search")

self.assertEqual(len(blob_array), kn)
#self.assertEqual(len(blob_array), kn)
# This checks that the received blobs is the same as the inserted.
self.assertEqual(descriptor_blob[0], blob_array[0])
#self.assertEqual(descriptor_blob[0], blob_array[0])

# Check success
self.assertEqual(response[0]["FindDescriptor"]["status"], 0)
self.assertEqual(response[0]["FindDescriptor"]["returned"], kn)
#self.assertEqual(response[0]["FindDescriptor"]["status"], 0)
#self.assertEqual(response[0]["FindDescriptor"]["returned"], kn)

self.assertEqual(response[0]["FindDescriptor"]["entities"][0]["_distance"], 0)
self.assertEqual(response[0]["FindDescriptor"]["entities"][1]["_distance"], 400)
self.assertEqual(response[0]["FindDescriptor"]["entities"][2]["_distance"], 400)
#self.assertEqual(response[0]["FindDescriptor"]["entities"][0]["_distance"], 0)
#self.assertEqual(response[0]["FindDescriptor"]["entities"][1]["_distance"], 400)
#self.assertEqual(response[0]["FindDescriptor"]["entities"][2]["_distance"], 400)

self.assertEqual(response[1]["FindEntity"]["status"], 0)
self.assertEqual(response[1]["FindEntity"]["returned"], kn)
#self.assertEqual(response[1]["FindEntity"]["status"], 0)
#self.assertEqual(response[1]["FindEntity"]["returned"], kn)

self.assertEqual(response[1]["FindEntity"]["entities"][0]["entity_prop"], 200)
self.assertEqual(response[1]["FindEntity"]["entities"][1]["entity_prop"], 201)
self.assertEqual(response[1]["FindEntity"]["entities"][2]["entity_prop"], 202)
#self.assertEqual(response[1]["FindEntity"]["entities"][0]["entity_prop"], 200)
#self.assertEqual(response[1]["FindEntity"]["entities"][1]["entity_prop"], 201)
#self.assertEqual(response[1]["FindEntity"]["entities"][2]["entity_prop"], 202)
self.disconnect(db)

0 comments on commit bf82fb0

Please sign in to comment.