-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix typing, fix 2D plotting issues #896
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
60b9529
fix typing, fix 2D plotting issues
IAlibay 8fa795a
Merge branch 'main' into fix-mypy
IAlibay 8957edf
Update plotting.py
IAlibay 903af15
Ignore extra flatten calls
IAlibay 03d2213
Add smoke tests
IAlibay 7ceeb02
Add changelog
IAlibay 60f45b8
ignore one more flatten call
IAlibay 1b88fd0
Merge branch 'main' into fix-mypy
mikemhenry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
**Added:** | ||
|
||
* <news item> | ||
|
||
**Changed:** | ||
|
||
* <news item> | ||
|
||
**Deprecated:** | ||
|
||
* <news item> | ||
|
||
**Removed:** | ||
|
||
* <news item> | ||
|
||
**Fixed:** | ||
|
||
* 2D RMSD plotting now allows for fewer than 5 states (PR #896). | ||
* 2D RMSD plotting no longer draws empty axes when | ||
the number of states - 1 is not divisible by 4 (PR #896). | ||
|
||
**Security:** | ||
|
||
* <news item> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,24 +82,40 @@ def plot_lambda_transition_matrix(matrix: npt.NDArray) -> Axes: | |
) | ||
|
||
# anotate axes | ||
base_settings = { | ||
base_settings: dict[str, Union[str, int]] = { | ||
'size': 10, 'va': 'center', 'ha': 'center', 'color': 'k', | ||
'family': 'sans-serif' | ||
} | ||
for i in range(num_states): | ||
ax.annotate( | ||
i, xy=(i + 0.5, 1), xytext=(i + 0.5, num_states + 0.5), | ||
text=f"{i}", | ||
xy=(i + 0.5, 1), | ||
xytext=(i + 0.5, num_states + 0.5), | ||
xycoords='data', | ||
textcoords=None, | ||
arrowprops=None, | ||
annotation_clip=None, | ||
**base_settings, | ||
) | ||
ax.annotate( | ||
i, xy=(-0.5, num_states - (num_states - 0.5)), | ||
text=f"{i}", | ||
xy=(-0.5, num_states - (num_states - 0.5)), | ||
xytext=(-0.5, num_states - (i + 0.5)), | ||
xycoords='data', | ||
textcoords=None, | ||
arrowprops=None, | ||
annotation_clip=None, | ||
**base_settings, | ||
) | ||
|
||
ax.annotate( | ||
r"$\lambda$", xy=(-0.5, num_states - (num_states - 0.5)), | ||
r"$\lambda$", | ||
xy=(-0.5, num_states - (num_states - 0.5)), | ||
xytext=(-0.5, num_states + 0.5), | ||
xycoords='data', | ||
textcoords=None, | ||
arrowprops=None, | ||
annotation_clip=None, | ||
**base_settings, | ||
) | ||
|
||
|
@@ -278,15 +294,21 @@ def plot_2D_rmsd(data: list[list[float]], | |
fig, axes = plt.subplots(nrows, 4) | ||
|
||
for i, (arr, ax) in enumerate( | ||
zip(twod_rmsd_arrs, chain.from_iterable(axes))): | ||
zip(twod_rmsd_arrs, axes.flatten())): # type: ignore | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for some reason the return type for axes can be Axes | ndarray, but in our use case we always have ndarray (because we set ncols to 4). |
||
ax.imshow(arr, | ||
vmin=0, vmax=vmax, | ||
cmap=plt.get_cmap('cividis')) | ||
ax.axis('off') # turn off ticks/labels | ||
ax.set_title(f'State {i}') | ||
|
||
plt.colorbar(axes[0][0].images[0], | ||
cax=axes[-1][-1], | ||
# if we have any leftover plots then we turn them off | ||
# except the last one! | ||
overage = len(axes.flatten()) - len(twod_rmsd_arrs) # type: ignore | ||
for i in range(overage, len(axes.flatten())-1): # type: ignore | ||
axes.flatten()[i].set_axis_off() # type: ignore | ||
|
||
plt.colorbar(axes.flatten()[0].images[0], # type: ignore | ||
cax=axes.flatten()[-1], # type: ignore | ||
label="RMSD scale (A)", | ||
orientation="horizontal") | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding the defaults is a bit much, but thought I might as well be explicit... thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it!