lammpsio.LabelMap

class lammpsio.LabelMap(map=None)

Map between integer type IDs and string type names.

A LabelMap is effectively a dictionary associating a label (type) with a particle’s or connection’s typeid. These labels can be useful for tracking the meaning of typeids. They are also automatically used when interconverting with HOOMD GSD files that require such labels.

Parameters:

map (dict) – Map of typeids to types.

Example

Create LabelMap:

type_label = lammpsio.topology.LabelMap({1: "A", 2: "B"})

This creates a dictionary mapping numeric type ID labels 1 and 2 used by LAMMPS to alphanumeric type labels “A” and “B”, such as those used by HOOMD-blue. The map can be accessed directly:

assert type_label[1] == "A"

The LabelMap additionally supports inverse mapping from type label to type ID:

assert type_label.inverse["B"] == 2

Methods:

clear()

get(k[,d])

items()

keys()

pop(k[,d])

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem()

as a 2-tuple; but raise KeyError if D is empty.

setdefault(k[,d])

update([E, ]**F)

If E present and has a .keys() method, does: for k in E.keys(): D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values()

Attributes:

inverse

Inverse map from type label to type id.

typeid

Type IDs in map.

types

Types in map.

clear() None.  Remove all items from D.
get(k[, d]) D[k] if k in D, else d.  d defaults to None.
items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
pop(k[, d]) v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem() (k, v), remove and return some (key, value) pair

as a 2-tuple; but raise KeyError if D is empty.

setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D
update([E, ]**F) None.  Update D from mapping/iterable E and F.

If E present and has a .keys() method, does: for k in E.keys(): D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values() an object providing a view on D's values
property types

Types in map.

Type:

tuple of str

property typeid

Type IDs in map.

Type:

tuple of int

property inverse

Inverse map from type label to type id.

Type:

dict