def _cmp_fstruct(self, s1, s2, frac_tol, mask): """ Returns true if a matching exists between s2 and s2 under frac_tol. s2 should be a subset of s1 """ if len(s2) > len(s1): raise ValueError("s1 must be larger than s2") if mask.shape != (len(s2), len(s1)): raise ValueError("mask has incorrect shape") return is_coord_subset_pbc(s2, s1, frac_tol, mask)
def is_coord_subset_pbc(subset, superset, atol=1e-8, mask=None): """ Tests if all fractional coords in subset are contained in superset. Args: subset, superset: List of fractional coords atol (float or size 3 array): Tolerance for matching mask (boolean array): Mask of matches that are not allowed. i.e. if mask[1,2] == True, then subset[1] cannot be matched to superset[2] Returns: True if all of subset is in superset. """ c1 = np.array(subset, dtype=np.float64) c2 = np.array(superset, dtype=np.float64) if mask is not None: m = np.array(mask, dtype=np.int) else: m = np.zeros((len(subset), len(superset)), dtype=np.int) atol = np.zeros(3, dtype=np.float64) + atol return cuc.is_coord_subset_pbc(c1, c2, atol, m)