def testNormalizeDataWithVolume(self): """Test the normalize data function with a selected RateOfReturn divisor row""" data = np.random.rand(3, 100) data = np.array(data.tolist() + np.random.randint(100, 10000, (1, 100)).tolist()) ndata = normalizeData(data, volume_row=3) assert np.shape(ndata) == (4, 99), "Normalize Data gave incorrect shape" for nd, d in izip(ndata[0:3], data[0:3]): assert close_enough(nd, rateOfReturn(d)), "Normalize Data did not use Rate of Return correctly" assert close_enough( ndata[3], normalizeVolume(data[3][1:]) ), "Normalize Data did not use Normalize Volume correctly"
def testMakeNormalizeDataGenerator(self): """Test the normalize data generator function""" data = np.random.rand(3, 100) simple_norm = DataNormalizer() ndata = simple_norm(data) assert np.shape(ndata) == (3, 99), "Normalize Data gave incorrect shape" for nd, d in izip(ndata, data): assert close_enough(nd, rateOfReturn(d)), "Normalize Data did not use Rate of Return function correctly" data = np.array(data.tolist() + np.random.randint(100, 10000, (1, 100)).tolist()) complex_norm = DataNormalizer(1, 3) ndata = complex_norm(data) assert np.shape(ndata) == (4, 99), "Normalize Data gave incorrect shape" for nd, d in izip(ndata[0:3], data[0:3]): assert close_enough( nd, rateOfReturn(d, data[1][0:-1]) ), "Normalize Data did not use Rate of Return correctly" assert close_enough( ndata[3], normalizeVolume(data[3][1:]) ), "Normalize Data did not use Normalize Volume correctly"
def testNormalizeVolume(self): """Test the normalize volume function""" data = range(1, 10) norm_data = normalizeVolume(data) assert len(norm_data) == 9, "NormalizeVolume changed length of vector" assert close_enough(norm_data, np.arange(0.2, 2, 0.2)), "NormalizeVolume gave incorrect output"