Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __getitem__(self, index):
new_index = Element.number_from_specie(index)
return self.matrix[index]
def get_tol(self, specie1, specie2):
"""
Returns the tolerance between two species.
Args:
specie1, specie2: the atomic number (int or float), name (str), symbol (str),
an Element object, or a pymatgen Specie object
Returns:
the tolerance between the provided pair of atomic species
"""
if self.prototype == "single_value":
return self.matrix[0][0]
index1 = Element.number_from_specie(specie1)
index2 = Element.number_from_specie(specie2)
if index1 is not None and index2 is not None:
return self.matrix[index1][index2]
else:
return None
def get_tol(self, specie1, specie2):
"""
Returns the tolerance between two species.
Args:
specie1, specie2: the atomic number (int or float), name (str), symbol (str),
an Element object, or a pymatgen Specie object
Returns:
the tolerance between the provided pair of atomic species
"""
if self.prototype == "single_value":
return self.matrix[0][0]
index1 = Element.number_from_specie(specie1)
index2 = Element.number_from_specie(specie2)
if index1 is not None and index2 is not None:
return self.matrix[index1][index2]
else:
return None
def set_tol(self, specie1, specie2, value):
"""
Sets the distance tolerance between two species.
Args:
specie1, specie2: the atomic number (int or float), name (str), symbol (str),
an Element object, or a pymatgen Specie object
value:
the tolerance (in Angstroms) to set to
"""
index1 = Element.number_from_specie(specie1)
index2 = Element.number_from_specie(specie2)
if index1 is None or index2 is None:
return
self.matrix[index1][index2] = float(value)
if index1 != index2:
self.matrix[index2][index1] = float(value)
if (index1, index2) not in self.custom_values and (
index2,
index1,
) not in self.custom_values:
larger = max(index1, index2)
smaller = min(index1, index2)
self.custom_values.append((smaller, larger))
def set_tol(self, specie1, specie2, value):
"""
Sets the distance tolerance between two species.
Args:
specie1, specie2: the atomic number (int or float), name (str), symbol (str),
an Element object, or a pymatgen Specie object
value:
the tolerance (in Angstroms) to set to
"""
index1 = Element.number_from_specie(specie1)
index2 = Element.number_from_specie(specie2)
if index1 is None or index2 is None:
return
self.matrix[index1][index2] = float(value)
if index1 != index2:
self.matrix[index2][index1] = float(value)
if (index1, index2) not in self.custom_values and (
index2,
index1,
) not in self.custom_values:
larger = max(index1, index2)
smaller = min(index1, index2)
self.custom_values.append((smaller, larger))