def test_subkeys_subkeys(self): atom_dep_quality = AdfKey( "AtomDepQuality", subkeys=[AdfKey("10", ["good"]), AdfKey("12", ["normal"])]) zlmfit = AdfKey("zlmfit", subkeys=[atom_dep_quality]) self.assertEqual(str(zlmfit), zlmfit_string) self.assertEqual(str(AdfKey.from_dict(zlmfit.as_dict())), zlmfit_string)
def test_option_operations(self): k1 = AdfKey("Charge", [-1, 0]) k1.add_option(2) self.assertListEqual(k1.options, [-1, 0, 2]) k1.remove_option(0) self.assertListEqual(k1.options, [0, 2]) k2 = AdfKey.from_string("step rad=0.15 angle=10.0") k2.add_option(["length", 0.1]) self.assertListEqual(k2.options[2], ["length", 0.1]) k2.remove_option("rad") self.assertListEqual(k2.options[0], ["angle", 10.0])
def test_subkeys(self): smooth = AdfKey("smooth", ["conservepoints"]) optim = AdfKey("optim", ["all", "cartesian"]) iterations = AdfKey("iterations", [250]) step = AdfKey("step", [("rad", 0.15), ("angle", 10.0)]) hessupd = AdfKey("hessupd", ["BFGS"]) converge = AdfKey("converge", [("e", 1.0e-3), ("grad", 3.0e-4), ("rad", 1.0e-2), ("angle", 0.5)]) geo = AdfKey( "geometry", subkeys=[smooth, optim, iterations, step, hessupd, converge]) self.assertEqual(str(geo), geometry_string) self.assertEqual(str(AdfKey.from_dict(geo.as_dict())), geometry_string) self.assertTrue(geo.has_subkey("optim"))
def test_simple(self): unrestricted = AdfKey("unrestricted") self.assertEqual(str(unrestricted).strip(), 'UNRESTRICTED')
def test_atom_block_key(self): block = AdfKey("atoms") o = Molecule.from_str(h2oxyz, "xyz") for site in o: block.add_subkey(AdfKey(str(site.specie), list(site.coords))) self.assertEqual(str(block), atoms_string)
def test_end(self): geo = AdfKey("Geometry") self.assertEqual(str(geo), "GEOMETRY\nEND\n")
def test_options(self): charge = AdfKey("charge", [-1, 0]) charge_string = "CHARGE -1 0\n" self.assertEqual(str(charge), "CHARGE -1 0\n") self.assertEqual(str(AdfKey.from_dict(charge.as_dict())), charge_string)