Do not use .npy format for tests
Created originally on Bitbucket by avmo (Ashwin Vishnu)
It is not a standard format and can break.
> fluidimage/calibration/test_direct_stereo_reconstruction.py
================================================================================ FAILURES ================================================================================
_____________________________________________________________________________ TestCalib.test _____________________________________________________________________________
self =
def test(self):
path_cam1 = pathbase / "E_Calibration_Images" / "Camera_01"
path_cam3 = pathbase / "E_Calibration_Images" / "Camera_03"
path_calib1 = path_cam1 / "calib1.npy"
path_calib3 = path_cam3 / "calib3.npy"
nb_pixelx, nb_pixely = 1024, 1024
nbline_x, nbline_y = 32, 32
calib = CalibDirect(path_cam1 / "img*", (nb_pixelx, nb_pixely))
calib.compute_interpolents()
calib.compute_interpolents_pixel2line(nbline_x, nbline_y, test=False)
calib.check_interp_lines(4)
plt.close("all")
calib.check_interp_lines_coeffs(2)
plt.close("all")
calib.check_interp_levels(2)
plt.close("all")
calib3 = CalibDirect(
os.path.join(path_cam3, "img*"), (nb_pixelx, nb_pixely)
)
calib3.compute_interpolents()
calib3.compute_interpolents_pixel2line(nbline_x, nbline_y, test=False)
calib.save(path_calib1)
calib3.save(path_calib3)
postfix = ".piv"
name = "piv_00001-00002.h5"
path_im = pathbase / "E_Particle_Images"
path_piv1 = path_im / ("Camera_01" + postfix) / name
path_piv3 = path_im / ("Camera_03" + postfix) / name
z0 = 0
alpha = 0
beta = 0
a, b, c, d = get_plane_equation(z0, alpha, beta)
Xl, Yl, dxl, dyl = get_piv_field(path_piv1)
Xr, Yr, dxr, dyr = get_piv_field(path_piv3)
> stereo = DirectStereoReconstruction(path_calib1, path_calib3)
fluidimage/calibration/test_direct_stereo_reconstruction.py:83:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fluidimage/calibration/calib_direct.py:452: in __init__
self.calib0 = CalibDirect(path_file=path_file0)
fluidimage/calibration/calib_direct.py:93: in __init__
self.load(path_file)
fluidimage/calibration/calib_direct.py:265: in load
tmp = np.load(pth_file)
/scratch/avmo/opt/gfdyn/lib/python3.7/site-packages/numpy/lib/npyio.py:447: in load
pickle_kwargs=pickle_kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/avmo/src/gfdyn/fluidimage/image_samples/4th_PIV-Challenge_Case_E/E_Calibration_Images/Camera_01/calib1.npy'>, allow_pickle = False
pickle_kwargs = {'encoding': 'ASCII', 'fix_imports': True}
def read_array(fp, allow_pickle=False, pickle_kwargs=None):
"""
Read an array from an NPY file.
Parameters
----------
fp : file_like object
If this is not a real file object, then this may take extra memory
and time.
allow_pickle : bool, optional
Whether to allow writing pickled data. Default: False
.. versionchanged:: 1.16.3
Made default False in response to CVE-2019-6446.
pickle_kwargs : dict
Additional keyword arguments to pass to pickle.load. These are only
useful when loading object arrays saved on Python 2 when using
Python 3.
Returns
-------
array : ndarray
The array from the data on disk.
Raises
------
ValueError
If the data is invalid, or allow_pickle=False and the file contains
an object array.
"""
version = read_magic(fp)
_check_version(version)
shape, fortran_order, dtype = _read_array_header(fp, version)
if len(shape) == 0:
count = 1
else:
count = numpy.multiply.reduce(shape, dtype=numpy.int64)
# Now read the actual data.
if dtype.hasobject:
# The array contained Python objects. We need to unpickle the data.
if not allow_pickle:
> raise ValueError("Object arrays cannot be loaded when "
"allow_pickle=False")
E ValueError: Object arrays cannot be loaded when allow_pickle=False
/scratch/avmo/opt/gfdyn/lib/python3.7/site-packages/numpy/lib/format.py:692: ValueError