From b0c02286449ef092726d6f48cd58d37fd9108638 Mon Sep 17 00:00:00 2001 From: DanielaBreitman Date: Thu, 25 Jul 2024 10:01:59 +0200 Subject: [PATCH 1/3] fix: make sure int values of boxlength are converted to floats --- src/powerbox/tools.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/powerbox/tools.py b/src/powerbox/tools.py index cbc7b80..1264e79 100644 --- a/src/powerbox/tools.py +++ b/src/powerbox/tools.py @@ -1120,7 +1120,9 @@ def get_power( dim = len(deltax.shape) if not np.iterable(boxlength): - boxlength = [boxlength] * dim + boxlength = [boxlength + 0.0] * dim + else: + boxlength = [val + 0.0 for val in boxlength] if deltax2 is not None and deltax.shape != deltax2.shape: raise ValueError("deltax and deltax2 must have the same shape!") From 0f4beed00c5da85e8dacc6a6952a9e92b713ca69 Mon Sep 17 00:00:00 2001 From: DanielaBreitman Date: Wed, 31 Jul 2024 13:41:44 +0200 Subject: [PATCH 2/3] fix: change type casting syntax --- src/powerbox/tools.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/powerbox/tools.py b/src/powerbox/tools.py index 1264e79..d03d500 100644 --- a/src/powerbox/tools.py +++ b/src/powerbox/tools.py @@ -1120,9 +1120,9 @@ def get_power( dim = len(deltax.shape) if not np.iterable(boxlength): - boxlength = [boxlength + 0.0] * dim + boxlength = [float(boxlength)] * dim else: - boxlength = [val + 0.0 for val in boxlength] + 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!") From b80787155b9942e09e67bbc77c4faa0fee8853e8 Mon Sep 17 00:00:00 2001 From: DanielaBreitman Date: Fri, 2 Aug 2024 10:49:36 +0200 Subject: [PATCH 3/3] test: add test for new line --- tests/test_tools.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_tools.py b/tests/test_tools.py index 4041def..47c5ee8 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -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()