_chebyshev_distance() — langchain Function Reference
Architecture documentation for the _chebyshev_distance() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 6f52a5c4_0127_1be1_4f2d_a031d090b56f["_chebyshev_distance()"] dc2d52f5_736c_0ec2_ad57_0e2fdaa94e04["_EmbeddingDistanceChainMixin"] 6f52a5c4_0127_1be1_4f2d_a031d090b56f -->|defined in| dc2d52f5_736c_0ec2_ad57_0e2fdaa94e04 91b8ba41_75bf_8afd_e893_d85d055226da["_check_numpy()"] 6f52a5c4_0127_1be1_4f2d_a031d090b56f -->|calls| 91b8ba41_75bf_8afd_e893_d85d055226da caa53c2b_01ef_7204_a5e6_ad683c86dbd2["_import_numpy()"] 6f52a5c4_0127_1be1_4f2d_a031d090b56f -->|calls| caa53c2b_01ef_7204_a5e6_ad683c86dbd2 style 6f52a5c4_0127_1be1_4f2d_a031d090b56f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/evaluation/embedding_distance/base.py lines 286–305
def _chebyshev_distance(a: Any, b: Any) -> Any:
"""Compute the Chebyshev distance between two vectors.
Args:
a (np.ndarray): The first vector.
b (np.ndarray): The second vector.
Returns:
np.floating: The Chebyshev distance.
"""
try:
from scipy.spatial.distance import chebyshev
return chebyshev(a.flatten(), b.flatten())
except ImportError:
if _check_numpy():
np = _import_numpy()
return np.max(np.abs(a - b))
return max(abs(x - y) for x, y in zip(a, b, strict=False))
Domain
Subdomains
Source
Frequently Asked Questions
What does _chebyshev_distance() do?
_chebyshev_distance() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/evaluation/embedding_distance/base.py.
Where is _chebyshev_distance() defined?
_chebyshev_distance() is defined in libs/langchain/langchain_classic/evaluation/embedding_distance/base.py at line 286.
What does _chebyshev_distance() call?
_chebyshev_distance() calls 2 function(s): _check_numpy, _import_numpy.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free