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
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
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)
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)
def test_fol_vector_dd(self): fol = Fol(120, 30) assert Lin(*fol.V.dd).asfol == fol
def test_lin_vector_dd(self): lin = Lin(120, 30) assert Lin(*lin.V.dd) == lin
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])
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)))
def test_lineation_product_operator(self): l1, l2 = Lin.rand(), Lin.rand() assert l1.cross(l2) == l1**l2
def test_that_azimuth_0_is_same_as_360(self): assert Lin(0, 20) == Lin(360, 20)
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
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])
def test_lineation_product_operator(self): l1, l2 = Lin.rand(), Lin.rand() assert l1.cross(l2) == l1 ** l2
def test_mutual_rotation(self): l1, l2 = Lin.rand(), Lin.rand() assert l1.transform(l1.H(l2)) == l2
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)
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))
def test_scalar_product(self): lin = Lin.rand() assert np.allclose(lin * lin, 1)
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])
def test_rotation_invariant(self): g = Group.randn_lin() self.assertTrue( np.allclose(g.rotate(Lin(45, 45), 90).rdegree, g.rdegree))
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)
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))
def test_axial_addition(self): m = Lin(135, 10) + Lin(315, 10) self.assertTrue(m.uv == Lin(135, 0))
def test_dd_property(self): lin = Lin(120, 30) assert Lin(*lin.dd) == lin
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)))
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`
def test_rdegree_under_rotation(self): g = Group.randn_lin() assert np.allclose(g.rotate(Lin(45, 45), 90).rdegree, g.rdegree)
def test_asvec_conversion(self): assert str(Lin(120, 10).asvec3) == str(Vec3(120, 10, 1))
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)
def x(self): return Lin(0, 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])
def test_equality_for_oposite_dir(self): lin = Lin.rand() assert lin == -lin
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 +'