mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2024-11-13 22:56:18 +00:00
feat: add tests
Signed-off-by: Dev Singh <dev@devksingh.com>
This commit is contained in:
parent
8cdbe11a86
commit
10586e752b
@ -1,8 +1,11 @@
|
||||
from tra_analysis import analysis as an
|
||||
from tra_analysis import metrics
|
||||
from tra_analysis import fits
|
||||
|
||||
def test_():
|
||||
test_data_linear = [1, 3, 6, 7, 9]
|
||||
x_data_circular = []
|
||||
y_data_circular = []
|
||||
y_data_ccu = [1, 3, 7, 14, 21]
|
||||
y_data_ccd = [1, 5, 7, 8.5, 8.66]
|
||||
test_data_scrambled = [-32, 34, 19, 72, -65, -11, -43, 6, 85, -17, -98, -26, 12, 20, 9, -92, -40, 98, -78, 17, -20, 49, 93, -27, -24, -66, 40, 84, 1, -64, -68, -25, -42, -46, -76, 43, -3, 30, -14, -34, -55, -13, 41, -30, 0, -61, 48, 23, 60, 87, 80, 77, 53, 73, 79, 24, -52, 82, 8, -44, 65, 47, -77, 94, 7, 37, -79, 36, -94, 91, 59, 10, 97, -38, -67, 83, 54, 31, -95, -63, 16, -45, 21, -12, 66, -48, -18, -96, -90, -21, -83, -74, 39, 64, 69, -97, 13, 55, 27, -39]
|
||||
@ -29,3 +32,4 @@ def test_():
|
||||
assert all(a == b for a, b in zip(an.Sort().bubblesort(test_data_scrambled), test_data_sorted))
|
||||
assert all(a == b for a, b in zip(an.Sort().cyclesort(test_data_scrambled), test_data_sorted))
|
||||
assert all(a == b for a, b in zip(an.Sort().cocktailsort(test_data_scrambled), test_data_sorted))
|
||||
assert fits.CircleFit(x=[0,0,-1,1], y=[1, -1, 0, 0]).LSC() == (0.0, 0.0, 1.0, 0.0)
|
@ -27,6 +27,12 @@ class CircleFit:
|
||||
# For more information on the LSC method, see:
|
||||
# http://www.dtcenter.org/sites/default/files/community-code/met/docs/write-ups/circle_fit.pdf
|
||||
def __init__(self, x, y, xy=None):
|
||||
if type(x) == list:
|
||||
x = np.array(x)
|
||||
if type(y) == list:
|
||||
y = np.array(y)
|
||||
if type(xy) == list:
|
||||
xy = np.array(xy)
|
||||
if data != None:
|
||||
self.coords = data
|
||||
self.ournp = np #todo: implement cupy correctly
|
||||
@ -76,7 +82,7 @@ class CircleFit:
|
||||
R_1 = self.ournp.mean(Ri_1)
|
||||
# calculate residual error
|
||||
residu_1 = self.ournp.sum((Ri_1-R_1)**2)
|
||||
return xc_1, yc_1, R_1, residu_1
|
||||
return (xc_1, yc_1, R_1, residu_1)
|
||||
def HyperFit(self):
|
||||
raise AttributeError("HyperFit not yet implemented")
|
||||
pass
|
Loading…
Reference in New Issue
Block a user