Test the normalize_or_copy function.
()
| 27 | |
| 28 | |
| 29 | def 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" |
nothing calls this directly
no test coverage detected
searching dependent graphs…