Add bbox in utils
This commit is contained in:
parent
7fd27731f9
commit
9d0078663f
@ -52,7 +52,6 @@ extensions = [
|
|||||||
'sphinx.ext.mathjax',
|
'sphinx.ext.mathjax',
|
||||||
'sphinx.ext.viewcode',
|
'sphinx.ext.viewcode',
|
||||||
'sphinx.ext.napoleon',
|
'sphinx.ext.napoleon',
|
||||||
'recommonmark',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# Add any paths that contain templates here, relative to this directory.
|
# Add any paths that contain templates here, relative to this directory.
|
||||||
|
@ -1,22 +1,12 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# file __init__.py
|
||||||
# \file __init__.py
|
# author Florent Guiotte <florent.guiotte@uhb.fr>
|
||||||
# \brief TODO
|
# version 0.0
|
||||||
# \author Florent Guiotte <florent.guiotte@gmail.com>
|
# date 28 févr. 2019
|
||||||
# \version 0.1
|
"""Idefix Module
|
||||||
# \date 27 févr. 2019
|
|
||||||
#
|
Utils and production pipelines for processing LiDAR point clouds.
|
||||||
# TODO details
|
|
||||||
|
"""
|
||||||
|
|
||||||
__all__ = ['utils']
|
__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 @@
|
|||||||
"""
|
#!/usr/bin/env python
|
||||||
General utils functions.
|
# 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):
|
def first(a):
|
||||||
"""Returns the inverse of the parameter.
|
"""Returns the inverse of the parameter.
|
||||||
|
|
||||||
@ -22,3 +32,24 @@ def first(a):
|
|||||||
Inverse of a.
|
Inverse of a.
|
||||||
"""
|
"""
|
||||||
return -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
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# file test_utils.py
|
||||||
# \file %filename%.py
|
# author Florent Guiotte <florent.guiotte@uhb.fr>
|
||||||
# \brief TODO
|
# version 0.0
|
||||||
# \author Florent Guiotte <florent.guiotte@gmail.com>
|
# date 28 févr. 2019
|
||||||
# \version 0.1
|
"""General utils functions unitary tests.
|
||||||
# \date 27 févr. 2019
|
|
||||||
#
|
|
||||||
# TODO details
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
import pytest
|
||||||
from idefix import utils
|
from idefix import utils
|
||||||
|
|
||||||
def test_first():
|
def test_first():
|
||||||
assert utils.first(1) == -1
|
assert utils.first(1) == -1
|
||||||
assert utils.first(-4) == 4
|
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