MCPcopy Create free account
hub / github.com/MinishLab/vicinity / test_normalize_or_copy

Function test_normalize_or_copy

tests/test_utils.py:29–45  ·  view source on GitHub ↗

Test the normalize_or_copy function.

()

Source from the content-addressed store, hash-verified

27
28
29def test_normalize_or_copy() -> None:
30 """Test the normalize_or_copy function."""
31 # Test when vectors are already normalized
32 vectors = np.array([[1.0, 0.0], [0.0, 1.0]])
33 result = normalize_or_copy(vectors)
34 assert result is vectors, "Should return the original array"
35
36 # Test when vectors are not normalized
37 vectors = np.array([[3.0, 4.0], [5.0, 12.0]])
38 result = normalize_or_copy(vectors)
39 assert result is not vectors, "Should return a new array"
40
41 # Test with zero vectors
42 zero_vectors = np.array([[0.0, 0.0], [0.0, 0.0]])
43 result_zero = normalize_or_copy(zero_vectors)
44 assert_array_equal(result_zero, zero_vectors)
45 assert result_zero is zero_vectors, "Should return the original array"

Callers

nothing calls this directly

Calls 1

normalize_or_copyFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…