Added runtime checks to cl_CIC_Density

This commit is contained in:
Guilhem Lavaux 2014-09-23 11:59:46 +02:00
parent f6ad248f75
commit 0d688fbf7d

View File

@ -227,6 +227,13 @@ def cl_CIC_Density(particles, Ngrid, Lbox, context=None, periodic=True, centered
if context is None:
context = cl.create_some_context()
cic = CIC_CL(context, ndim=3, centered=centered)
ktype = particles.dtype
if ktype != np.float32 and ktype != np.float64:
raise ValueError("particles may only be float32 or float64")
return cic.run(particles, Ng, L)
if len(particles.shape) != 2 or particles.shape[1] != 3:
raise ValueError("particles may only be a Nx3 array")
cic = CIC_CL(context, ndim=3, centered=centered, ktype=ktype)
return cic.run(particles, Ngrid, Lbox)