2

I'm running means2 from scipy, and although I'm getting an error message:

/usr/lib/python2.7/dist-packages/scipy/cluster/vq.py:600: UserWarning: One of the clusters is empty. Re-run kmean with a different initialization. warnings.warn("One of the clusters is empty. "

when running the following code in a loop:

training_2= numpy.random.random_integers(0, 400, size=[50,1]).astype(numpy.float32)
cent, clus= kmeans2(training_2, 3, minit='points')

the loop doesn't terminate. I've noticed this behavior with numpy and OpenCV as well.

The usual try except block doesn't catch these (for lack of a better term) 'soft' errors; is there another way to handle these errors?

If this isn't possible directly, then is there a way to have a python script read it's own output as it runs?

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
Ryan
  • 3,555
  • 1
  • 22
  • 36

1 Answers1

3

It is not an exception, it is a warning:

Warning messages are typically issued in situations where it is useful to alert the user of some condition in a program, where that condition (normally) doesn’t warrant raising an exception and terminating the program.

How to handle it, depends on the warning and whether it affects your program execution, you can:

Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195