From db2982f0748138647de5d848a76c717c36c7455f Mon Sep 17 00:00:00 2001 From: Francesco Ioli Date: Wed, 16 Oct 2024 12:01:05 +0200 Subject: [PATCH] fixed database.py for compatibility with numpy 2.0 - changed np.NaN to np.nan for compatibility with numpy 2.0 - Simplify `array_to_blob` and `blob_to_array` functions using `tobytes` and `frombuffer`. - Remove Python 2 compatibility checks and code paths. --- src/deep_image_matching/hloc/utils/database.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/deep_image_matching/hloc/utils/database.py b/src/deep_image_matching/hloc/utils/database.py index 883900d..b1f4575 100644 --- a/src/deep_image_matching/hloc/utils/database.py +++ b/src/deep_image_matching/hloc/utils/database.py @@ -123,17 +123,11 @@ def pair_id_to_image_ids(pair_id): def array_to_blob(array): - if IS_PYTHON3: - return array.tobytes() - else: - return np.getbuffer(array) + return array.tobytes() def blob_to_array(blob, dtype, shape=(-1,)): - if IS_PYTHON3: - return np.fromstring(blob, dtype=dtype).reshape(*shape) - else: - return np.frombuffer(blob, dtype=dtype).reshape(*shape) + return np.frombuffer(blob, dtype=dtype).reshape(*shape) class COLMAPDatabase(sqlite3.Connection):