Skip to content

Commit

Permalink
improve Transformation return_ranked_list kwarg doc string
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh committed May 13, 2023
1 parent 2f4daf4 commit 563ffb9
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 77 deletions.
18 changes: 9 additions & 9 deletions dev_scripts/chemenv/get_plane_permutations_optimized.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ def random_permutations_iterator(initial_permutation, n_permutations):
points_perfect=points_perfect,
)

mycsms = [c["symmetry_measure"] for c in csms]
my_csms = [c["symmetry_measure"] for c in csms]
prt1(string="Continuous symmetry measures", printing_volume=printing_volume)
prt1(string=mycsms, printing_volume=printing_volume)
prt1(string=my_csms, printing_volume=printing_volume)
csms_with_recorded_permutation = []
explicit_permutations = []
for icsm, csm in enumerate(csms):
Expand Down Expand Up @@ -378,19 +378,19 @@ def random_permutations_iterator(initial_permutation, n_permutations):
points_perfect=points_perfect,
)

mycsms = [c["symmetry_measure"] for c in csms]
imin = np.argmin(mycsms)
mincsm = min(mycsms)
my_csms = [c["symmetry_measure"] for c in csms]
imin = np.argmin(my_csms)
mincsm = min(my_csms)
if not mincsm < 1.0:
print("Following is not close enough to 0.0 ...")
input(mycsms)
print("Following is not close enough to 0 ...")
input(my_csms)
mincsm_indices = []
for icsm, csm in enumerate(mycsms):
for icsm, csm in enumerate(my_csms):
if np.isclose(mincsm, csm, rtol=0.0):
mincsm_indices.append(icsm)
this_plane_sep_perm = tuple(sep_perms[imin])
prt2(
string=f" permutation {'-'.join(map(str, this_plane_sep_perm))} gives csm={mycsms[imin]:.6f}",
string=f" permutation {'-'.join(map(str, this_plane_sep_perm))} gives csm={my_csms[imin]:.6f}",
printing_volume=printing_volume,
)

Expand Down
2 changes: 1 addition & 1 deletion dev_scripts/chemenv/test_algos.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
print("Number of permutations tested : ", len(results[0]))
algos_results.append(min(results[0]))

if not np.isclose(min(results[0]), 0.0):
if not np.isclose(min(results[0]), 0):
print("Following is not 0.0 ...")
input(results)
print(" => ", algos_results)
Expand Down
26 changes: 13 additions & 13 deletions dev_scripts/chemenv/view_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,27 @@
print(algo)
print()
# Visualize the separation plane of a given algorithm
sepplane = False
sep_plane = False
if any(algo.algorithm_type == SEPARATION_PLANE for algo in cg.algorithms):
test = input("Enter index of the algorithm for which you want to visualize the plane : ")
if test != "":
try:
ialgo = int(test)
algo = cg.algorithms[ialgo]
sepplane = True
sep_plane = True
except Exception:
print(
"Unable to determine the algorithm/separation_plane you want "
"to visualize for this geometry. Continues without ..."
)
myfactor = 3.0
my_factor = 3
if vis is None:
vis = visualize(cg=cg, zoom=1.0, myfactor=myfactor)
vis = visualize(cg=cg, zoom=1, myfactor=my_factor)
else:
vis = visualize(cg=cg, vis=vis, myfactor=myfactor)
cg_points = [myfactor * np.array(pp) for pp in cg.points]
cg_central_site = myfactor * np.array(cg.central_site)
if sepplane:
vis = visualize(cg=cg, vis=vis, myfactor=my_factor)
cg_points = [my_factor * np.array(pp) for pp in cg.points]
cg_central_site = my_factor * np.array(cg.central_site)
if sep_plane:
pts = [cg_points[ii] for ii in algo.plane_points]
if algo.minimum_number_of_points == 2:
pts.append(cg_central_site)
Expand All @@ -92,23 +92,23 @@
p3 = centre - factor * (pts[0] - centre)
p4 = centre - perp

vis.add_faces([[p1, p2, p3, p4]], [1.0, 0.0, 0.0], opacity=0.5)
vis.add_faces([[p1, p2, p3, p4]], [1, 0, 0], opacity=0.5)

target_radius = 0.25
radius = 1.5 * target_radius

if algo.minimum_number_of_points == 2:
vis.add_partial_sphere(
coords=cg_central_site, radius=radius, color=[1.0, 0.0, 0.0], start=0, end=360, opacity=0.5
coords=cg_central_site, radius=radius, color=[1, 0, 0], start=0, end=360, opacity=0.5
)
for pp in pts:
vis.add_partial_sphere(coords=pp, radius=radius, color=[1.0, 0.0, 0.0], start=0, end=360, opacity=0.5)
vis.add_partial_sphere(coords=pp, radius=radius, color=[1, 0, 0], start=0, end=360, opacity=0.5)

