def test__from_data(): """ test getters """ assert C2H2CLF_GEO == geom.from_data( syms=geom.symbols(C2H2CLF_GEO), xyzs=geom.coordinates(C2H2CLF_GEO), )
def format_coords(geo): """ format the coords section """ # Get the number of atoms natoms = len(geo) # Get the geometry information symbols = geom.symbols(geo) coordinates = geom.coordinates(geo) masses = geom.masses(geo) print(masses) # Build a string with the formatted coordinates string if geom.is_atom(geo): geo_str = '{0:<4s}{1:<6d}'.format(symbols[0], masses[0]) else: geo_str = '{0} \n'.format(str(natoms)) for symbol, mass, coords in zip(symbols, masses, coordinates): coords = [coord * phycon.BOHR2ANG for coord in coords] coords_str = '{0:>14.8f}{1:>14.8f}{2:>14.8f}'.format( coords[0], coords[1], coords[2]) geo_str += '{0:<4s}{1:<6.0f}{2}\n'.format(symbol, mass, coords_str) # Remove final newline character from the string geo_str = geo_str.rstrip() return natoms, geo_str
def format_coords(geo): """ format the coords section """ # Get the number of atoms natoms = len(geo) # Get the geometry information symbs = geom.symbols(geo) coords = geom.coordinates(geo) masses = tuple(round(mass) for mass in geom.masses(geo)) # Build a string with the formatted coordinates string if geom.is_atom(geo): geo_str = f'{symbs[0]:<4s}{masses[0]:<6d}' else: geo_str = f'{str(natoms)} \n' for symb, mass, xyzs in zip(symbs, masses, coords): _xyzs = [x * phycon.BOHR2ANG for x in xyzs] xyzs_str = f'{_xyzs[0]:>14.8f}{_xyzs[1]:>14.8f}{_xyzs[2]:>14.8f}' geo_str += f'{symb:<4s}{mass:<6.0f}{xyzs_str}\n' # Remove final newline character from the string geo_str = geo_str.rstrip() return natoms, geo_str
def test__from_data(): """ test geom.from_data """ assert C2H2CLF_GEO == geom.from_data( symbols=geom.symbols(C2H2CLF_GEO), coordinates=geom.coordinates(C2H2CLF_GEO), )
def test__is_valid(): """ test geom.is_valid """ # Check validity assert geom.is_valid(C2H2CLF_GEO) # with pytest.raises(ValueError): # geom.is_valid(BAD_GEO) # Check empty geom returns empty information assert not geom.symbols(()) assert not geom.coordinates(())