I have 2 npz files I'd like to compare through an assert from numpy testing module:
https://numpy.org/doc/stable/reference/routines.testing.html
From documentation I understood that .npz files are loaded as instance :
https://docs.scipy.org/doc/numpy-1.10.1/reference/generated/numpy.load.html https://www.kite.com/python/docs/numpy.lib.npyio.NpzFile
From my understanding I thought .npz files were dict but they are loaded as instance and I end up with this error :
AssertionError:
Items are not equal:
ACTUAL: <numpy.lib.npyio.NpzFile object at 0x11d96c690>
DESIRED: <numpy.lib.npyio.NpzFile object at 0x11d97a5d0>
here is my code :
import numpy as np
_npz_test = np.load(npz_test, allow_pickle=True)
_npz_res = np.load(npz_res, allow_pickle=True)
np.testing.assert_equal(_npz_test, _npz_res)
Those .npz files are composed of 3 different files to which I can access when printing:
_npz_test.files
I suppose I could use a workaround by iterating through the keys but I'd like a one line solution to do this.
I can share the files if needed
[np.testing.assert_equal(_npz_test[x],_npz_res[x]) for x in _npz_test.keys()]will throw assert error if they are not equal, also you need to verify that all the keys exists in both objects