[docs]@ParametrizeDocstrings@pytest.mark.parametrize("geodim",Physical_dims)@pytest.mark.parametrize("nbody",Few_bodies)deftest_Identity(float64_tols,geodim,nbody):""" Tests properties of the identity transformation. """Id=choreo.ActionSym.Identity(nbody,geodim)assertId.IsIdentity(atol=float64_tols.atol)assertId.IsWellFormed(atol=float64_tols.atol)Id2=Id.Compose(Id)assertId2.IsIdentity(atol=float64_tols.atol)InvId=Id.Inverse()assertId.IsSame(InvId,atol=float64_tols.atol)
[docs]@ParametrizeDocstrings@RepeatTest()@pytest.mark.parametrize("geodim",Physical_dims)@pytest.mark.parametrize("nbody",Few_bodies)deftest_Random(float64_tols,geodim,nbody):""" Tests group properties on random transformations. """Id=choreo.ActionSym.Identity(nbody,geodim)A=choreo.ActionSym.Random(nbody,geodim)AInv=A.Inverse()assertA.IsWellFormed(atol=float64_tols.atol)assertAInv.IsWellFormed(atol=float64_tols.atol)assertId.IsSame(A.Compose(AInv),atol=float64_tols.atol)assertId.IsSame(AInv.Compose(A),atol=float64_tols.atol)B=choreo.ActionSym.Random(nbody,geodim)BInv=B.Inverse()assertnot(A.IsSame(B,atol=float64_tols.atol))AB=A.Compose(B)BA=B.Compose(A)assertAB.IsWellFormed(atol=float64_tols.atol)assertBA.IsWellFormed(atol=float64_tols.atol)n=AB.TimeShiftDenforiinrange(n):tb=B.ApplyT(i,n)tab=A.ApplyT(*tb)asserttab==AB.ApplyT(i,n)ABInv=AB.Inverse()BAInv=BA.Inverse()assertABInv.IsWellFormed(atol=float64_tols.atol)assertBAInv.IsWellFormed(atol=float64_tols.atol)assertABInv.IsSame(BInv.Compose(AInv),atol=float64_tols.atol)assertBAInv.IsSame(AInv.Compose(BInv),atol=float64_tols.atol)C=choreo.ActionSym.Random(nbody,geodim)A_BC=A.Compose(B.Compose(C))AB_C=A.Compose(B).Compose(C)assertA_BC.IsWellFormed(atol=float64_tols.atol)assertAB_C.IsWellFormed(atol=float64_tols.atol)assertA_BC.IsSame(AB_C,atol=float64_tols.atol)
[docs]@ParametrizeDocstrings@pytest.mark.parametrize("geodim",Physical_dims)deftest_rotation_generation(float64_tols,geodim):""" Tests parametrization of the orthogonal group. """n=(geodim*(geodim-1))//2params=np.random.random(n)idmat=np.identity(geodim,dtype=np.float64)mat=choreo.ActionSym.SurjectiveDirectSpaceRot(params)matTmat=np.matmul(mat.T,mat)matmatT=np.matmul(mat,mat.T)assertnp.allclose(matTmat,idmat,rtol=float64_tols.rtol,atol=float64_tols.atol)assertnp.allclose(matmatT,idmat,rtol=float64_tols.rtol,atol=float64_tols.atol)assertabs(scipy.linalg.det(mat)-1.)<float64_tols.atol
[docs]@ParametrizeDocstrings@pytest.mark.parametrize("Sym_list",[pytest.param(Sym_list,id=name)forname,Sym_listinSymList_dict.items()])deftest_Cayley_graph(Sym_list):""" Tests properties of Cayley graphs.Tests:* Strong connectedness* Regularity """nsym=len(Sym_list)ifnsym<1:returnSym=Sym_list[0]nbody=Sym.BodyPerm.shape[0]geodim=Sym.SpaceRot.shape[0]CayleyGraph=choreo.ActionSym.BuildCayleyGraph(nbody,geodim,GeneratorList=Sym_list)assertnetworkx.is_strongly_connected(CayleyGraph)assertlen(Sym_list)*CayleyGraph.number_of_nodes()==CayleyGraph.number_of_edges()fornodeinCayleyGraph:nneigh=0forneighinCayleyGraph.successors(node):nneigh+=1assertnneigh==nsymnneigh=0forneighinCayleyGraph.predecessors(node):nneigh+=1assertnneigh==nsym