-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix get_crystal_sys raise ValueError on non-positive space group numbers
- Loading branch information
Showing
4 changed files
with
48 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import pytest | ||
from matplotlib.offsetbox import AnchoredText | ||
|
||
from ml_matrics.utils import add_mae_r2_box, get_crystal_sys | ||
|
||
from . import y_pred, y_true | ||
|
||
|
||
def test_add_mae_r2_box(): | ||
|
||
text_box = add_mae_r2_box(y_pred, y_true) | ||
|
||
assert isinstance(text_box, AnchoredText) | ||
|
||
assert text_box.txt.get_text() == "$\\mathrm{MAE} = 0.116$\n$R^2 = 0.740$" | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"input, expected", | ||
[ | ||
(1, "triclinic"), | ||
(15, "monoclinic"), | ||
(16, "orthorhombic"), | ||
(75, "tetragonal"), | ||
(143, "trigonal"), | ||
(168, "hexagonal"), | ||
(230, "cubic"), | ||
], | ||
) | ||
def test_get_crystal_sys(input, expected): | ||
assert expected == get_crystal_sys(input) | ||
|
||
|
||
@pytest.mark.parametrize("spg", [-1, 0, 231]) | ||
def test_get_crystal_sys_invalid(spg): | ||
with pytest.raises(ValueError, match=f"Received invalid space group {spg}"): | ||
get_crystal_sys(spg) |