Пример #1
0
    def test_sub_operator__simple(self):
        l1, l2 = Lin.rand(), Lin.rand()

        assert l1 - l2 == l1 - (-l2)

        # Anyway, axial sub is commutative.
        assert l1 - l2 == l2 - l1
Пример #2
0
    def test_add_operator__simple(self):
        l1, l2 = Lin.rand(), Lin.rand()

        assert l1 + l2 == l1 + (-l2)

        # Anyway, axial add is commutative.
        assert l1 + l2 == l2 + l1
Пример #3
0
    def test_sub_operator__simple(self):
        l1, l2 = Lin.rand(), Lin.rand()

        assert l1 - l2 == l1 - (-l2)

        # Anyway, axial sub is commutative.
        assert l1 - l2 == l2 - l1
Пример #4
0
    def test_add_operator__simple(self):
        l1, l2 = Lin.rand(), Lin.rand()

        assert l1 + l2 == l1 + (-l2)

        # Anyway, axial add is commutative.
        assert l1 + l2 == l2 + l1
Пример #5
0
def test_pair_equal():
    n, lin = Lin.rand(), Lin.rand()
    fol = n ** lin
    p = Pair.from_pair(fol, lin)
    assert p == Pair.from_pair(fol, lin)
    assert p == Pair.from_pair(fol, -lin)
    assert p == Pair.from_pair(-fol, lin)
    assert p == Pair.from_pair(-fol, -lin)
Пример #6
0
 def test_pair_equal(self):
     n, lin = Lin.rand(), Lin.rand()
     fol = n**lin
     p = Pair.from_pair(fol, lin)
     assert p == Pair.from_pair(fol, lin)
     assert p == Pair.from_pair(fol, -lin)
     assert p == Pair.from_pair(-fol, lin)
     assert p == Pair.from_pair(-fol, -lin)
Пример #7
0
    def test_fol_vector_dd(self):
        fol = Fol(120, 30)

        assert Lin(*fol.V.dd).asfol == fol
Пример #8
0
    def test_lin_vector_dd(self):
        lin = Lin(120, 30)

        assert Lin(*lin.V.dd) == lin
Пример #9
0
    def test_cross_product(self):
        l1, l2 = Lin.rand(), Lin.rand()
        p = l1**l2

        assert np.allclose([p.angle(l1), p.angle(l2)], [90, 90])
Пример #10
0
    def test_angle_under_rotation(self):
        l1, l2 = Lin.rand(), Lin.rand()
        D = DefGrad.from_axis(Lin(45, 45), 60)

        assert np.allclose(l1.angle(l2),
                           l1.transform(D).angle(l2.transform(D)))
Пример #11
0
    def test_lineation_product_operator(self):
        l1, l2 = Lin.rand(), Lin.rand()

        assert l1.cross(l2) == l1**l2
Пример #12
0
    def test_cross_product(self):
        l1, l2 = Lin.rand(), Lin.rand()
        p = l1**l2

        assert np.allclose([p.angle(l1), p.angle(l2)], [90, 90])
Пример #13
0
 def test_that_azimuth_0_is_same_as_360(self):
     assert Lin(0, 20) == Lin(360, 20)
Пример #14
0
 def test_resultant_rdegree(self):
     g = Group.from_array([45, 135, 225, 315], [45, 45, 45, 45], Lin)
     c1 = g.R.uv == Lin(0, 90)
     c2 = np.allclose(abs(g.R), np.sqrt(8))
     c3 = np.allclose((g.rdegree / 100 + 1)**2, 2)
     assert c1 and c2 and c3
Пример #15
0
    def test_lineation_product(self):
        l1, l2 = Lin.rand(), Lin.rand()
        p = l1.cross(l2)

        assert np.allclose([p.angle(l1), p.angle(l2)], [90, 90])
Пример #16
0
    def test_lineation_product_operator(self):
        l1, l2 = Lin.rand(), Lin.rand()

        assert l1.cross(l2) == l1 ** l2
Пример #17
0
    def test_angle_under_rotation(self):
        l1, l2 = Lin.rand(), Lin.rand()
        D = DefGrad.from_axis(Lin(45, 45), 60)

        assert np.allclose(l1.angle(l2), l1.transform(D).angle(l2.transform(D)))
Пример #18
0
    def test_mutual_rotation(self):
        l1, l2 = Lin.rand(), Lin.rand()

        assert l1.transform(l1.H(l2)) == l2
Пример #19
0
 def test_centered_group(self):
     g = Group.randn_lin(mean=Lin(40, 50))
     gc = g.centered
     el = gc.ortensor.eigenlins
     assert el[0] == Lin(0, 90) and el[1] == Lin(90, 0) and el[2] == Lin(
         0, 0)
Пример #20
0
def test_orthogonality_rotation_matrix():
    lin = Lin.rand()
    a = np.random.randint(180)
    R = DefGrad.from_axis(lin, a)
    assert np.allclose(R * R.T, np.eye(3))
