Skip to content

Commit

Permalink
fixed test for constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasHelfer committed Dec 29, 2023
1 parent fea65b9 commit e5b987c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/test_Constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@


def test_Constraints():
"""
Test the Constraints class for correctness.
This function tests the Constraints class by comparing its output with precomputed data.
It reads test data for variable X from a specified directory, computes the necessary
derivatives, and checks if the output of the Constraints class is within a specified
tolerance level of the expected values.
The test passes if the computed values are sufficiently close to the expected values,
within a specified tolerance level.
"""
# Define the path to the test data files for variable X
filenamesX = os.path.dirname(__file__) + "/TestData/Xdata_level0_step*"

Expand All @@ -36,6 +47,7 @@ def test_Constraints():
d1 = TensorDict(diff1(dataX, oneoverdx), keys_all)
h_UU = torch.inverse(vars["h"])
chris = compute_christoffel(d1["h"], h_UU)
out = constraint_equations(vars, d1, d2, h_UU, chris)

assert (f"{torch.mean(torch.abs(out['Ham']-vars['Ham']))}") < tol

Expand Down

0 comments on commit e5b987c

Please sign in to comment.