Home / File/ math.py — langchain Source File

math.py — langchain Source File

Architecture documentation for math.py, a python file in the langchain codebase. 3 imports, 0 dependents.

File python CoreAbstractions Serialization 3 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  64d9ae74_5cf0_7792_81e1_7ed0eb0ceb88["math.py"]
  8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"]
  64d9ae74_5cf0_7792_81e1_7ed0eb0ceb88 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3
  439a4142_6fa6_fe9a_2cba_7c9fb0cdceb7["langchain_classic._api"]
  64d9ae74_5cf0_7792_81e1_7ed0eb0ceb88 --> 439a4142_6fa6_fe9a_2cba_7c9fb0cdceb7
  8593fff4_7ff6_3339_11fb_f4c14be375c2["langchain_community.utils.math"]
  64d9ae74_5cf0_7792_81e1_7ed0eb0ceb88 --> 8593fff4_7ff6_3339_11fb_f4c14be375c2
  style 64d9ae74_5cf0_7792_81e1_7ed0eb0ceb88 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from typing import TYPE_CHECKING, Any

from langchain_classic._api import create_importer

if TYPE_CHECKING:
    from langchain_community.utils.math import (
        cosine_similarity,
        cosine_similarity_top_k,
    )

# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
# Not marked as deprecated since we may want to move the functionality
# into langchain as long as we're OK with numpy as the dependency.
_MODULE_LOOKUP = {
    "cosine_similarity": "langchain_community.utils.math",
    "cosine_similarity_top_k": "langchain_community.utils.math",
}

_import_attribute = create_importer(__package__, module_lookup=_MODULE_LOOKUP)


def __getattr__(name: str) -> Any:
    """Look up attributes dynamically."""
    return _import_attribute(name)


__all__ = [
    "cosine_similarity",
    "cosine_similarity_top_k",
]

Subdomains

Dependencies

  • langchain_classic._api
  • langchain_community.utils.math
  • typing

Frequently Asked Questions

What does math.py do?
math.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, Serialization subdomain.
What functions are defined in math.py?
math.py defines 2 function(s): __getattr__, langchain_community.
What does math.py depend on?
math.py imports 3 module(s): langchain_classic._api, langchain_community.utils.math, typing.
Where is math.py in the architecture?
math.py is located at libs/langchain/langchain_classic/utils/math.py (domain: CoreAbstractions, subdomain: Serialization, directory: libs/langchain/langchain_classic/utils).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free