Best Python code snippet using pytest-benchmark
test_restrict_isometry.py
Source:test_restrict_isometry.py
...15 space = rot2dOnR2(-1, maximum_frequency=10)16 17 subspace, mapping, _ = space.restrict(4)18 19 self.assertIsInstance(subspace, GSpace2D)20 self.assertEqual(subspace.fibergroup.order(), 4)21 22 self.check_restriction(space, 4)23 def test_restrict_rotations_to_trivial(self):24 25 space = rot2dOnR2(-1, maximum_frequency=10)26 27 subspace, mapping, _ = space.restrict(1)28 29 self.assertIsInstance(subspace, GSpace2D)30 self.assertEqual(subspace.fibergroup.order(), 1)31 self.check_restriction(space, 1)32 def test_restrict_flipsrotations(self):33 34 space = flipRot2dOnR2(-1, maximum_frequency=10)35 36 N=1037 for axis in range(13):38 axis = axis * np.pi / (13*N)39 assert axis <= np.pi / N40 subspace, mapping, _ = space.restrict((axis, N))41 42 self.assertIsInstance(subspace, GSpace2D)43 self.assertEqual(subspace.fibergroup.order(), 2 * N)44 45 self.check_restriction(space, (axis, N))46 47 def test_restrict_flipsrotations_to_rotations(self):48 49 space = flipRot2dOnR2(-1, maximum_frequency=10)50 51 subspace, mapping, _ = space.restrict((None, -1))52 53 self.assertIsInstance(subspace, GSpace2D)54 self.assertEqual(subspace.fibergroup.order(), -1)55 self.check_restriction(space, (None, -1))56 def test_restrict_flipsrotations_to_flips(self):57 58 space = flipRot2dOnR2(-1, maximum_frequency=10)59 for axis in range(13):60 axis = axis * np.pi/13.61 subspace, mapping, _ = space.restrict((axis, 1))62 63 self.assertIsInstance(subspace, GSpace2D)64 self.assertEqual(subspace.fibergroup.order(), 2)65 self.check_restriction(space, (axis, 1))66 67 def test_restrict_fliprotations_to_trivial(self):68 69 space = flipRot2dOnR2(-1, maximum_frequency=10)70 71 subspace, mapping, _ = space.restrict((None, 1))72 73 self.assertIsInstance(subspace, GSpace2D)74 self.assertEqual(subspace.fibergroup.order(), 1)75 76 self.check_restriction(space, (None, 1))77 def test_restrict_flips_to_trivial(self):78 79 space = flip2dOnR2()80 81 subspace, mapping, _ = space.restrict(1)82 83 self.assertIsInstance(subspace, GSpace2D)84 self.assertEqual(subspace.fibergroup.order(), 1)85 self.check_restriction(space, 1)86 ####################################################################################################################87 ### ########################################################################################88 ### 3D isometries ########################################################################################89 ### ########################################################################################90 ####################################################################################################################91 ####### SO(3) ######################################################################################################92 93 def test_restrict_3d_rotations_to_ico(self):94 95 space = rot3dOnR3(maximum_frequency=2)96 97 subspace, mapping, _ = space.restrict('ico')98 99 self.assertIsInstance(subspace, GSpace3D)100 self.assertIsInstance(subspace.fibergroup, Icosahedral)101 102 self.check_restriction(space, 'ico')103 def test_restrict_3d_rotations_to_octa(self):104 space = rot3dOnR3(maximum_frequency=2)105 subspace, mapping, _ = space.restrict('octa')106 self.assertIsInstance(subspace, GSpace3D)107 self.assertIsInstance(subspace.fibergroup, Octahedral)108 self.check_restriction(space, 'octa')109 def test_restrict_3d_rotations_to_2d_rotations(self):110 111 space = rot3dOnR3(maximum_frequency=2)112 113 for n in [-1, 1, 2, 4, 7]:114 sg_id = False, n115 116 subspace, mapping, _ = space.restrict(sg_id)117 118 self.assertIsInstance(subspace, GSpace3D)119 if n > 0:120 self.assertIsInstance(subspace.fibergroup, CyclicGroup)121 else:122 self.assertIsInstance(subspace.fibergroup, SO2)123 self.assertEqual(subspace.fibergroup.order(), n)124 self.check_restriction(space, sg_id)125 def test_restrict_3d_rotations_to_2d_rotations_reflections(self):126 127 space = rot3dOnR3(maximum_frequency=2)128 129 for n in [2, 4]:130 for axis in [0., np.pi/2, np.pi/4]:131 sg_id = axis, n132 133 subspace, mapping, _ = space.restrict(sg_id)134 135 self.assertIsInstance(subspace, GSpace3D)136 self.assertIsInstance(subspace.fibergroup, DihedralGroup)137 self.assertEqual(subspace.fibergroup.order(), 2*n)138 139 self.check_restriction(space, sg_id)140 def test_restrict_3d_rotations_to_2d_reflection(self):141 142 space = rot3dOnR3(maximum_frequency=2)143 144 for axis in [0., np.pi / 2, np.pi / 4]:145 sg_id = axis, 1146 147 subspace, mapping, _ = space.restrict(sg_id)148 149 self.assertIsInstance(subspace, GSpace3D)150 self.assertIsInstance(subspace.fibergroup, CyclicGroup)151 self.assertEqual(subspace.fibergroup.order(), 2)152 153 self.check_restriction(space, sg_id)154 ####### O(3) #######################################################################################################155 def test_restrict_3d_rotationinversion_so3(self):156 space = flipRot3dOnR3(maximum_frequency=2)157 sg_id = 'so3'158 159 subspace, mapping, _ = space.restrict(sg_id)160 self.assertIsInstance(subspace, GSpace3D)161 self.assertIsInstance(subspace.fibergroup, SO3)162 self.check_restriction(space, sg_id)163 164 def test_restrict_3d_rotationinversion_ico(self):165 space = flipRot3dOnR3(maximum_frequency=2)166 sg_id = False, 'ico'167 168 subspace, mapping, _ = space.restrict(sg_id)169 170 self.assertIsInstance(subspace, GSpace3D)171 self.assertIsInstance(subspace.fibergroup, Icosahedral)172 173 self.check_restriction(space, sg_id)174 def test_restrict_3d_rotationinversion_dih_o2(self):175 space = flipRot3dOnR3(maximum_frequency=2)176 177 for axis in [0., np.pi / 2, np.pi / 3, 2 * np.pi]:178 for n in [2, 4]:179 sg_id = (False, axis, n)180 subspace, mapping, _ = space.restrict(sg_id)181 182 self.assertIsInstance(subspace, GSpace3D)183 self.assertIsInstance(subspace.fibergroup, DihedralGroup)184 185 self.check_restriction(space, sg_id)186 def test_restrict_3d_rotationinversion_so2(self):187 188 space = flipRot3dOnR3(maximum_frequency=2)189 for n in [2, 4]:190 sg_id = (False, False, n)191 192 subspace, mapping, _ = space.restrict(sg_id)193 self.assertIsInstance(subspace, GSpace3D)194 self.assertIsInstance(subspace.fibergroup, CyclicGroup)195 self.check_restriction(space, sg_id)196 197 def test_restrict_3d_rotationinversion_flip(self):198 199 space = flipRot3dOnR3(maximum_frequency=2)200 for axis in [0., np.pi / 2, np.pi / 3, 2 * np.pi]:201 202 sg_id = (False, 2*axis, 1)203 204 subspace, mapping, _ = space.restrict(sg_id)205 self.assertIsInstance(subspace, GSpace3D)206 self.assertIsInstance(subspace.fibergroup, CyclicGroup)207 self.check_restriction(space, sg_id)208 def test_restrict_3d_rotationinversion_cone_o2(self):209 210 space = flipRot3dOnR3(maximum_frequency=2)211 for n in [2, 4]:212 # Cone aligned along Z axis213 # i.e., rotation along Z axis214 # on XY plane, mirror wrt Y axis (i.e. flip along X axis)215 sg_id = ('cone', 0., n)216 subspace, mapping, _ = space.restrict(sg_id)217 self.assertIsInstance(subspace, GSpace3D)218 self.assertIsInstance(subspace.fibergroup, DihedralGroup)219 self.check_restriction(space, sg_id)220 # Cone aligned along Z axis221 # i.e., rotation along Z axis222 # on XY plane, mirror wrt X axis (i.e. flip along Y axis)223 sg_id = ('cone', np.pi, n)224 subspace, mapping, _ = space.restrict(sg_id)225 self.assertIsInstance(subspace, GSpace3D)226 self.assertIsInstance(subspace.fibergroup, DihedralGroup)227 self.check_restriction(space, sg_id)228 xyz = space.fibergroup.element(229 (230 0,231 np.array([232 np.sqrt(1./3.) * np.sin(np.pi*2/3),233 np.sqrt(1./3.) * np.sin(np.pi*2/3),234 np.sqrt(1./3.) * np.sin(np.pi*2/3),235 np.cos(np.pi*2/3),236 ])237 ),238 'Q'239 )240 for adj in [xyz, xyz@xyz, xyz @ space.fibergroup.inversion, xyz @ xyz @ space.fibergroup.inversion]:241 sg_id = ('cone', 0., n, adj)242 subspace, mapping, _ = space.restrict(sg_id)243 244 self.assertIsInstance(subspace, GSpace3D)245 self.assertIsInstance(subspace.fibergroup, DihedralGroup)246 247 self.check_restriction(space, sg_id)248 def test_restrict_3d_rotationinversion_mir(self):249 250 space = flipRot3dOnR3(maximum_frequency=2)251 252 # mirror wrt Y axis (i.e. flip along X axis)253 sg_id = ('cone', 0., 1)254 subspace, mapping, _ = space.restrict(sg_id)255 256 self.assertIsInstance(subspace, GSpace3D)257 self.assertIsInstance(subspace.fibergroup, CyclicGroup)258 259 self.check_restriction(space, sg_id)260 261 # mirror wrt X axis (i.e. flip along Y axis)262 sg_id = ('cone', np.pi, 1)263 subspace, mapping, _ = space.restrict(sg_id)264 265 self.assertIsInstance(subspace, GSpace3D)266 self.assertIsInstance(subspace.fibergroup, CyclicGroup)267 268 self.check_restriction(space, sg_id)269 270 xyz = space.fibergroup.element(271 (272 0,273 np.array([274 np.sqrt(1. / 3.) * np.sin(np.pi * 2 / 3),275 np.sqrt(1. / 3.) * np.sin(np.pi * 2 / 3),276 np.sqrt(1. / 3.) * np.sin(np.pi * 2 / 3),277 np.cos(np.pi * 2 / 3),278 ])279 ),280 'Q'281 )282 283 for adj in [xyz, xyz @ xyz, xyz @ space.fibergroup.inversion, xyz @ xyz @ space.fibergroup.inversion]:284 sg_id = ('cone', 0., 1, adj)285 subspace, mapping, _ = space.restrict(sg_id)286 287 self.assertIsInstance(subspace, GSpace3D)288 self.assertIsInstance(subspace.fibergroup, CyclicGroup)289 290 self.check_restriction(space, sg_id)291 def test_restrict_3d_rotationinversion_fullcylinder_c2xo2(self):292 space = flipRot3dOnR3(maximum_frequency=2)293 for n in [2, 4]:294 sg_id = (True, True, n)295 subspace, mapping, _ = space.restrict(sg_id)296 self.assertIsInstance(subspace, GSpace3D)297 self.assertIsInstance(subspace.fibergroup, DirectProductGroup)298 self.assertIsInstance(subspace.fibergroup.G1, CyclicGroup) and subspace.fibergroup.order() == 2299 self.assertIsInstance(subspace.fibergroup.G2, DihedralGroup) and subspace.fibergroup.order() == 2*n300 self.check_restriction(space, sg_id)301 def test_restrict_3d_rotationinversion_cylinder_c2xso2(self):302 space = flipRot3dOnR3(maximum_frequency=2)303 for n in [2, 4]:304 sg_id = (True, False, n)305 subspace, mapping, _ = space.restrict(sg_id)306 self.assertIsInstance(subspace, GSpace3D)307 self.assertIsInstance(subspace.fibergroup, DirectProductGroup)308 self.assertIsInstance(subspace.fibergroup.G1, CyclicGroup) and subspace.fibergroup.order() == 2309 self.assertIsInstance(subspace.fibergroup.G2, CyclicGroup) and subspace.fibergroup.order() == n310 self.check_restriction(space, sg_id)311 def test_restrict_3d_rotationinversion_inv(self):312 313 space = flipRot3dOnR3(maximum_frequency=2)314 315 # Inversion wrt the origin316 sg_id = (True, False, 1)317 318 subspace, mapping, _ = space.restrict(sg_id)319 self.assertIsInstance(subspace, GSpace3D)320 self.assertIsInstance(subspace.fibergroup, CyclicGroup)321 self.check_restriction(space, sg_id)322 ####################################################################################################################323 def check_restriction(self, space: GSpace, subgroup_id):324 subspace, parent, child = space.restrict(subgroup_id)325 326 # rho = space.trivial_repr327 irreps = space.fibergroup.irreps()328 for rho in irreps:329 sub_rho = rho.restrict(subgroup_id)330 331 x = np.random.randn(1, rho.size, 3, 3, 3)332 333 for e in subspace.testing_elements:334 ...
species_test.py
Source:species_test.py
...40 def setUp(self):41 self.conformer = Conformer(smiles='CC')42 self.conformer_torsion_test = Conformer(smiles='CC#CC')43 def test_rmg_molecules(self):44 self.assertIsInstance(self.conformer.rmg_molecule,rmgpy.molecule.Molecule)45 def test_rdkit_mol(self):46 autotst_rdkit = self.conformer.get_rdkit_mol()47 self.assertIsInstance(autotst_rdkit,rdkit.Chem.rdchem.Mol)48 def test_ase_mol(self):49 autotst_ase_mol = self.conformer.get_ase_mol()50 self.assertIsInstance(autotst_ase_mol,ase.Atoms)51 def test_get_molecules(self):52 autotst_rdkit, autotst_ase_mol = self.conformer.get_molecules()53 self.assertIsInstance(autotst_rdkit,rdkit.Chem.rdchem.Mol)54 self.assertIsInstance(autotst_ase_mol,ase.Atoms)55 def test_get_bonds(self):56 bonds = self.conformer.get_bonds()57 self.assertIsInstance(bonds,list)58 self.assertIsInstance(bonds[0],Bond)59 self.assertEquals(len(bonds),7)60 def test_get_angles(self):61 angles = self.conformer.get_angles()62 self.assertIsInstance(angles,list)63 self.assertIsInstance(angles[0],Angle)64 self.assertEquals(len(angles),12)65 def test_get_torsions(self):66 torsions = self.conformer_torsion_test.get_torsions()67 self.assertIsInstance(torsions,list)68 self.assertEquals(len(torsions), 1)69 torsion = torsions[0]70 self.assertIsInstance(torsion, Torsion)71 self.assertEquals(len(torsion.center_atoms),2)72 self.assertEquals(torsion.mask.count(True),4)73 def test_get_cistrans(self):74 cistrans = self.conformer.get_cistrans()75 self.assertIsInstance(cistrans,list)76 self.assertEquals(len(cistrans),0)77 def test_get_chiralcenters(self):78 chiralcenters = self.conformer.get_chiral_centers()79 self.assertIsInstance(chiralcenters,list)80 self.assertEquals(len(chiralcenters),0)81 def test_get_geometries(self):82 geometries = self.conformer.get_geometries()83 self.assertIsInstance(geometries,tuple)84 self.assertIsInstance(geometries[0],list)85 self.assertIsInstance(geometries[0][0],Bond)86 self.assertIsInstance(geometries[1],list)87 self.assertIsInstance(geometries[1][0],Angle)88 self.assertIsInstance(geometries[2],list)89 self.assertIsInstance(geometries[2][0],Torsion)90 self.assertIsInstance(geometries[3],list)91 self.assertIsInstance(geometries[4],list)92 def test_calculate_symmetry_number(self):93 species_to_test = {94 "CC" : 18.0,95 96 }97 self.assertEquals(self.conformer.calculate_symmetry_number(), 18.0)98 def test_get_xyz_block(self):99 xyz_block = self.conformer.get_xyz_block()100 positions = self.conformer.ase_molecule.arrays["positions"]101 for n in range(len(positions)):102 self.assertTrue((np.array([float(x) for x in xyz_block.split('\n')[n].split()[1:]]) == positions[n]).all())103class TestSpecies(unittest.TestCase):104 def setUp(self):105 self.species = Species(smiles=["CC"])106 def test_generate_structures(self):107 self.assertIsInstance(self.species.generate_structures(),dict)108 self.assertIsInstance(list(self.species.generate_structures().values())[0][0],Conformer)109if __name__ == "__main__":...
deps_cpp_info_test.py
Source:deps_cpp_info_test.py
...10 cpp_info.includedirs = ["include1"]11 deps_cpp_info.add("pkg", DepCppInfo(cpp_info))12 info_for_package = deps_cpp_info["pkg"]13 # Documented as list for 'self.cpp_info' object14 self.assertIsInstance(info_for_package.includedirs, list)15 self.assertIsInstance(info_for_package.libdirs, list)16 self.assertIsInstance(info_for_package.resdirs, list)17 self.assertIsInstance(info_for_package.bindirs, list)18 self.assertIsInstance(info_for_package.builddirs, list)19 self.assertIsInstance(info_for_package.libs, list)20 self.assertIsInstance(info_for_package.defines, list)21 self.assertIsInstance(info_for_package.cflags, list)22 self.assertIsInstance(info_for_package.cppflags, list)23 self.assertIsInstance(info_for_package.cxxflags, list)24 self.assertIsInstance(info_for_package.sharedlinkflags, list)25 self.assertIsInstance(info_for_package.exelinkflags, list)26 self.assertIsInstance(info_for_package.frameworks, list)27 self.assertIsInstance(info_for_package.frameworkdirs, list)28 self.assertIsInstance(info_for_package.rootpath, six.string_types)29 self.assertIsInstance(info_for_package.name, six.string_types)30 self.assertIsInstance(info_for_package.system_libs, list)31 self.assertIsInstance(info_for_package.build_modules, dict)32 self.assertIsInstance(info_for_package.components, dict)33 # Documented as list for `deps_cpp_info["pkg"]`34 self.assertIsInstance(info_for_package.include_paths, list)35 self.assertIsInstance(info_for_package.lib_paths, list)36 self.assertIsInstance(info_for_package.bin_paths, list)37 self.assertIsInstance(info_for_package.build_paths, list)38 self.assertIsInstance(info_for_package.res_paths, list)39 self.assertIsInstance(info_for_package.framework_paths, list)40 self.assertIsInstance(info_for_package.build_modules_paths, dict)41 self.assertIsInstance(info_for_package.get_name("generator"), six.string_types)42 self.assertIsInstance(info_for_package.version, six.string_types)...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!