Add bbox in utils
This commit is contained in:
parent
7fd27731f9
commit
9d0078663f
@ -52,7 +52,6 @@ extensions = [
|
||||
'sphinx.ext.mathjax',
|
||||
'sphinx.ext.viewcode',
|
||||
'sphinx.ext.napoleon',
|
||||
'recommonmark',
|
||||
]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
|
@ -1,22 +1,12 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# \file __init__.py
|
||||
# \brief TODO
|
||||
# \author Florent Guiotte <florent.guiotte@gmail.com>
|
||||
# \version 0.1
|
||||
# \date 27 févr. 2019
|
||||
#
|
||||
# TODO details
|
||||
#!/usr/bin/env python
|
||||
# file __init__.py
|
||||
# author Florent Guiotte <florent.guiotte@uhb.fr>
|
||||
# version 0.0
|
||||
# date 28 févr. 2019
|
||||
"""Idefix Module
|
||||
|
||||
Utils and production pipelines for processing LiDAR point clouds.
|
||||
|
||||
"""
|
||||
|
||||
__all__ = ['utils']
|
||||
|
||||
__author__ = 'Florent Guiotte'
|
||||
__copyright__ = 'Copyright 2019, CAMLOT doctoral project'
|
||||
__credit__ = ['Florent Guiotte']
|
||||
|
||||
__license__ = 'GPL'
|
||||
__version__ = 0.0
|
||||
__maintainer__ = 'Florent Guiotte'
|
||||
__email__ = 'florent.guiotte@uhb.fr'
|
||||
__status__ = 'Development'
|
||||
|
||||
|
@ -1,11 +1,21 @@
|
||||
"""
|
||||
General utils functions.
|
||||
#!/usr/bin/env python
|
||||
# file utils.py
|
||||
# author Florent Guiotte <florent.guiotte@uhb.fr>
|
||||
# version 0.0
|
||||
# date 28 févr. 2019
|
||||
"""General utils functions.
|
||||
|
||||
This module contains common utils for basic point cloud management and dataviz.
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
||||
Everything should be highly tested there.
|
||||
|
||||
Author: Florent Guiotte
|
||||
Date: 2019-02-27
|
||||
Description: Utilities for idefix package and more.
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
|
||||
def first(a):
|
||||
"""Returns the inverse of the parameter.
|
||||
|
||||
@ -22,3 +32,24 @@ def first(a):
|
||||
Inverse of a.
|
||||
"""
|
||||
return -a
|
||||
|
||||
def bbox(data):
|
||||
"""Returns bounding box of data.
|
||||
|
||||
This function returns the lower and the upper points describing the
|
||||
bounding box of the points contained in data.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
data : ndarray (N, 3)
|
||||
Point cloud data of shape (N, 3), i.e. (x,y,z).
|
||||
|
||||
Returns
|
||||
-------
|
||||
bbox : ndarray
|
||||
Lower and upper points describing the bounding box such as::
|
||||
|
||||
[[xmin, ymin, zmin],
|
||||
[xmax, ymax, zmax]]
|
||||
"""
|
||||
return np.array((np.min(data, axis=0), np.max(data, axis=0)))
|
||||
|
@ -1,15 +1,25 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# \file %filename%.py
|
||||
# \brief TODO
|
||||
# \author Florent Guiotte <florent.guiotte@gmail.com>
|
||||
# \version 0.1
|
||||
# \date 27 févr. 2019
|
||||
#
|
||||
# TODO details
|
||||
#!/usr/bin/env python
|
||||
# file test_utils.py
|
||||
# author Florent Guiotte <florent.guiotte@uhb.fr>
|
||||
# version 0.0
|
||||
# date 28 févr. 2019
|
||||
"""General utils functions unitary tests.
|
||||
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
from idefix import utils
|
||||
|
||||
def test_first():
|
||||
assert utils.first(1) == -1
|
||||
assert utils.first(-4) == 4
|
||||
|
||||
@pytest.fixture
|
||||
def fix_data():
|
||||
np.random.seed(0)
|
||||
return np.random.random((10,3))
|
||||
|
||||
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()
|
||||
|
Loading…
Reference in New Issue
Block a user