Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions tests/test_analyse_symmetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,27 @@ def test_arg_equivalent_vectors(self):
dx_round = np.round(np.absolute(dx), decimals=3)
self.assertEqual(len(np.unique(dx_round + arg_v)), len(np.unique(arg_v)))

def test_get_primitive_cell_pbc_error(self):
structure = bulk("Al", cubic=True)
structure.pbc = [True, True, False]
sym = stk.analyse.get_symmetry(structure=structure)
with self.assertRaisesRegex(ValueError, "Can only symmetrize periodic structures."):
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertRaisesRegex treats the pattern as a regular expression; the trailing . in the message currently matches any character. If the intent is to assert the exact message (including the period), consider escaping/anchoring the pattern (e.g., escape the dot and use ^...$) so the test can’t pass on slightly different messages.

Suggested change
with self.assertRaisesRegex(ValueError, "Can only symmetrize periodic structures."):
with self.assertRaisesRegex(
ValueError, r"^Can only symmetrize periodic structures\.$"
):

Copilot uses AI. Check for mistakes.
sym.get_primitive_cell()

def test_get_primitive_cell_arrays_warning(self):
structure = bulk("Al", cubic=True)
structure.set_array("test_array", np.zeros(len(structure)))
sym = stk.analyse.get_symmetry(structure=structure)
with self.assertLogs(level="WARNING") as cm:
sym.get_primitive_cell()
self.assertTrue(
any(
"Custom arrays {'test_array'} do not carry over to new structure!"
in output
for output in cm.output
)
)

def test_error(self):
"""spglib errors should be wrapped in a SymmetryError."""

Expand Down
Loading