diff --git a/idefix/utils.py b/idefix/utils.py index 701d0f8..0ac00c2 100644 --- a/idefix/utils.py +++ b/idefix/utils.py @@ -87,10 +87,10 @@ def fit_bbox(data, decimals=0): -------- bbox : Returns a raw bounding box on the data. """ - bbox = bbox(data) + raw_bbox = bbox(data) - nbbox = np.round(bbox, decimals) - nbbox[0,2] = np.floor(bbox * 10 ** decimals)[0,2] / 10 ** decimals - nbbox[1,2] = np.ceil(bbox * 10 ** decimals)[1,2] / 10 ** decimals + nbbox = np.round(raw_bbox, decimals) + nbbox[0,2] = np.floor(raw_bbox * 10 ** decimals)[0,2] / 10 ** decimals + nbbox[1,2] = np.ceil(raw_bbox * 10 ** decimals)[1,2] / 10 ** decimals return nbbox diff --git a/test/test_utils.py b/test/test_utils.py index 566c53f..0eca61f 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -27,6 +27,11 @@ def test_bbox(fix_data): res = np.array([fix_data.min(axis=0), fix_data.max(axis=0)]) assert (utils.bbox(fix_data) == res).all() +def test_fit_bbox(fix_data): + res = np.array([[0, 0, 0], + [1, 1, 1]]) + assert (utils.fit_bbox(fix_data) == res).all() + def test_read(datadir): with open(datadir.join('first.txt')) as f: assert f.read() == 'hullo\n'