Add test on fit_bbox

This commit is contained in:
Florent Guiotte 2021-02-16 16:36:40 +01:00
parent a21598eb74
commit 553a896e36
2 changed files with 9 additions and 4 deletions

View File

@ -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

View File

@ -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'