Skip to content
Snippets Groups Projects
Commit ff2d8f66 authored by abhishek-0802's avatar abhishek-0802
Browse files

maths and processing files

parent 39f8cf7a
No related branches found
No related tags found
No related merge requests found
No preview for this file type
This diff is collapsed.
......@@ -312,6 +312,11 @@ class TestCase(unittest.TestCase):
self.assertFalse(np.any(np.isnan(vec)))
self.assertTrue(is_numeric_array(vec))
def test_weighted_irdf(self):
for i, j, k in [([1,2,3],7, [4.0,3, 2.0]), ([3.0,'w',4],'w', ['w', 7.0, 4]), (3, [3.0, 2, 8.0], 7)]:
with self.assertRaises(TypeError):
comparing.weighted_irdf(i,j,k)
if __name__ == '__main__':
unittest.main()
......@@ -47,11 +47,23 @@ class TestCase(unittest.TestCase):
- channel name is None value or nan
"""
# channels must be strings or char
for n in [3, 8.7, None, np.nan]:
for n in [(3, 8.7, None, np.nan)]:
with self.assertRaises(TypeError):
DataBase(self.mydb_filename, channels=n)
for l in [None, np.nan, 'Wr',[2, 3.0]]:
with self.assertRaises(ValueError):
DataBase(self.mydb_filename, channels= [l])
def test_adapt_arr(self):
with self.assertRaises(ValueError):
DataBase(self.mydb_filename, channels=[None, 2])
database.adapt_array(None)
def test_convert_arr(self):
with self.assertRaises(ValueError):
database.convert_array(None)
def test_table_exist(self):
"""
......@@ -79,14 +91,21 @@ class TestCase(unittest.TestCase):
- row is out of range; smaller or equal to 0
- checks if true is returned for an exiting entry (row=1)
"""
for n in [7.0, None, np.nan]:
with self.assertRaises(TypeError):
self.mydb.check_data_validity(n)
for n in [-1, 0]:
for n in [ -1, 0]:
with self.assertRaises(ValueError):
self.mydb.check_data_validity(n)
assert self.mydb.check_data_validity(1)
def test_read_posorient(self):
"""
this test checks the function read_posorient works
......@@ -150,6 +169,8 @@ class TestCase(unittest.TestCase):
for rowid in [0, -2]:
with self.assertRaises(ValueError):
self.mydb.read_posorient(rowid=rowid)
with self.assertRaises(TypeError):
self.mydb.read_posorient(rowid='T')
with self.assertRaises(Exception):
......@@ -159,6 +180,9 @@ class TestCase(unittest.TestCase):
with self.assertRaises(TypeError):
self.mydb.read_posorient(rowid=4.5)
for rowid in [1]:
posoriend2 = self.mydb.read_posorient(rowid=rowid)
pd.testing.assert_series_equal(posoriend2, posorient)
......@@ -180,10 +204,13 @@ class TestCase(unittest.TestCase):
with self.assertRaises(ValueError):
# print("rowid",rowid)
self.mydb.scene(rowid=rowid)
with self.assertRaises(Exception):
self.mydb.scene(posorient = None, rowid=None)
with self.assertRaises(TypeError):
self.mydb.scene(rowid='T')
with self.assertRaises(Exception):
self.mydb.scene(rowid=None)
with self.assertRaises(TypeError):
self.mydb.scene(rowid=np.nan)
with self.assertRaises(TypeError):
......
import unittest
import numpy as np
from navipy.errorprop import propagate_error, estimate_jacobian
from navipy.errorprop import propagate_error, estimate_jacobian, estimate_error
def sincosine(x):
......@@ -44,6 +44,17 @@ class TestErrorProp(unittest.TestCase):
err_theo[1, 1] = c*(c*d - c*f) - c*(c*e - c*g)
np.testing.assert_array_almost_equal(err, err_theo)
def test_estimate_error(self):
for i, j in [(2, 3.0), (3.0, 2), ('w', 'w')]:
with self.assertRaises(TypeError):
estimate_error(i, j)
for i, j in [(2, [2, 3.0, 4])]:
with self.assertRaises(ValueError):
estimate_error(i, j)
if __name__ == '__main__':
unittest.main()
......@@ -18,7 +18,6 @@ class TestCoordinates(unittest.TestCase):
with self.assertRaises(ValueError):
coordinates.cartesian_to_spherical_vectors(a,b)
for c,d in [((3.0,2),([5, 6.0])),(([4.0, 2]),(4, 3))]:
with self.assertRaises(TypeError):
coordinates.cartesian_to_spherical_vectors(c, d)
......@@ -27,11 +26,20 @@ class TestCoordinates(unittest.TestCase):
with self.assertRaises(TypeError):
coordinates.cartesian_to_spherical_vectors(g,h)
with self.assertRaises(Exception):
coordinates.cartesian_to_spherical_vectors(g, h)
i = np.array([[1,2,3,4],[5,6,7,8], [9,10,11,12]])
k = np.array([['w', 1.0, 2],[3,'w', 2.0], ['w', 4.0, 6]])
for i, j in [(i, 2.0), (i, k)]:
with self.assertRaises(TypeError):
coordinates.cartesian_to_spherical_vectors(i, j)
with self.assertRaises(Exception):
i = np.array([[1,2,3,4],[5,6,7,8], [9,10,11,12]])
j = np.array([[3, 1, 2],[3,4, 6], [1, 4, 6]])
coordinates.cartesian_to_spherical_vectors(i, j)
with self.assertRaises(Exception):
e = np.array([2, 4, 6, 8])
f = np.array([2, 4, 6, 8, 3.0])
......
import unittest
import numpy as np
import pandas as pd
from navipy.processing import mcode
# import matplotlib.pyplot as plt
......@@ -532,6 +533,20 @@ class TestCase(unittest.TestCase):
assert np.all(np.isclose(achigh, res_high))
assert np.all(np.isclose(achigh2, res_high2))
def test_opticflow(self):
series = pd.Series(np.array([1,2,3,4,5]))
with self.assertRaises(TypeError):
mcode._check_optic_flow_param([2, 3.0, 4], 5)
with self.assertRaises(Exception):
mcode._check_optic_flow_param([2, 3.0, 5], series)
if __name__ == '__main__':
unittest.main()
import unittest
from navipy.processing import mcode
from navipy.processing.mcode import Module
import pandas as pd
import numpy as np
from navipy.trajectories import posorient_columns
......@@ -126,3 +127,17 @@ yaw-pitch-roll (zyx) convention has vertical gOF equal to zero
# Add abs tol because we compare to zero
np.testing.assert_allclose(rof, np.zeros_like(rof), atol=1e-7)
np.testing.assert_allclose(vof, np.zeros_like(vof), atol=1e-7)
# def test__check_optic_flow(self):
#
# for c,d in [(4, None), ([3, 7.0], None)]:
# with self.assertRaises(ValueError):
# mcode._check_optic_flow_param(c,d)
# with self.assertRaises(TypeError):
# mcode._check_optic_flow_param(c, d)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment