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_group_examples(self): exlist = Group.examples() for ex in exlist: g = Group.examples(ex) assert g.name == ex
def test_group_type_error(self): with pytest.raises(Exception) as exc: Group([1, 2, 3]) assert "Data must be Fol, Lin or Vec3 type." == str(exc.exception)
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 test_rdegree_under_rotation(self): g = Group.randn_lin() assert np.allclose(g.rotate(Lin(45, 45), 90).rdegree, g.rdegree)
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_group_examples(self): exlist = Group.examples() for ex in exlist: g = Group.examples(ex)
def test_ortensor_uniform(): f = Fol.rand() assert np.allclose( Ortensor.from_group(Group([f.V, f.rake(-45), f.rake(45)]))._evals, np.ones(3) / 3)
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.from_array([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_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_rotation_invariant(self): g = Group.randn_lin() self.assertTrue( np.allclose(g.rotate(Lin(45, 45), 90).rdegree, g.rdegree))
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)