Skip to content

Commit

Permalink
Merge pull request #67 from steven-murray/fix_boxlength
Browse files Browse the repository at this point in the history
fix: make sure int values of boxlength are converted to floats
  • Loading branch information
steven-murray authored Aug 2, 2024
2 parents f71b955 + b807871 commit bcf2573
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/powerbox/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,9 @@ def get_power(
dim = len(deltax.shape)

if not np.iterable(boxlength):
boxlength = [boxlength] * dim
boxlength = [float(boxlength)] * dim
else:
boxlength = [float(val) for val in boxlength]

if deltax2 is not None and deltax.shape != deltax2.shape:
raise ValueError("deltax and deltax2 must have the same shape!")
Expand Down
3 changes: 3 additions & 0 deletions tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,9 @@ def test_cross_power_identity():
p, k = get_power(dx, pb.boxlength, b=1)
p_cross, k = get_power(dx, pb.boxlength, b=1, deltax2=dx)
assert np.all(np.isclose(p, p_cross))
p, k = get_power(dx, [1, 1], b=1)
p_cross, k = get_power(dx, [1, 1], b=1, deltax2=dx)
assert np.all(np.isclose(p, p_cross))


@pytest.mark.skip()
Expand Down

0 comments on commit bcf2573

Please sign in to comment.