From 6d80ffca595b56f570a79c045a1eeb094cd65dda Mon Sep 17 00:00:00 2001 From: ltcptgeneral <35508619+ltcptgeneral@users.noreply.github.com> Date: Tue, 12 May 2020 20:19:58 -0500 Subject: [PATCH] analysis.py v 1.2.1.001 --- analysis-master/analysis/analysis.py | 48 ++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/analysis-master/analysis/analysis.py b/analysis-master/analysis/analysis.py index cd9de8a0..2106bf4a 100644 --- a/analysis-master/analysis/analysis.py +++ b/analysis-master/analysis/analysis.py @@ -7,10 +7,14 @@ # current benchmark of optimization: 1.33 times faster # setup: -__version__ = "1.2.1.000" +__version__ = "1.2.1.001" # changelog should be viewed using print(analysis.__changelog__) __changelog__ = """changelog: + 1.2.1.001: + - added add, mul, neg, and inv functions to ArrayTest class + - added normalize function to ArrayTest class + - added dot and cross functions to ArrayTest class 1.2.1.000: - added ArrayTest class - added elementwise mean, median, standard deviation, variance, min, max functions to ArrayTest class @@ -974,4 +978,44 @@ class ArrayTest(): # tests on nd arrays independent of basic_stats _min = self.elementwise_npmin(*args) _max = self.elementwise_npmax(*args) - return _mean, _median, _stdev, _variance, _min, _max \ No newline at end of file + return _mean, _median, _stdev, _variance, _min, _max + + def normalize(self, array): + + a = np.atleast_1d(np.linalg.norm(array)) + a[a==0] = 1 + return array / np.expand_dims(a) + + def add(self, *args): + + temp = np.array([]) + + for a in *args: + temp += a + + return temp + + def mul(self, *args): + + temp = np.array([]) + + for a in *args: + temp *= a + + return temp + + def neg(self, array): + + return -array + + def inv(self, array): + + return 1/array + + def dot(self, a, b): + + return np.dot(a, b) + + def cross(self, a, b): + + return np.cross(a, b) \ No newline at end of file