Skip to content

Commit

Permalink
fixed database.py for compatibility with numpy 2.0
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
franioli committed Oct 16, 2024
1 parent 7895024 commit db2982f
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/deep_image_matching/hloc/utils/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit db2982f

Please sign in to comment.