rhsimplex / image-match

🎇 Quickly search over billions of images
2.94k stars 405 forks source link

Failure when running this function through pytest #140

Open Sandermfc opened 3 years ago

Sandermfc commented 3 years ago

My code calls image_match.signature_database_base.get_words directly. I am getting this failure during pytest unit tests:

        words = np.zeros((N, k)).astype('int8')

        for i, pos in enumerate(word_positions):
            if pos + k <= array.shape[0]:
                words[i] = array[pos:pos+k]
            else:
                temp = array[pos:].copy()
>               temp.resize(k)
E               ValueError: cannot resize an array that references or is referenced
E               by another array in this way.
E               Use the np.resize function or refcheck=False

venv/lib/python3.8/site-packages/image_match/signature_database_base.py:407: ValueError

I have solved this locally by simply adding refcheck=False to the resize line. However, https://stackoverflow.com/questions/20730366/numpy-resize-method seems to suggest that using a temp buffer in this way may not be appropriate.