Skip to content

Commit

Permalink
add tests for invalid values
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielYang59 committed Apr 3, 2024
1 parent 5e91f39 commit 96ba966
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions tests/relation/test_relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,36 @@ def test_eval_limit_potential_2D(self):
)

delta_E_relation.eval_limit_potential_2D(
x = np.arange(0, 10, 10),
y = np.arange(0, 10, 10),
x=np.arange(0, 10, 10),
y=np.arange(0, 10, 10),
)

def test_invalid_eval_limit_potential_2D(self):
# Test invalid dim
with pytest.raises(
ValueError, match="Expect a Relation with two descriptors"
):
delta_E_relation = DeltaERelation(
coefficients=[np.random.rand(4), np.random.rand(4)]
)

delta_E_relation.eval_limit_potential_2D(
x=np.arange(0, 10, 10),
y=np.arange(0, 10, 10),
)

# Test invalid base arrays
delta_E_relation = DeltaERelation(
coefficients=[np.random.rand(3), np.random.rand(3)]
)
with pytest.raises(TypeError, match="Expect 1D x array"):
delta_E_relation.eval_limit_potential_2D(
x=list(range(10)),
y=np.arange(0, 10, 10),
)

with pytest.raises(TypeError, match="Expect 1D y array"):
delta_E_relation.eval_limit_potential_2D(
x=np.arange(0, 10, 10),
y=np.random.rand(0, 10, 10, 2), # should be 1D
)

0 comments on commit 96ba966

Please sign in to comment.