def testTri(self): from org.nmrfx.processor.operations import Tri op = Tri(0, 1.0, 1.0, False) v = Vec(1000, False) v.ones() op.eval(v) for i in range(v.getSize()): self.assertAlmostEqual(v[i], 1.0) self.assertEqual(v.getReal(0), 1.0) self.assertEqual(v.getReal(999), 1.0) op = Tri(500, -10.0, 10.0, False) v1 = Vec(1000, False) v1.ones() op.eval(v1) self.assertAlmostEqual(v1.getReal(0), -10.0) self.assertAlmostEqual(v1.getReal(999), 10.0) for i in range(v.getSize() - 1): self.assert_(v[i] <= v[i + 1]) v2 = Vec(100, False) v2.ones() op = Tri(0, 0.0, 2.0, False) op.eval(v2) self.assertAlmostEqual(v2.getReal(0), 1.0) self.assertAlmostEqual(v2.getReal(49), 1.5, 1) self.assertAlmostEqual(v2.getReal(99), 2.0) for i in range(v.getSize() - 1): self.assert_(v[i] <= v[i + 1])
def testZFInverse(self): from org.nmrfx.processor.operations import Zf size = 31 newSize = 64 factor = None pad = None v = Vec(size, False) op = Zf(factor, newSize, pad) op.eval(v) size2 = v.getSize() self.assert_(newSize == size2) iop = op.getInverseOp() iop.eval(v) size3 = v.getSize() self.assert_(size == size3)
def testZF(self): from org.nmrfx.processor.operations import Zf import math log2 = lambda x: int(math.log(x) / math.log(2)) size = 32 newSize = 63 factor = None pad = None v = Vec(size, False) op = Zf(factor, newSize, pad) op.eval(v) self.assert_(len(v) == newSize) self.assert_(v.getSize() == newSize) size = 64 v = Vec(size, False) newSize = None factor = 2 pad = None op = Zf(factor, newSize, pad) op.eval(v) self.assert_(len(v) == 2**(2 + log2(size))) self.assert_(v.getSize() == 2**(2 + log2(size))) size = 100 v = Vec(size, False) newSize = None factor = None pad = 15 op = Zf(factor, newSize, pad) op.eval(v) self.assert_(len(v) == size + pad) self.assert_(v.getSize() == size + pad)