Skip to content

Commit 5fc7e48

Browse files
clean_test
1 parent 0342793 commit 5fc7e48

File tree

3 files changed

+65
-278
lines changed

3 files changed

+65
-278
lines changed

tests/test_components/autograd/numerical/test_autograd_box_polyslab_numerical.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,21 @@
4242
if SHOW_PRINT_STATEMENTS:
4343
sys.stdout = sys.stderr
4444

45+
def angled_overlap_deg(v1, v2):
46+
norm_v1 = np.linalg.norm(v1)
47+
norm_v2 = np.linalg.norm(v2)
48+
49+
if np.isclose(norm_v1, 0.0) or np.isclose(norm_v2, 0.0):
50+
if not (np.isclose(norm_v1, 0.0) and np.isclose(norm_v2, 0.0)):
51+
return np.inf
52+
53+
return 0.0
54+
55+
dot = np.minimum(1.0, np.sum((v1 / np.linalg.norm(v1)) * (v2 / np.linalg.norm(v2))))
56+
angle_deg = np.arccos(dot) * 180.0 / np.pi
57+
58+
return angle_deg
59+
4560

4661
def dimension_permutation(infinite_dim: int) -> tuple[int, int]:
4762
offset_dim = (1 + infinite_dim) % 3
@@ -404,21 +419,6 @@ def test_box_and_polyslab_gradients_match(is_3d, infinite_dim_2d, shift_box_cent
404419
**test_data,
405420
)
406421

407-
def angled_overlap_deg(v1, v2):
408-
norm_v1 = np.linalg.norm(v1)
409-
norm_v2 = np.linalg.norm(v2)
410-
411-
if np.isclose(norm_v1, 0.0) or np.isclose(norm_v2, 0.0):
412-
if not (np.isclose(norm_v1, 0.0) and np.isclose(norm_v2, 0.0)):
413-
return np.inf
414-
415-
return 0.0
416-
417-
dot = np.minimum(1.0, np.sum((v1 / np.linalg.norm(v1)) * (v2 / np.linalg.norm(v2))))
418-
angle_deg = np.arccos(dot) * 180.0 / np.pi
419-
420-
return angle_deg
421-
422422
box_polyslab_overlap_deg = angled_overlap_deg(box_grad_filtered, polyslab_grad_filtered)
423423
fd_overlap_deg = angled_overlap_deg(fd_box, fd_polyslab)
424424
box_fd_adj_overlap_deg = angled_overlap_deg(box_grad_filtered, fd_box)

0 commit comments

Comments
 (0)