Пример #21
0
 def test_scalar_product(self):
     lin = Lin.rand()
     assert np.allclose(lin * lin, 1)
Пример #22
0
def test_stress_invariants_under_rotation():
    S = Stress.from_comp(xx=4, yy=6, zz=8, xy=1, xz=2)
    lin = Lin.rand()
    a = np.random.randint(180)
    Sr = S.rotate(lin, a)
    assert np.allclose([S.I1, S.I2, S.I3], [Sr.I1, Sr.I2, Sr.I3])
Пример #23
0
 def test_scalar_product(self):
     lin = Lin.rand()
     assert np.allclose(lin * lin, 1)
Пример #24
0
 def test_rotation_invariant(self):
     g = Group.randn_lin()
     self.assertTrue(
         np.allclose(g.rotate(Lin(45, 45), 90).rdegree, g.rdegree))
Пример #25
0
    def test_lineation_product(self):
        l1, l2 = Lin.rand(), Lin.rand()
        p = l1.cross(l2)

        assert np.allclose([p.angle(l1), p.angle(l2)], [90, 90])
Пример #26
0
 def test_resultant_rdegree(self):
     g = Group.fromarray([45, 135, 225, 315], [45, 45, 45, 45])
     c1 = g.resultant.uv == Lin(0, 90)
     c2 = np.allclose(abs(g.resultant), np.sqrt(8))
     c3 = np.allclose((g.rdegree / 100 + 1)**2, 2)
     self.assertTrue(c1 and c2 and c3)
Пример #27
0
    def test_mutual_rotation(self):
        l1, l2 = Lin.rand(), Lin.rand()

        assert l1.transform(l1.H(l2)) == l2
Пример #28
0
 def test_cross_product(self):
     l1 = Lin(110, 22)
     l2 = Lin(163, 47)
     p = l1**l2
     self.assertTrue(np.allclose(p.angle(l1), p.angle(l2), 90))
Пример #29
0
 def test_axial_addition(self):
     m = Lin(135, 10) + Lin(315, 10)
     self.assertTrue(m.uv == Lin(135, 0))
Пример #30
0
def test_orthogonality_rotation_matrix():
    lin = Lin.rand()
    a = np.random.randint(180)
    R = DefGrad.from_axis(lin, a)
    assert np.allclose(R * R.T, np.eye(3))
Пример #31
0
 def test_dd_property(self):
     lin = Lin(120, 30)
     assert Lin(*lin.dd) == lin
Пример #32
0
def test_stress_invariants_under_rotation():
    S = Stress.from_comp(xx=4, yy=6, zz=8, xy=1, xz=2)
    lin = Lin.rand()
    a = np.random.randint(180)
    Sr = S.rotate(lin, a)
    assert np.allclose([S.I1, S.I2, S.I3], [Sr.I1, Sr.I2, Sr.I3])
Пример #33
0
    def test_angle_under_rotation(self):
        f1, f2 = Fol.rand(), Fol.rand()
        D = DefGrad.from_axis(Lin(45, 45), 60)

        assert np.allclose(f1.angle(f2),
                           f1.transform(D).angle(f2.transform(D)))
Пример #34
0
 def test_aslin_conversion(self):
     assert str(Vec3([1, 1, 1]).aslin) == str(Lin(45, 35))  # `Vec` to `Lin`
     assert str(Vec3(Lin(110, 37)).aslin) == str(Lin(
         110, 37))  # `Lin` to `Vec` to `Lin`
Пример #35
0
 def test_rdegree_under_rotation(self):
     g = Group.randn_lin()
     assert np.allclose(g.rotate(Lin(45, 45), 90).rdegree, g.rdegree)
Пример #36
0
 def test_asvec_conversion(self):
     assert str(Lin(120, 10).asvec3) == str(Vec3(120, 10, 1))
Пример #37
0
 def test_group_heterogenous_error(self):
     with pytest.raises(Exception) as exc:
         Group([Fol(10, 10), Lin(20, 20)])
         assert "All data in group must be of same type." == str(
             exc.exception)
Пример #38
0
 def x(self):
     return Lin(0, 0)
Пример #39
0
 def test_pair_rotate(self):
     p = Pair.rand()
     pr = p.rotate(Lin(45, 45), 120)
     assert np.allclose([p.fvec.angle(p.lvec),
                         pr.fvec.angle(pr.lvec)], [90, 90])
Пример #40
0
 def test_equality_for_oposite_dir(self):
     lin = Lin.rand()
     assert lin == -lin
Пример #41
0
 def test_fault_rotation_sense(self):
     f = Fault(90, 30, 110, 28, -1)
     assert repr(f.rotate(Lin(220, 10), 60)) == 'F:343/37-301/29 +'
Пример #42
0
 def test_equality_for_oposite_dir(self):
     lin = Lin.rand()
     assert lin == -lin