Esempio n. 1
0
    def test_misc(self):
        """::exercise misc functions"""

        z1 = sp.random_patt_uniform(11, 10, patt_type=sp.scalar)

        _ = sp.abs(z1)
        _ = sp.mag(z1)
        _ = sp.mag2(z1)
        _ = sp.L2_patt(z1)
        _ = sp.LInf_patt(z1)

        z1 = sp.random_patt_uniform(11, 10, patt_type=sp.vector)

        _ = sp.mag(z1)
        _ = sp.mag2(z1)
        _ = sp.L2_patt(z1)
        _ = sp.LInf_patt(z1)

        z1 = sp.random_coefs(11, 10, coef_type=sp.scalar)

        _ = sp.abs(z1)
        _ = sp.mag(z1)
        _ = sp.mag2(z1)
        _ = sp.L2_coef(z1)
        _ = sp.LInf_coef(z1)

        z1 = sp.random_coefs(11, 10, coef_type=sp.vector)

        _ = sp.mag(z1)
        _ = sp.mag2(z1)
        _ = sp.L2_coef(z1)
        _ = sp.LInf_coef(z1)

        self.assertTrue(True)
Esempio n. 2
0
def verify_ispht(pattfile, scoeffile):

    fsc = fl.load_coef(scoeffile)
    fpatt = fl.load_patt(pattfile)
    patt = sp.ispht(fsc, fpatt.nrows, fpatt.ncols)

    diff = fpatt - patt

    return (sp.L2_patt(diff),
            sp.LInf_patt(diff), sp.L2_patt(diff) / sp.L2_patt(fpatt),
            sp.LInf_patt(diff) / sp.LInf_patt(fpatt))
Esempio n. 3
0
    def test_div_same_sizes(self):
        """::can add two VectorPatternUniform that are same sized """
        z1 = sp.ones_patt_uniform(11, 10, patt_type=sp.vector)
        z2 = sp.random_patt_uniform(11, 10, patt_type=sp.vector)
        a = z1 / (z2 + 0.0001)
        b = z1 / (z2 + 0.0001)
        c = a - b

        res = True
        if sp.L2_patt(c) / sp.L2_patt(b) > 1e-13:
            res = False

        self.assertTrue(res)
Esempio n. 4
0
    def test_mult_same_sizes(self):
        """::can mult two ScalarPatternUniform that are same sized """
        z1 = sp.ones_patt_uniform(11, 10)
        z2 = sp.random_patt_uniform(11, 10)
        a = z1 * z2
        b = z1 * z2
        c = a - b

        res = True
        if sp.L2_patt(c) / sp.L2_patt(b) > 1e-13:
            res = False

        self.assertTrue(res)
Esempio n. 5
0
def verify_vispht(pattf1, pattf2, scoeff1, scoeff2):

    vfpatt = fl.load_vpatt(pattf1, pattf2)

    fsc1 = fl.load_coef(scoeff1)
    fsc2 = fl.load_coef(scoeff2)

    vfsc = sp.VectorCoefs(fsc1._vec, fsc2._vec, fsc1.nmax, fsc1.mmax)

    vpatt = sp.vispht(vfsc, vfpatt.nrows, vfpatt.ncols)

    diff = vfpatt - vpatt

    return (sp.L2_patt(diff),
            sp.LInf_patt(diff), sp.L2_patt(diff) / sp.L2_patt(vfpatt),
            sp.LInf_patt(diff) / sp.LInf_patt(vfpatt))
Esempio n. 6
0
    def test_div_constant_left_right(self):
        """::can mult a scalar to ScalarPatternUniform from both sides"""
        z1 = sp.ones_patt_uniform(11, 10)

        a = z1 / 1j * 1.1
        b = z1 / 1j * 1.1
        c = a - b

        res = True
        if sp.L2_patt(c) / sp.L2_patt(b) > 1e-13:
            res = False

        a = 1j * 1.1 / z1
        b = 1j * 1.1 / z1
        c = a - b

        if sp.L2_patt(c) / sp.L2_patt(b) > 1e-13:
            res = False

        self.assertTrue(res)
Esempio n. 7
0
    def test_div_constant_left_right(self):
        """::can div a scalar to VectorPatternUniform from both sides"""
        z1 = sp.random_patt_uniform(11, 10, patt_type=sp.vector)

        a = z1 / 1j * 1.1
        b = z1 / 1j * 1.1
        c = a - b

        res = True
        if sp.L2_patt(c) / sp.L2_patt(b) > 1e-13:
            res = False

        a = 1j * 1.1 / z1
        b = 1j * 1.1 / z1
        c = a - b

        if sp.L2_patt(c) / sp.L2_patt(b) > 1e-13:
            res = False

        self.assertTrue(res)
Esempio n. 8
0
import sys
sys.path.append('../spherepy')
import spherepy as sp

#TODO: Change all xrange instances to range
#and do a 'from six.moves import range' here
from six.moves import xrange

patt1 = sp.random_patt_uniform(5, 10, patt_type=sp.scalar)

sp.file.save_patt(patt1, 't1.txt')

patt2 = sp.file.load_patt('t1.txt')

a = sp.L2_patt(patt1 - patt2)

scoef1 = sp.random_coefs(10, 7)

sp.file.save_coef(scoef1, 't2.txt')

scoef2 = sp.file.load_coef('t2.txt')

a = sp.L2_coef(scoef1 - scoef2)

a = 1