Skip to content

Commit 4ee028b

Browse files
committed
Fix error handling in large_scale_density_spherical_volume.py
1 parent b81af86 commit 4ee028b

2 files changed

Lines changed: 8 additions & 14 deletions

File tree

halotools/mock_observables/large_scale_density/large_scale_density_spherical_volume.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,13 @@ def _large_scale_density_spherical_volume_process_args(
145145
rbins = np.atleast_1d(radius).astype(float)
146146
rbins = np.append(rbins, rbins[0] + 0.0001)
147147

148-
period = get_period(period)[0]
149-
150148
if sample_volume is None:
151-
sample_volume = period.prod()
152-
else:
153-
msg = "If period is not None, do not pass in sample_volume"
154-
raise HalotoolsError(msg)
149+
if period is None:
150+
raise HalotoolsError("If sample_volume is None, must pass period")
151+
if period is not None:
152+
raise HalotoolsError("If period is not None, do not pass in sample_volume")
153+
154+
period = get_period(period)[0]
155+
sample_volume = period.prod()
155156

156157
return sample, tracers, rbins, period, sample_volume, num_threads, approx_cell1_size

halotools/mock_observables/large_scale_density/tests/test_large_scale_density_spherical_volume.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,7 @@ def test_large_scale_density_spherical_volume_exception_handling():
2525

2626
with pytest.raises(HalotoolsError) as err:
2727
result = large_scale_density_spherical_volume(sample, tracers, radius)
28-
substr = "If period is None, you must pass in ``sample_volume``."
29-
assert substr in err.value.args[0]
30-
31-
with pytest.raises(HalotoolsError) as err:
32-
result = large_scale_density_spherical_volume(
33-
sample, tracers, radius, period=[1, 1]
34-
)
35-
substr = "Input ``period`` must either be a float or length-3 sequence"
28+
substr = "must pass"
3629
assert substr in err.value.args[0]
3730

3831
with pytest.raises(HalotoolsError) as err:

0 commit comments

Comments
 (0)