Skip to content

Commit

Permalink
migrate ConnectivityAttrs
Browse files Browse the repository at this point in the history
  • Loading branch information
jandom committed Aug 20, 2023
1 parent 828ed6c commit 1153df5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
28 changes: 22 additions & 6 deletions doc/source/scripts/gen_topologyparser_attrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,29 @@ def _supported_formats(name, singular, description):
self.table_writer.get_lines_and_write_table()


class ConnectivityAttrs(TopologyAttrs):
headings = ("Atom", "AtomGroup", "Supported formats")
filename = "generated/topology/connectivityattrs.txt"
class ConnectivityAttrs:
def __init__(self, attrs) -> None:
def _atom(name, singular, *args):
return singular

def _atomgroup(name, *args):
return name

def _set_up_input(self):
inp = [[x] * 3 for x in "bonds angles dihedrals impropers".split()]
return inp
def _supported_formats(name, singular, description):
return ", ".join(sorted(attrs[name]))

input_items = [[x] * 3 for x in ("bonds", "angles", "dihedrals", "impropers")]
self.table_writer = TableWriter(
headings=("Atom", "AtomGroup", "Supported formats"),
filename="generated/topology/connectivityattrs.txt",
input_items=input_items,
columns={
"Atom": _atom,
"AtomGroup": _atomgroup,
"Supported formats": _supported_formats,
},
)
self.table_writer.get_lines_and_write_table()


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ def test_ConnectivityAttrs(snapshot):
with patch("builtins.open"):
top = TopologyParsers()
ca = ConnectivityAttrs(top.attrs)
assert ca.lines == snapshot
assert ca.table_writer.lines == snapshot

0 comments on commit 1153df5

Please sign in to comment.