Test the normalize function.
(vectors: np.ndarray)
| 7 | |
| 8 | |
| 9 | def 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 | |
| 29 | def test_normalize_or_copy() -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…