ps1 = [cg_points[ii] for ii in algo.point_groups[0]]
ps2 = [cg_points[ii] for ii in algo.point_groups[1]]

for pp in ps1:
vis.add_partial_sphere(coords=pp, radius=radius, color=[0.0, 1.0, 0.0], start=0, end=360, opacity=0.5)
vis.add_partial_sphere(coords=pp, radius=radius, color=[0, 1, 0], start=0, end=360, opacity=0.5)
for pp in ps2:
vis.add_partial_sphere(coords=pp, radius=radius, color=[0.0, 0.0, 1.0], start=0, end=360, opacity=0.5)
vis.add_partial_sphere(coords=pp, radius=radius, color=[0, 0, 1], start=0, end=360, opacity=0.5)
vis.show()
18 changes: 9 additions & 9 deletions pymatgen/analysis/local_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def _get_valences(self):
valences = bv.get_valences(self._structure)
except Exception:
try:
bv = BVAnalyzer(symm_tol=0.0)
bv = BVAnalyzer(symm_tol=0)
self._structure = bv.get_oxi_state_decorated_structure(self._structure)
valences = bv.get_valences(self._structure)
except Exception:
Expand Down Expand Up @@ -1313,13 +1313,13 @@ class MinimumDistanceNN(NearNeighbors):
(relative) distance tolerance parameter.
"""

def __init__(self, tol: float = 0.1, cutoff=10.0, get_all_sites=False):
def __init__(self, tol: float = 0.1, cutoff=10, get_all_sites=False):
"""
Args:
tol (float): tolerance parameter for neighbor identification
(default: 0.1).
cutoff (float): cutoff radius in Angstrom to look for trial
near-neighbor sites (default: 10.0).
near-neighbor sites (default: 10).
get_all_sites (bool): If this is set to True then the neighbor
sites are only determined by the cutoff radius, tol is ignored
"""
Expand Down Expand Up @@ -1718,13 +1718,13 @@ class MinimumOKeeffeNN(NearNeighbors):
to calculate relative distances.
"""

def __init__(self, tol: float = 0.1, cutoff=10.0):
def __init__(self, tol: float = 0.1, cutoff=10):
"""
Args:
tol (float): tolerance parameter for neighbor identification
(default: 0.1).
cutoff (float): cutoff radius in Angstrom to look for trial
near-neighbor sites (default: 10.0).
near-neighbor sites (default: 10).
"""
self.tol = tol
self.cutoff = cutoff
Expand Down Expand Up @@ -1813,13 +1813,13 @@ class MinimumVIRENN(NearNeighbors):
to calculate relative distances.
"""

def __init__(self, tol: float = 0.1, cutoff=10.0):
def __init__(self, tol: float = 0.1, cutoff=10):
"""
Args:
tol (float): tolerance parameter for neighbor identification
(default: 0.1).
cutoff (float): cutoff radius in Angstrom to look for trial
near-neighbor sites (default: 10.0).
near-neighbor sites (default: 10).
"""
self.tol = tol
self.cutoff = cutoff
Expand Down Expand Up @@ -2020,7 +2020,7 @@ def get_okeeffe_distance_prediction(el1, el2):
return r1 + r2 - r1 * r2 * pow(sqrt(c1) - sqrt(c2), 2) / (c1 * r1 + c2 * r2)


def get_neighbors_of_site_with_index(struct, n, approach="min_dist", delta=0.1, cutoff=10.0):
def get_neighbors_of_site_with_index(struct, n, approach="min_dist", delta=0.1, cutoff=10):
"""
Returns the neighbors of a given site using a specific neighbor-finding
method.
Expand Down Expand Up @@ -2052,7 +2052,7 @@ def get_neighbors_of_site_with_index(struct, n, approach="min_dist", delta=0.1,
raise RuntimeError(f"unsupported neighbor-finding method ({approach}).")


def site_is_of_motif_type(struct, n, approach="min_dist", delta=0.1, cutoff=10.0, thresh=None):
def site_is_of_motif_type(struct, n, approach="min_dist", delta=0.1, cutoff=10, thresh=None):
"""
Returns the motif type of the site with index n in structure struct;
currently featuring "tetrahedral", "octahedral", "bcc", and "cp"
Expand Down
Loading

0 comments on commit 563ffb9

Please sign in to comment.