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

Function test_normalize

tests/test_utils.py:9–26  ·  view source on GitHub ↗

Test the normalize function.

(vectors: np.ndarray)

Source from the content-addressed store, hash-verified

7
8
9def test_normalize(vectors: np.ndarray) -> None:
10 """Test the normalize function."""
11 vector = np.array([3.0, 4.0])
12 expected = np.array([0.6, 0.8])
13 result = normalize(vector)
14 assert_almost_equal(result, expected)
15
16 # Test normalizing a zero vector
17 zero_vector = np.array([0.0, 0.0])
18 expected_zero = np.array([0.0, 0.0])
19 result_zero = normalize(zero_vector)
20 assert_array_equal(result_zero, expected_zero)
21
22 # Test normalizing a matrix of vectors
23 vectors = np.array([[3.0, 4.0], [1.0, 0.0], [0.0, 0.0]])
24 expected_vectors = np.array([[0.6, 0.8], [1.0, 0.0], [0.0, 0.0]])
25 result_vectors = normalize(vectors)
26 assert_almost_equal(result_vectors, expected_vectors)
27
28
29def test_normalize_or_copy() -> None:

Callers

nothing calls this directly

Calls 1

normalizeFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…