Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future

When running a python program involving the following function, image[x,y] = 0 gives the following error message. What does that mean and how to solve it? Thanks.

Warning

VisibleDeprecationWarning: using a non-integer number instead of an integer   
will result in an error in the future
image[x,y] = 0
Illegal instruction (core dumped)

Code

def create_image_and_label(nx,ny):
  x = np.floor(np.random.rand(1)[0]*nx)
  y = np.floor(np.random.rand(1)[0]*ny)

  image = np.ones((nx,ny))
  label = np.ones((nx,ny))
  image[x,y] = 0
  image_distance = ndimage.morphology.distance_transform_edt(image)

  r = np.random.rand(1)[0]*(r_max-r_min)+r_min
  plateau = np.random.rand(1)[0]*(plateau_max-plateau_min)+plateau_min

  label[image_distance <= r] = 0 
  label[image_distance > r] = 1
  label = (1 - label)

  image_distance[image_distance <= r] = 0 
  image_distance[image_distance > r] = 1
  image_distance = (1 - image_distance)*plateau

  image = image_distance + np.random.randn(nx,ny)/sigma

  return image, label[92:nx-92,92:nx-92]
like image 979
user288609 Avatar asked Aug 22 '16 04:08

user288609


1 Answers

The warning is saying not to use floats to index your array; use np.int instead of np.floor

like image 72
maxymoo Avatar answered Oct 11 '22 11:10

maxymoo