-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathClass.py
33 lines (23 loc) · 1.14 KB
/
Class.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import numpy as np
class Class():
def __init__(self, featureMeans, featureCovariances):
if not isinstance(featureMeans, np.ndarray):
featureMeans = np.ndarray(featureMeans)
if not isinstance(featureCovariances, np.ndarray):
featureCovariances = np.ndarray(featureCovariances)
if featureMeans.ndim != 1:
raise Exception("The number of dimensions input argument" +
"featureMeans must be 1")
self.numberOfFeatures = len(featureMeans)
self.featureMeans = featureMeans
if featureCovariances.ndim != 2:
raise Exception("The input argument featureCovariances's"+
"number of dimensions should be 2")
height, width = featureCovariances.shape
if height != width:
raise Exception("The inpurt argument featureCovariances matrix"+
"must be square")
if height != self.numberOfFeatures:
raise Exception("The inpurt argument featureCovariances matrix"+
"height must be equal to the size of input argument featureMeans")
self.featureCovariances = featureCovariances