test_single_dimension_vectors() — langchain Function Reference
Architecture documentation for the test_single_dimension_vectors() function in test_utils.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD f43651b7_5aef_e62d_e413_5b53cf41864e["test_single_dimension_vectors()"] 43305d93_a58a_e7db_615b_b8a5a18284ab["TestCosineSimilarity"] f43651b7_5aef_e62d_e413_5b53cf41864e -->|defined in| 43305d93_a58a_e7db_615b_b8a5a18284ab style f43651b7_5aef_e62d_e413_5b53cf41864e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/vectorstores/test_utils.py lines 153–164
def test_single_dimension_vectors(self) -> None:
"""Test with single-dimension vectors."""
x: list[list[float]] = [[5], [-3]]
y: list[list[float]] = [[2], [-1], [4]]
result = _cosine_similarity(x, y)
expected = np.array(
[
[1.0, -1.0, 1.0], # [5] vs [2], [-1], [4]
[-1.0, 1.0, -1.0], # [-3] vs [2], [-1], [4]
]
)
np.testing.assert_array_almost_equal(result, expected)
Domain
Subdomains
Source
Frequently Asked Questions
What does test_single_dimension_vectors() do?
test_single_dimension_vectors() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/vectorstores/test_utils.py.
Where is test_single_dimension_vectors() defined?
test_single_dimension_vectors() is defined in libs/core/tests/unit_tests/vectorstores/test_utils.py at line 153.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free