Skip to content

Commit

Permalink
convert the error to a warning.
Browse files Browse the repository at this point in the history
Sometimes we do push zero particles through the pipe due to
fluctuations or weird cuts. The code shall not crash due
to this.
  • Loading branch information
rainwoodman committed Oct 23, 2017
1 parent 387d4c0 commit 13e7da9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions nbodykit/base/catalogmesh.py
Expand Up @@ -2,6 +2,7 @@
from nbodykit.base.catalog import CatalogSource, CatalogSourceBase
import numpy
import logging
import warnings

# for converting from particle to mesh
from pmesh import window
Expand Down Expand Up @@ -437,8 +438,10 @@ def to_real_field(self, out=None, normalize=True):

# make sure we painted something!
if N == 0:
raise ValueError(("trying to paint particle source to mesh, "
"but no particles were found!"))
warnings.warn(("trying to paint particle source to mesh, "
"but no particles were found!"),
RuntimeWarning
)

# shot noise is volume / un-weighted number
shotnoise = numpy.prod(pm.BoxSize) / N
Expand Down

0 comments on commit 13e7da9

Please sign in to comment.