-
Notifications
You must be signed in to change notification settings - Fork 57
Closed
Description
General information
- Corrfunc version: v2.2
Issue description
Passing only one weights array when doing a cross-correlation of particle sets of different sizes causes a RuntimeError
.
The cause is that the Python wrappers create a uniform weights array for the second set of particles if only the first was provided, but it is created with size equal to the first particle set.
Minimal failing example
import numpy as np
from Corrfunc.theory.DD import DD
N_d = 10000
Lbox = 250.
N_r = N_d*5
x_DM_jack = np.random.uniform(0.,Lbox,N_d)
y_DM_jack = np.random.uniform(0.,Lbox,N_d)
z_DM_jack = np.random.uniform(0.,Lbox,N_d)
x_rand_jack = np.random.uniform(0.,Lbox,N_r)
y_rand_jack = np.random.uniform(0.,Lbox,N_r)
z_rand_jack = np.random.uniform(0.,Lbox,N_r)
w_DM_jack = np.full_like(x_DM_jack,1.)
w_DM_jack[:] = np.random.uniform(1.,2.,N_d)
bins = np.logspace(-1,1.,25)
autocorr = 0
results = DD(autocorr,nthreads=16,binfile=bins,
X1=x_rand_jack, Y1=y_rand_jack, Z1=z_rand_jack,
X2=x_DM_jack, Y2=y_DM_jack, Z2=z_DM_jack,weights2=w_DM_jack,
boxsize=Lbox,periodic=False)
---------------------------------------------------------------------------
error Traceback (most recent call last)
error: ERROR: the last dimension of `weights` must match the number of positions. Instead found n_weights=10000, nx=50000
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-7-fac2f1ff5530> in <module>
23 X1=x_rand_jack, Y1=y_rand_jack, Z1=z_rand_jack,
24 X2=x_DM_jack, Y2=y_DM_jack, Z2=z_DM_jack,weights2=w_DM_jack,
---> 25 boxsize=Lbox,periodic=False)
~/anaconda3/lib/python3.6/site-packages/Corrfunc-2.3.0-py3.6-linux-x86_64.egg/Corrfunc/theory/DD.py in DD(autocorr, nthreads, binfile, X1, Y1, Z1, weights1, periodic, X2, Y2, Z2, weights2, verbose, boxsize, output_ravg, xbin_refine_factor, ybin_refine_factor, zbin_refine_factor, max_cells_per_dim, enable_min_sep_opt, c_api_timer, isa, weight_type)
246 if extn_results is None:
247 msg = "RuntimeError occurred"
--> 248 raise RuntimeError(msg)
249 else:
250 extn_results, api_time = extn_results
RuntimeError: RuntimeError occurred
Thanks to @boryanah for finding this and providing the failing example!