Exemple #1
0
    def test_sub_same_sizes(self):
        """::can sub two ScalarPatternUniform that are same sized """
        z1 = sp.zeros_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)
Exemple #2
0
    def test_spht(self):
        """::Compare spht within pysphi and csphi"""

        Nrows = 100
        Ncols = 200
        res = True

        for MM in xrange(2, 8, 2):
            NNcols = Ncols - MM
            p = sp.random_patt_uniform(Nrows, NNcols)

            spy = sp.spht_slow(p, 50, 46)
            sc = sp.spht(p, 50, 46)

            rerr = sp.compare_relative(spy, sc)
            if (rerr > 1e-13):
                res = False

        self.assertTrue(res)
Exemple #3
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)
Exemple #4
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
Exemple #5
0
        """spt = sp.ones_patt_uniform(12, 13, patt_type=sp.scalar)""",
        """spt = sp.random_patt_uniform(11, 10, patt_type=sp.scalar)""",
        """spt = sp.random_patt_uniform(11, 11, patt_type=sp.scalar)""",
        """a = spatt + spatt2""", """a = spatt - spatt2""",
        """a = spatt * spatt2""", """a = spatt / spatt2""",
        """a = spatt + spatt3""", """a = spatt - spatt3""",
        """a = spatt * spatt3""", """a = spatt / spatt3""",
        """a = spatt4 + spatt""", """a = spatt4 - spatt""",
        """a = spatt4 * spatt""", """a = spatt4 / spatt""",
        """a = spatt4 + 2.1""", """a = spatt4 - 2.1""", """a = spatt4 * 2.1""",
        """a = spatt4 / 2.1""", """a = 4.5 + spatt2""", """a = 4.5 - spatt2""",
        """a = 4.5 * spatt2""", """a = 4.5 / spatt2""", """a = spatt / 0"""
    ]

    spatt = sp.zeros_patt_uniform(11, 8, patt_type=sp.scalar)
    spatt2 = sp.random_patt_uniform(11, 8, patt_type=sp.scalar)
    spatt3 = sp.random_patt_uniform(11, 6, patt_type=sp.scalar)
    spatt4 = sp.zeros_patt_uniform(12, 6, patt_type=sp.scalar)

    test_executes(executes_spatts)

if test_vector_patt_unif:
    print("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=")
    print("")
    print("           VectorPatternUniform structure with exceptions")
    print("")
    print("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=")

    executes_vpatts = [
        """vpt = sp.zeros_patt_uniform(11, 14, patt_type=sp.vector)""",
        """vpt = sp.zeros_patt_uniform(11, 15, patt_type=sp.vector)""",
Exemple #6
0
 def test_is_symmetric(self):
     """::test single_val method"""
     z2 = sp.random_patt_uniform(11, 10, patt_type=sp.vector)
     self.assertTrue(z2.is_symmetric)
Exemple #7
0
 def test_mult_diff_sizes(self):
     """::can't mult two VectorPatternUniform that are different """
     z1 = sp.ones_patt_uniform(12, 12, patt_type=sp.vector)
     z2 = sp.random_patt_uniform(12, 10, patt_type=sp.vector)
     with self.assertRaises(ValueError):
         _ = z1 * z2
Exemple #8
0
 def test_sub_diff_sizes(self):
     """::can't sub two VectorPatternUniform that are different """
     z1 = sp.zeros_patt_uniform(11, 10, patt_type=sp.vector)
     z2 = sp.random_patt_uniform(11, 12, patt_type=sp.vector)
     with self.assertRaises(ValueError):
         _ = z1 - z2
Exemple #9
0
 def test_make_sure_even_cols_r(self):
     """::raise an error if I try to set ncol odd random"""
     with self.assertRaises(ValueError):
         _ = sp.random_patt_uniform(13, 17, patt_type=sp.vector)
Exemple #10
0
 def test_mult_diff_sizes(self):
     """::can't multiply two ScalarPatternUniform that are different """
     z1 = sp.ones_patt_uniform(12, 12)
     z2 = sp.random_patt_uniform(12, 10)
     with self.assertRaises(ValueError):
         _ = z1 * z2
Exemple #11
0
 def test_add_diff_sizes(self):
     """::can't add two ScalarPatternUniform that are different """
     z1 = sp.zeros_patt_uniform(11, 10)
     z2 = sp.random_patt_uniform(12, 10)
     with self.assertRaises(ValueError):
         _ = z1 + z2
Exemple #12
0
 def test_misc_raise1(self):
     """::exercise raise TypError abs vpatt"""
     z1 = sp.random_patt_uniform(11, 10, patt_type=sp.vector)
     with self.assertRaises(TypeError):
         _ = sp.abs(z1)
Exemple #13
0
    print scoef[:, 2]

    sp = sp.ispht(scoef, 6, 8)

if T5:
    rr = sp.random_coefs(10, 10) + 1j * sp.random_coefs(10, 10)

    ss = 1j - 2 / (sp.zeros_coefs(5,4) + .001) + \
            4* sp.random_coefs(5,4) / 6.0
    ss += sp.ones_coefs(5, 4, coef_type=sp.scalar)

    qq = 1 + 2 * sp.ones_coefs(3, 3) / 4 * sp.ones_coefs(3, 3) - 2

    ds1 =1j + 4*sp.ones_patt_uniform(5,8)/3 - \
        sp.ones_patt_uniform(5,8) -1 + \
        10*sp.random_patt_uniform(5,8)

    print ds1.single_val

    print sp.array(ds1)

    zc = sp.zeros_coefs(10, 10)
    zc[2, 1] = 1.0
    zc[2, -2] = 3.0
    zc[0, 0] = 1j * 5.0
    zc[5, 1] = 7.0

    print zc[2, 1]
    print zc[2, -2]
    print zc[5, 1]