test_transform.py — langchain Source File
Architecture documentation for test_transform.py, a python file in the langchain codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 27ea57fa_8f6f_9729_5dc0_14afdb328701["test_transform.py"] 67ec3255_645e_8b6e_1eff_1eb3c648ed95["re"] 27ea57fa_8f6f_9729_5dc0_14afdb328701 --> 67ec3255_645e_8b6e_1eff_1eb3c648ed95 120e2591_3e15_b895_72b6_cb26195e40a6["pytest"] 27ea57fa_8f6f_9729_5dc0_14afdb328701 --> 120e2591_3e15_b895_72b6_cb26195e40a6 08e4321c_76f7_5a89_d283_e4d93734a53b["langchain_classic.chains.transform"] 27ea57fa_8f6f_9729_5dc0_14afdb328701 --> 08e4321c_76f7_5a89_d283_e4d93734a53b style 27ea57fa_8f6f_9729_5dc0_14afdb328701 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Test transform chain."""
import re
import pytest
from langchain_classic.chains.transform import TransformChain
def dummy_transform(inputs: dict[str, str]) -> dict[str, str]:
"""Transform a dummy input for tests."""
outputs = inputs
outputs["greeting"] = f"{inputs['first_name']} {inputs['last_name']} says hello"
del outputs["first_name"]
del outputs["last_name"]
return outputs
def test_transform_chain() -> None:
"""Test basic transform chain."""
transform_chain = TransformChain(
input_variables=["first_name", "last_name"],
output_variables=["greeting"],
transform=dummy_transform,
)
input_dict = {"first_name": "Leroy", "last_name": "Jenkins"}
response = transform_chain(input_dict)
expected_response = {"greeting": "Leroy Jenkins says hello"}
assert response == expected_response
def test_transform_chain_bad_inputs() -> None:
"""Test basic transform chain."""
transform_chain = TransformChain(
input_variables=["first_name", "last_name"],
output_variables=["greeting"],
transform=dummy_transform,
)
input_dict = {"name": "Leroy", "last_name": "Jenkins"}
with pytest.raises(
ValueError, match=re.escape("Missing some input keys: {'first_name'}")
):
_ = transform_chain(input_dict)
Domain
Subdomains
Dependencies
- langchain_classic.chains.transform
- pytest
- re
Source
Frequently Asked Questions
What does test_transform.py do?
test_transform.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, RunnableInterface subdomain.
What functions are defined in test_transform.py?
test_transform.py defines 3 function(s): dummy_transform, test_transform_chain, test_transform_chain_bad_inputs.
What does test_transform.py depend on?
test_transform.py imports 3 module(s): langchain_classic.chains.transform, pytest, re.
Where is test_transform.py in the architecture?
test_transform.py is located at libs/langchain/tests/unit_tests/chains/test_transform.py (domain: CoreAbstractions, subdomain: RunnableInterface, directory: libs/langchain/tests/unit_tests/chains).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free