Closed JACKCHAN000 closed 1 year ago
Hi @JACKCHAN000, Thanks for bringing this to my attention. Could you please check which version of numba you are using? I was able to run the example using interpolation 2.2.4 and numba 0.56.4.
Best, -Chandler
Thank you for your help! I created a new environment and run the example again. It still has the same error. The interpolation version is 2.2.4 and numba version is still 0.56.4.
Package Version
--------------------- -----------
beautifulsoup4 4.11.1
bioformats-jar 2020.5.27
certifi 2022.12.7
cffi 1.15.1
colorama 0.4.6
colour-science 0.4.1
contourpy 1.0.7
cycler 0.11.0
dnspython 2.3.0
elementpath 3.0.2
email-validator 1.3.0
fastcluster 1.2.6
fonttools 4.38.0
idna 3.4
imageio 2.24.0
importlib-metadata 6.0.0
interpolation 2.2.4
jgo 1.0.5
joblib 1.2.0
JPype1 1.4.1
kiwisolver 1.4.4
llvmlite 0.39.1
lxml 4.9.2
matplotlib 3.6.3
networkx 3.0
numba 0.56.4
numpy 1.23.5
ome-types 0.3.2
opencv-contrib-python 4.7.0.68
packaging 21.3
pandas 1.5.2
Pillow 9.4.0
Pint 0.20.1
pip 22.3.1
psutil 5.9.4
pycparser 2.21
pydantic 1.10.4
pyparsing 3.0.9
python-dateutil 2.8.2
pytz 2022.7.1
pyvips 2.2.1
PyWavelets 1.4.1
scikit-image 0.19.3
scikit-learn 1.2.0
scipy 1.10.0
scyjava 1.8.1
setuptools 65.6.3
shapely 2.0.0
SimpleITK 2.2.1
six 1.16.0
soupsieve 2.3.2.post1
Tempita 0.5.2
threadpoolctl 3.1.0
tifffile 2022.10.10
tqdm 4.64.1
typing_extensions 4.4.0
valis-wsi 1.0.0rc12
weightedstats 0.4.1
wheel 0.37.1
wincertstore 0.2
xmlschema 2.1.1
zipp 3.11.0
Hi @JACKCHAN000, that's really strange. The assertion that's being violated appears to be the requirement that a
is a tuple containing (float64, float64, int64)
, and based on the error the tuple passed in should be exactly that (i.e. (0.0, float(displacement_shape_rc[1]-1), displacement_shape_rc[1])
, where displacement_shape_rc
is just the shape of a numpy array). Could you try the following, and let me know if it works?
import numpy as np
import numba
from interpolation.splines import UCGrid
from valis import warp_tools
dxdy = [np.ones((100, 200)), np.ones((100, 200))]
displacement_shape_rc = dxdy[0].shape[0:2]
tt = numba.typeof((10.0, 1.0, 1))
# Check using numpy array as source for displacement_shape_rc
grid_shape = ((0.0, float(displacement_shape_rc[1]-1), displacement_shape_rc[1]),
(0.0, float(displacement_shape_rc[0]-1), displacement_shape_rc[0]))
a = grid_shape[0]
numba.typeof(a) == tt # assertion being violated
grid = UCGrid((0.0, float(displacement_shape_rc[1]-1), displacement_shape_rc[1]),
(0.0, float(displacement_shape_rc[0]-1), displacement_shape_rc[0]))
# Check using pyvips.Image as source for displacement_shape_rc
vips_dxdy = warp_tools.numpy2vips(np.dstack(dxdy))
vips_displacement_shape_rc = np.array([vips_dxdy.height, vips_dxdy.width])
vips_grid_shape = ((0.0, float(vips_displacement_shape_rc[1]-1), vips_displacement_shape_rc[1]),
(0.0, float(vips_displacement_shape_rc[0]-1), vips_displacement_shape_rc[0]))
vips_a = vips_grid_shape[0]
numba.typeof(vips_a) == tt # assertion being violated
vips_grid = UCGrid((0.0, float(vips_displacement_shape_rc[1]-1), vips_displacement_shape_rc[1]),
(0.0, float(vips_displacement_shape_rc[0]-1), vips_displacement_shape_rc[0]))
Best, -Chandler
Hi @JACKCHAN000, that's really strange. The assertion that's being violated appears to be the requirement that
a
is a tuple containing(float64, float64, int64)
, and based on the error the tuple passed in should be exactly that (i.e.(0.0, float(displacement_shape_rc[1]-1), displacement_shape_rc[1])
, wheredisplacement_shape_rc
is just the shape of a numpy array). Could you try the following, and let me know if it works?import numpy as np import numba from interpolation.splines import UCGrid from valis import warp_tools dxdy = [np.ones((100, 200)), np.ones((100, 200))] displacement_shape_rc = dxdy[0].shape[0:2] tt = numba.typeof((10.0, 1.0, 1)) # Check using numpy array as source for displacement_shape_rc grid_shape = ((0.0, float(displacement_shape_rc[1]-1), displacement_shape_rc[1]), (0.0, float(displacement_shape_rc[0]-1), displacement_shape_rc[0])) a = grid_shape[0] numba.typeof(a) == tt # assertion being violated grid = UCGrid((0.0, float(displacement_shape_rc[1]-1), displacement_shape_rc[1]), (0.0, float(displacement_shape_rc[0]-1), displacement_shape_rc[0])) # Check using pyvips.Image as source for displacement_shape_rc vips_dxdy = warp_tools.numpy2vips(np.dstack(dxdy)) vips_displacement_shape_rc = np.array([vips_dxdy.height, vips_dxdy.width]) vips_grid_shape = ((0.0, float(vips_displacement_shape_rc[1]-1), vips_displacement_shape_rc[1]), (0.0, float(vips_displacement_shape_rc[0]-1), vips_displacement_shape_rc[0])) vips_a = vips_grid_shape[0] numba.typeof(vips_a) == tt # assertion being violated vips_grid = UCGrid((0.0, float(vips_displacement_shape_rc[1]-1), vips_displacement_shape_rc[1]), (0.0, float(vips_displacement_shape_rc[0]-1), vips_displacement_shape_rc[0]))
Best, -Chandler
It raises an error on the last line.
exception: no description
File "C:\Users\JACK\Desktop\aaa.py", line 32, in <module>
vips_grid = UCGrid((0.0, float(vips_displacement_shape_rc[1]-1), vips_displacement_shape_rc[1]), (0.0, float(vips_displacement_shape_rc[0]-1), vips_displacement_shape_rc[0]))
AssertionError:
However, if I change last line into vips_grid = UCGrid((0.0, 199.0, 200),(0.0, 99.0, 100))
. It can run without any errors.
vips_grid = UCGrid((0.0, float(vips_displacement_shape_rc[1]-1), vips_displacement_shape_rc[1]), (0.0, float(vips_displacement_shape_rc[0]-1), vips_displacement_shape_rc[0]))
I change the last line into vips_grid = UCGrid((0.0, float(vips_displacement_shape_rc[1]-1), int(vips_displacement_shape_rc[1])), (0.0, float(vips_displacement_shape_rc[0]-1), int(vips_displacement_shape_rc[0])))
The code can run successfully now.
The vips_displacement_shape_rc[1]
here is numpy.int32 not int
Hi @JACKCHAN000, thanks for confirming that the issue is that pyvips.Image shape values aren't Python ints, but numpy.ints instead. It's so strange though, as the code above works fine on my Mac. Maybe it's a Windows specific issue? No matter, I'll update the code to fix this bug in the next version (1.0.0rc13), which should be available soon. Best, -Chandler
Hi @JACKCHAN000, I've pushed the most recent version of valis that has this bug fixed. I'll close the issue for now, but please reopen it if you continue to have this issue.
Best, -Chandler
Hi! I just run the example
register_and_merge_cycif.py
but it comes up with some error. I read this https://github.com/MathOnco/valis/issues/12 before but I have installed the latest version of valis already. Therefore, I have no idea what the problem is. Any suggestion?Package version: