Skip to content

Commit

Permalink
Fix parsing error when periodic=False and boxsize not given in the th…
Browse files Browse the repository at this point in the history
…eory module (#257)

* Fix parsing error when periodic=False and boxsize not given. Fixes #256.

* Changelog

* Fix PEP8

* Change conditional structure

* Fix whitespace
  • Loading branch information
lgarrison authored Sep 11, 2021
1 parent cacc923 commit 596fe77
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Enhancements
Bug fixes
---------
- Fix Python reference leak to results struct [#229]
- Fix parsing error when ``periodic=False`` and ``boxsize`` not given in the theory module [#257]


2.3.4 (2019-07-21)
Expand Down
4 changes: 2 additions & 2 deletions Corrfunc/theory/DD.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ def DD(autocorr, nthreads, binfile, X1, Y1, Z1, weights1=None, periodic=True,

# Passing None parameters breaks the parsing code, so avoid this
kwargs = {}
for k in ['weights1', 'weights2', 'weight_type', 'X2', 'Y2', 'Z2']:
for k in ['weights1', 'weights2', 'weight_type',
'X2', 'Y2', 'Z2', 'boxsize']:
v = locals()[k]
if v is not None:
kwargs[k] = v
Expand All @@ -241,7 +242,6 @@ def DD(autocorr, nthreads, binfile, X1, Y1, Z1, weights1=None, periodic=True,
X1, Y1, Z1,
periodic=periodic,
verbose=verbose,
boxsize=boxsize,
output_ravg=output_ravg,
xbin_refine_factor=xbin_refine_factor,
ybin_refine_factor=ybin_refine_factor,
Expand Down
4 changes: 2 additions & 2 deletions Corrfunc/theory/DDrppi.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ def DDrppi(autocorr, nthreads, pimax, binfile, X1, Y1, Z1, weights1=None,

# Passing None parameters breaks the parsing code, so avoid this
kwargs = {}
for k in ['weights1', 'weights2', 'weight_type', 'X2', 'Y2', 'Z2']:
for k in ['weights1', 'weights2', 'weight_type',
'X2', 'Y2', 'Z2', 'boxsize']:
v = locals()[k]
if v is not None:
kwargs[k] = v
Expand All @@ -293,7 +294,6 @@ def DDrppi(autocorr, nthreads, pimax, binfile, X1, Y1, Z1, weights1=None,
X1, Y1, Z1,
periodic=periodic,
verbose=verbose,
boxsize=boxsize,
output_rpavg=output_rpavg,
xbin_refine_factor=xbin_refine_factor,
ybin_refine_factor=ybin_refine_factor,
Expand Down
4 changes: 2 additions & 2 deletions Corrfunc/theory/DDsmu.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ def DDsmu(autocorr, nthreads, binfile, mu_max, nmu_bins,

# Passing None parameters breaks the parsing code, so avoid this
kwargs = {}
for k in ['weights1', 'weights2', 'weight_type', 'X2', 'Y2', 'Z2']:
for k in ['weights1', 'weights2', 'weight_type',
'X2', 'Y2', 'Z2', 'boxsize']:
v = locals()[k]
if v is not None:
kwargs[k] = v
Expand All @@ -309,7 +310,6 @@ def DDsmu(autocorr, nthreads, binfile, mu_max, nmu_bins,
X1, Y1, Z1,
periodic=periodic,
verbose=verbose,
boxsize=boxsize,
output_savg=output_savg,
fast_divide_and_NR_steps=fast_divide_and_NR_steps,
xbin_refine_factor=xbin_refine_factor,
Expand Down
8 changes: 6 additions & 2 deletions Corrfunc/theory/vpf.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ def vpf(rmax, nbins, nspheres, numpN, seed,
if periodic and boxsize is None:
raise ValueError("Must specify a boxsize if periodic=True")

kwargs = {}
if boxsize is not None:
kwargs['boxsize'] = boxsize

# Ensure all input arrays are native endian
X, Y, Z = [convert_to_native_endian(arr, warn=True)
for arr in [X, Y, Z]]
Expand All @@ -216,14 +220,14 @@ def vpf(rmax, nbins, nspheres, numpN, seed,
X, Y, Z,
verbose=verbose,
periodic=periodic,
boxsize=boxsize,
xbin_refine_factor=xbin_refine_factor,
ybin_refine_factor=ybin_refine_factor,
zbin_refine_factor=zbin_refine_factor,
max_cells_per_dim=max_cells_per_dim,
copy_particles=copy_particles,
c_api_timer=c_api_timer,
isa=integer_isa)
isa=integer_isa,
**kwargs)
if extn_results is None:
msg = "RuntimeError occurred"
raise RuntimeError(msg)
Expand Down

0 comments on commit 596fe77

Please sign in to comment.