-
Notifications
You must be signed in to change notification settings - Fork 862
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test return type and reduce function calls in test_plot_periodic_heat…
…map()
- Loading branch information
Showing
10 changed files
with
73 additions
and
72 deletions.
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
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
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
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
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
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 |
---|---|---|
@@ -1,32 +1,35 @@ | ||
from __future__ import annotations | ||
|
||
import matplotlib.pyplot as plt | ||
|
||
from pymatgen.util.plotting import periodic_table_heatmap, van_arkel_triangle | ||
from pymatgen.util.testing import PymatgenTest | ||
|
||
|
||
class FuncTestCase(PymatgenTest): | ||
def test_plot_periodic_heatmap(self): | ||
random_data = { | ||
"Te": 0.11083818874391202, | ||
"Au": 0.7575629917425387, | ||
"Th": 1.2475885304040335, | ||
"Ni": -2.0354391922547705, | ||
} | ||
_ = periodic_table_heatmap(random_data) | ||
_ = periodic_table_heatmap(random_data, cmap="plasma") | ||
_ = periodic_table_heatmap(random_data, max_row=7) | ||
_ = periodic_table_heatmap(random_data, max_row=10) | ||
_ = periodic_table_heatmap(random_data, cbar_label_size=18) | ||
_ = periodic_table_heatmap(random_data, cmap_range=[0, 1]) | ||
_ = periodic_table_heatmap(random_data, cbar_label="Hello World") | ||
_ = periodic_table_heatmap(random_data, blank_color="white") | ||
_ = periodic_table_heatmap(random_data, value_format="%.4f") | ||
_ = periodic_table_heatmap(random_data, edge_color="black") | ||
_ = periodic_table_heatmap(random_data, value_fontsize=12) | ||
_ = periodic_table_heatmap(random_data, symbol_fontsize=18) | ||
_ = periodic_table_heatmap(random_data, readable_fontcolor=True) | ||
random_data = {"Te": 0.11083, "Au": 0.75756, "Th": 1.24758, "Ni": -2.0354} | ||
ret_val = periodic_table_heatmap(random_data) | ||
assert ret_val is plt | ||
|
||
# Test all keywords | ||
periodic_table_heatmap( | ||
random_data, | ||
cmap="plasma", | ||
max_row=10, | ||
cbar_label_size=18, | ||
cmap_range=[0, 1], | ||
cbar_label="Hello World", | ||
blank_color="white", | ||
value_format="%.4f", | ||
edge_color="black", | ||
value_fontsize=12, | ||
symbol_fontsize=18, | ||
readable_fontcolor=True, | ||
) | ||
|
||
def test_van_arkel_triangle(self): | ||
random_list = [("Fe", "C"), ("Ni", "F")] | ||
_ = van_arkel_triangle(random_list) | ||
_ = van_arkel_triangle(random_list, annotate=True) | ||
ret_val = van_arkel_triangle(random_list) | ||
assert ret_val is plt | ||
van_arkel_triangle(random_list, annotate=True) |