sisl.geom.AtomIndex
- class sisl.geom.AtomIndex
Bases:
AtomCategoryClassify atoms based on indices
- Parameters:
*args (
intorlistofint) – each value will be equivalent toin=set(args)**kwargs (
key,value) – if key is a function it must accept two valuesvalue, atomwherevalueis the value on this command. The function should return anything that can be interpreted as a True/False. Multiplekeyequates to an and statement.
Examples
>>> aidx = AtomIndex(1, 4, 5) >>> geom.sub(aidx) == geom.sub([1, 4, 5]) >>> aidx = AtomIndex(mod=2) # odd indices >>> geom.sub(aidx) == geom.sub(range(1, len(geom), 2)) >>> aidx = ~AtomIndex(mod=2) # even indices >>> geom.sub(aidx) == geom.sub(range(0, len(geom), 2)) >>> aidx = ~AtomIndex(mod=3) # every 3rd atom >>> geom.sub(aidx) == geom.sub(range(0, len(geom), 3)) >>> aidx = AtomIndex(mod=3) # [1, 2, 4, 5, ...]: range(na) - range(0, na, 3) >>> geom.sub(aidx) == geom.sub(range(0, len(geom), 3))
Methods
categorize(geometry[, atoms])Do categorization
is_class(name[, case])Query whether
namematches the class name by removing a prefixkwkw(**kwargs)Create categories based on keywords
Attributes
Name of category
- categorize(geometry, atoms=None)[source]
Do categorization
- Parameters:
geometry (Geometry)
atoms (AtomsIndex)
- classmethod is_class(name, case=True)
Query whether
namematches the class name by removing a prefixkwThis is important to ensure that users match the full class name by omitting the prefix returned from this method.
This is an abstract method to ensure sub-classes of Category implements it.
For instance:
class MyCategory(Category): @classmethod def is_class(cls, name): # strip "My" and do comparison return cl.__name__.lower()[2:] == name.lower()
would enable one to compare against the base category scheme.
This has the option to search case-sensitivity or not.
- Return type:
- classmethod kw(**kwargs)
Create categories based on keywords
This will search through the inherited classes and return and & category object for all keywords.
Since this is a class method one should use this on the base category class in the given section of the code.
- property name
Name of category