Skip to content

Commit

Permalink
Fix log printing for some cases using -ss
Browse files Browse the repository at this point in the history
  • Loading branch information
hmcezar committed Sep 27, 2023
1 parent 052107b commit cbe7461
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 7 additions & 1 deletion clusttraj/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,13 @@ def __str__(self) -> str:
return_str += f"Method: {self.method}\n"
if self.silhouette_score:
return_str += "\nUsing silhouette score\n"
return_str += f"RMSD criterion found by silhouette: {self.optimal_cut[0]}\n"
if isinstance(self.optimal_cut, (np.ndarray, list)):
scut = self.optimal_cut[0]
elif isinstance(self.optimal_cut, (float, np.float32, np.float64)):
scut = self.optimal_cut
else:
raise ValueError("optimal_cut must be a float or np.ndarray")
return_str += f"RMSD criterion found by silhouette: {scut}\n"
else:
return_str += f"RMSD criterion: {self.min_rmsd}\n"
return_str += f"Ignoring hydrogens?: {self.no_hydrogen}\n"
Expand Down
7 changes: 4 additions & 3 deletions clusttraj/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ def plot_dendrogram(clust_opt: ClustOptions, Z: np.ndarray) -> None:

# Add a horizontal line at the minimum RMSD value
if clust_opt.silhouette_score:
if isinstance(clust_opt.optimal_cut, np.ndarray):
if isinstance(clust_opt.optimal_cut, (np.ndarray, list)):
plt.axhline(clust_opt.optimal_cut[0], linestyle="--")

if isinstance(clust_opt.optimal_cut, (float, np.float32, np.float64)):
elif isinstance(clust_opt.optimal_cut, (float, np.float32, np.float64)):
plt.axhline(clust_opt.optimal_cut, linestyle="--")
else:
raise ValueError("optimal_cut must be a float or np.ndarray")
else:
plt.axhline(clust_opt.min_rmsd, linestyle="--")

Expand Down

0 comments on commit cbe7461

Please sign in to comment.