repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
PythonRobotics | SLAM/GraphBasedSLAM/graphslam/graph.py | .py | # Copyright (c) 2020 Jeff Irion and contributors
#
# This file originated from the `graphslam` package:
#
# https://github.com/JeffLIrion/python-graphslam
r"""A ``Graph`` class that stores the edges and vertices required for Graph SLAM.
"""
import warnings
from collections import defaultdict
from functools import ... | 283 | 9,247 |
PythonRobotics | SLAM/GraphBasedSLAM/graphslam/pose/se2.py | .py | # Copyright (c) 2020 Jeff Irion and contributors
#
# This file originated from the `graphslam` package:
#
# https://github.com/JeffLIrion/python-graphslam
r"""Representation of a pose in :math:`SE(2)`.
"""
import math
import numpy as np
from ..util import neg_pi_to_pi
class PoseSE2(np.ndarray):
r"""A repres... | 185 | 5,015 |
PythonRobotics | SLAM/GraphBasedSLAM/graphslam/edge/edge_odometry.py | .py | # Copyright (c) 2020 Jeff Irion and contributors
#
# This file originated from the `graphslam` package:
#
# https://github.com/JeffLIrion/python-graphslam
r"""A class for odometry edges.
"""
import numpy as np
import matplotlib.pyplot as plt
#: The difference that will be used for numerical differentiation
EPSI... | 181 | 5,422 |
PythonRobotics | SLAM/ICPMatching/icp_matching.py | .py | """
Iterative Closest Point (ICP) SLAM example
author: Atsushi Sakai (@Atsushi_twi), Göktuğ Karakaşlı, Shamil Gemuev
"""
import math
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
import matplotlib.pyplot as plt
import numpy as np
# ICP parameters
EPS = 0.0001
MAX_ITER = 100
show_animation = T... | 206 | 5,933 |
PythonRobotics | SLAM/FastSLAM2/fast_slam2.py | .py | """
FastSLAM 2.0 example
author: Atsushi Sakai (@Atsushi_twi)
"""
import math
import matplotlib.pyplot as plt
import numpy as np
from utils.angle import angle_mod
# Fast SLAM covariance
Q = np.diag([3.0, np.deg2rad(10.0)]) ** 2
R = np.diag([1.0, np.deg2rad(20.0)]) ** 2
# Simulation parameter
Q_SIM = np.diag([0.... | 427 | 11,289 |
PythonRobotics | SLAM/EKFSLAM/ekf_slam.py | .py | """
Extended Kalman Filter SLAM example
author: Atsushi Sakai (@Atsushi_twi)
"""
import math
import matplotlib.pyplot as plt
import numpy as np
from utils.angle import angle_mod
# EKF state covariance
Cx = np.diag([0.5, 0.5, np.deg2rad(30.0)]) ** 2
# Simulation parameter
Q_sim = np.diag([0.2, np.deg2rad(1.0)]) **... | 264 | 6,924 |
PythonRobotics | MissionPlanning/StateMachine/state_machine.py | .py | """
State Machine
author: Wang Zheng (@Aglargil)
Reference:
- [State Machine]
(https://en.wikipedia.org/wiki/Finite-state_machine)
"""
import string
from urllib.request import urlopen, Request
from base64 import b64encode
from zlib import compress
from io import BytesIO
from collections.abc import Callable
from mat... | 295 | 10,339 |
PythonRobotics | MissionPlanning/StateMachine/robot_behavior_case.py | .py | """
A case study of robot behavior using state machine
author: Wang Zheng (@Aglargil)
"""
from state_machine import StateMachine
class Robot:
def __init__(self):
self.battery = 100
self.task_progress = 0
# Initialize state machine
self.machine = StateMachine("robot_sm", self)
... | 112 | 3,228 |
PythonRobotics | MissionPlanning/BehaviorTree/behavior_tree.py | .py | """
Behavior Tree
author: Wang Zheng (@Aglargil)
Reference:
- [Behavior Tree](https://en.wikipedia.org/wiki/Behavior_tree_(artificial_intelligence,_robotics_and_control))
"""
import time
import xml.etree.ElementTree as ET
from enum import Enum
class Status(Enum):
SUCCESS = "success"
FAILURE = "failure"
... | 691 | 19,668 |
PythonRobotics | MissionPlanning/BehaviorTree/robot_behavior_case.py | .py | """
Robot Behavior Tree Case
This file demonstrates how to use a behavior tree to control robot behavior.
"""
from behavior_tree import (
BehaviorTreeFactory,
Status,
ActionNode,
)
import time
import random
import os
class CheckBatteryNode(ActionNode):
"""
Node to check robot battery level
... | 248 | 6,855 |
PythonRobotics | ArmNavigation/n_joint_arm_3d/NLinkArm3d.py | .py | """
Class of n-link arm in 3D
Author: Takayuki Murooka (takayuki5168)
"""
import numpy as np
import math
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
class Link:
def __init__(self, dh_params):
self.dh_params_ = dh_params
def transformation_matrix(self):
theta = self... | 216 | 6,950 |
PythonRobotics | ArmNavigation/n_joint_arm_3d/random_inverse_kinematics.py | .py | """
Inverse Kinematics for an n-link arm in 3D
Author: Takayuki Murooka (takayuki5168)
"""
import math
from NLinkArm3d import NLinkArm
import random
def random_val(min_val, max_val):
return min_val + random.random() * (max_val - min_val)
def main():
print("Start solving Inverse Kinematics 10 times")
# i... | 36 | 1,233 |
PythonRobotics | ArmNavigation/n_joint_arm_3d/random_forward_kinematics.py | .py | """
Forward Kinematics for an n-link arm in 3D
Author: Takayuki Murooka (takayuki5168)
"""
import math
from NLinkArm3d import NLinkArm
import random
def random_val(min_val, max_val):
return min_val + random.random() * (max_val - min_val)
def main():
print("Start solving Forward Kinematics 10 times")
# i... | 34 | 1,011 |
PythonRobotics | ArmNavigation/two_joint_arm_to_point_control/two_joint_arm_to_point_control.py | .py | """
Inverse kinematics of a two-joint arm
Left-click the plot to set the goal position of the end effector
Author: Daniel Ingram (daniel-s-ingram)
Atsushi Sakai (@Atsushi_twi)
Reference: P. I. Corke, "Robotics, Vision & Control", Springer 2017,
ISBN 978-3-319-54413-7 p102
- [Robotics, Vision and Control]
(ht... | 146 | 3,965 |
PythonRobotics | ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation.py | .py | """
Obstacle navigation using A* on a toroidal grid
Author: Daniel Ingram (daniel-s-ingram)
"""
from math import pi
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import from_levels_and_colors
plt.ion()
# Simulation parameters
M = 100
obstacles = [[1.75, 0.75, 0.6], [0.55, 1.5, 0.5], [0, -... | 269 | 8,721 |
PythonRobotics | ArmNavigation/arm_obstacle_navigation/arm_obstacle_navigation_2.py | .py | """
Obstacle navigation using A* on a toroidal grid
Author: Daniel Ingram (daniel-s-ingram)
Tullio Facchinetti (tullio.facchinetti@unipv.it)
"""
from math import pi
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import from_levels_and_colors
import sys
plt.ion()
# Simulation parame... | 300 | 9,847 |
PythonRobotics | ArmNavigation/n_joint_arm_to_point_control/n_joint_arm_to_point_control.py | .py | """
Inverse kinematics for an n-link arm using the Jacobian inverse method
Author: Daniel Ingram (daniel-s-ingram)
Atsushi Sakai (@Atsushi_twi)
"""
import sys
from pathlib import Path
sys.path.append(str(Path(__file__).parent.parent.parent))
import numpy as np
from ArmNavigation.n_joint_arm_to_point_control.... | 169 | 5,414 |
PythonRobotics | ArmNavigation/n_joint_arm_to_point_control/NLinkArm.py | .py | """
Class for controlling and plotting an arm with an arbitrary number of links.
Author: Daniel Ingram
"""
import numpy as np
import matplotlib.pyplot as plt
class NLinkArm(object):
def __init__(self, link_lengths, joint_angles, goal, show_animation):
self.show_animation = show_animation
self.n_... | 77 | 2,486 |
PythonRobotics | ArmNavigation/rrt_star_seven_joint_arm_control/rrt_star_seven_joint_arm_control.py | .py | """
RRT* path planner for a seven joint arm
Author: Mahyar Abdeetedal (mahyaret)
"""
import math
import random
import numpy as np
import matplotlib.pyplot as plt
import sys
import pathlib
sys.path.append(str(pathlib.Path(__file__).parent.parent))
from n_joint_arm_3d.NLinkArm3d import NLinkArm
show_animation = True
ve... | 406 | 14,101 |
code-review-graph | diagrams/generate_diagrams.py | .py | #!/usr/bin/env python3
"""Generate 9 Excalidraw diagrams for code-review-graph Medium article.
All statistics match repo benchmarks exactly. No invented features or numbers.
"""
import json
import math
import os
import random
random.seed(2024)
OUT = os.path.dirname(os.path.abspath(__file__))
_n = 0
def _id():
g... | 731 | 30,134 |
code-review-graph | tests/test_flows.py | .py | """Tests for execution flow detection, tracing, and scoring."""
import tempfile
from pathlib import Path
from code_review_graph.flows import (
detect_entry_points,
get_affected_flows,
get_flow_by_id,
get_flows,
incremental_trace_flows,
store_flows,
trace_flows,
)
from code_review_graph.gra... | 637 | 25,959 |
code-review-graph | tests/test_language_reconciliation.py | .py | """Regression tests for reconciled community language contributions."""
from __future__ import annotations
from pathlib import Path
import pytest
from code_review_graph.graph import GraphStore
from code_review_graph.parser import CodeParser
def _parse(path: Path, source: str):
path.write_text(source, encoding... | 673 | 22,481 |
code-review-graph | tests/test_http_origin_guard.py | .py | """End-to-end tests for the ``serve --http`` Host/Origin guard.
These exercise the real FastMCP ASGI application with the real middleware, and
assert the kwargs the server entry point passes are actually accepted by the
installed FastMCP. A mock of ``mcp.run`` cannot catch a keyword the pinned
FastMCP does not accept,... | 158 | 6,315 |
code-review-graph | tests/test_diagnose_pypi_connectivity.py | .py | """Tests for the standalone PyPI connectivity diagnostic."""
import ssl
from contextlib import nullcontext
from scripts import diagnose_pypi_connectivity
class _FakeTLSConnection:
def version(self) -> str:
return "TLSv1.2"
class _FakeTLSContext:
def __init__(self) -> None:
self.minimum_ver... | 38 | 1,018 |
code-review-graph | tests/test_python_star_imports.py | .py | """Regression tests for repository-bounded Python wildcard imports."""
import json
from pathlib import Path
from code_review_graph.parser import CodeParser
def _call_targets(repo_root: Path, source_file: Path) -> set[str]:
_, edges = CodeParser(repo_root).parse_file(source_file)
return {edge.target for edge... | 294 | 8,223 |
code-review-graph | tests/test_visualization.py | .py | """Tests for graph visualization export."""
import base64
import hashlib
import json
import re
import shutil
import subprocess
from html.parser import HTMLParser
from importlib import resources
import pytest
from code_review_graph.graph import GraphStore
from code_review_graph.parser import EdgeInfo, NodeInfo
clas... | 991 | 35,818 |
code-review-graph | tests/test_forget_parity.py | .py | """Full-build parity tests for `forget`.
The contract the reviewer asked for: after ``forget X`` the graph must match the
graph you would get by building the repository without ``X`` — not just for the
forgotten file's own rows, but for cross-file incoming edges, flows,
communities, and embeddings. These tests build a... | 373 | 13,117 |
code-review-graph | tests/test_prompts.py | .py | """Tests for MCP prompt templates."""
from fastmcp.prompts.prompt import Message
from code_review_graph.prompts import (
architecture_map_prompt,
debug_issue_prompt,
onboard_developer_prompt,
pre_merge_check_prompt,
review_changes_prompt,
)
def _text(msg: Message) -> str:
"""Extract the text... | 193 | 6,247 |
code-review-graph | tests/test_embedding_initialization.py | .py | """Concurrency regression tests for local embedding initialization (#610)."""
from __future__ import annotations
import builtins
import sys
import threading
from types import ModuleType
from typing import Any, Callable
import pytest
from code_review_graph import embeddings
from code_review_graph import main as crg_... | 267 | 8,569 |
code-review-graph | tests/test_skills.py | .py | """Tests for skills and hooks auto-install."""
import json
import os
import stat
import subprocess
import sys
from pathlib import Path
from unittest.mock import patch
import pytest
if sys.version_info >= (3, 11):
import tomllib
else: # pragma: no cover - Python 3.10 backport
import tomli as tomllib
from co... | 2,485 | 103,473 |
code-review-graph | tests/test_incremental.py | .py | """Tests for the incremental graph update module."""
import hashlib
import io
import subprocess
from pathlib import Path
from unittest.mock import MagicMock, call, patch # noqa: F401 – used in tests
import pytest
import code_review_graph.incremental as incremental_module
from code_review_graph.graph import GraphSto... | 1,772 | 70,032 |
code-review-graph | tests/test_mcp_stdio_shutdown.py | .py | """End-to-end regression for MCP stdio executor shutdown (PR #615)."""
from __future__ import annotations
import json
import os
import select
import subprocess
import sys
import time
from pathlib import Path
import pytest
def _send(proc: subprocess.Popen[str], message: dict) -> None:
assert proc.stdin is not N... | 141 | 4,151 |
code-review-graph | tests/test_migrations.py | .py | """Tests for the schema migration framework."""
import sqlite3
import tempfile
from pathlib import Path
from code_review_graph.graph import GraphStore
from code_review_graph.migrations import (
LATEST_VERSION,
MIGRATIONS,
get_schema_version,
run_migrations,
)
class TestMigrations:
def setup_meth... | 153 | 6,253 |
code-review-graph | tests/test_graph.py | .py | """Tests for the graph storage and query engine."""
import logging
import sqlite3
import tempfile
import time
from pathlib import Path, PureWindowsPath
import pytest
import code_review_graph.constants as constants_module
from code_review_graph.graph import GraphStore
from code_review_graph.incremental import full_bu... | 1,291 | 50,838 |
code-review-graph | tests/test_hcl_parser.py | .py | """Terraform/HCL parser and module-scope resolution tests."""
from pathlib import Path
from code_review_graph.graph import GraphStore
from code_review_graph.incremental import full_build
from code_review_graph.parser import CodeParser
def test_for_expression_references_are_emitted_for_local_binding() -> None:
p... | 118 | 3,356 |
code-review-graph | tests/test_php_scoped_calls.py | .py | """Scoped/static ``Class::method`` calls are tracked as callers in PHP (#567).
A PHP call written ``Mailer::dispatch($x)`` used to store a ``CALLS`` edge whose
target was the intermediate string ``Mailer::dispatch``. That key matched
neither the canonical node name (``<file>::Mailer.dispatch``) nor a bare method
name... | 669 | 22,608 |
code-review-graph | tests/test_daemon.py | .py | """Tests for daemon config, PID management, WatchDaemon, and CLI."""
from __future__ import annotations
import os
import signal
import sys
from pathlib import Path
from unittest.mock import MagicMock, patch
import pytest
from code_review_graph.daemon import (
DaemonConfig,
WatchDaemon,
WatchRepo,
_s... | 1,361 | 51,167 |
code-review-graph | tests/test_registry.py | .py | """Tests for multi-repo registry and connection pool."""
import sqlite3
import tempfile
from pathlib import Path
from unittest.mock import MagicMock, patch
from code_review_graph.registry import ConnectionPool, Registry, resolve_repo
class TestRegistry:
def setup_method(self):
self.tmp_dir = tempfile.mk... | 490 | 18,013 |
code-review-graph | tests/test_pr_review_workflows.py | .py | """Static security regressions for the split fork-PR review workflows."""
from pathlib import Path
ROOT = Path(__file__).parents[1]
ANALYSIS_WORKFLOW = ROOT / ".github" / "workflows" / "pr-review.yml"
COMMENT_WORKFLOW = ROOT / ".github" / "workflows" / "pr-review-comment.yml"
ACTION = ROOT / "action.yml"
DOCS = ROOT ... | 82 | 3,177 |
code-review-graph | tests/test_fts_sync.py | .py | """Tests for FTS5 content sync robustness."""
import sqlite3
import tempfile
from pathlib import Path
import pytest
from code_review_graph.graph import GraphStore
from code_review_graph.parser import NodeInfo
from code_review_graph.search import rebuild_fts_index
@pytest.fixture
def store():
"""Create a tempora... | 76 | 2,648 |
code-review-graph | tests/test_spring_scheduling.py | .py | from pathlib import Path
from code_review_graph.graph import GraphStore
from code_review_graph.parser import CodeParser
from code_review_graph.tools.query import query_graph
SOURCE = """
import java.util.concurrent.TimeUnit;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.schedu... | 112 | 3,750 |
code-review-graph | tests/test_embedding_refresh.py | .py | """Explicit, provider-scoped embedding refresh and orphan cleanup."""
import asyncio
import sys
from unittest.mock import MagicMock, patch
import pytest
from code_review_graph.embeddings import EmbeddingStore, embed_all_nodes
from code_review_graph.graph import GraphStore
from code_review_graph.parser import NodeInf... | 443 | 15,510 |
code-review-graph | tests/test_typed_receiver_calls.py | .py | from pathlib import Path
from code_review_graph.parser import CodeParser
def _calls_from(edges, source_suffix: str) -> list[str]:
return [
edge.target
for edge in edges
if edge.kind == "CALLS" and edge.source.endswith(source_suffix)
]
def test_python_imported_class_and_typed_receive... | 248 | 8,136 |
code-review-graph | tests/test_spring_webflux_endpoints.py | .py | from pathlib import Path
from code_review_graph.graph import GraphStore
from code_review_graph.parser import CodeParser
from code_review_graph.tools.query import query_graph
SOURCE = b"""
import static org.springframework.web.reactive.function.server.RouterFunctions.route;
import org.springframework.web.reactive.func... | 96 | 3,334 |
code-review-graph | tests/test_changes.py | .py | """Tests for change impact analysis (changes.py)."""
import subprocess
import tempfile
from pathlib import Path
from unittest.mock import patch
import pytest
from code_review_graph.changes import (
_parse_numstat,
_parse_unified_diff,
analyze_changes,
compute_file_churn,
compute_risk_score,
m... | 793 | 30,222 |
code-review-graph | tests/test_windows_compat.py | .py | """Cross-platform guards for Windows-only test-suite constraints."""
from __future__ import annotations
import ast
from pathlib import Path
def _qualified_name(node: ast.AST) -> str | None:
if isinstance(node, ast.Name):
return node.id
if isinstance(node, ast.Attribute):
parent = _qualified_... | 95 | 3,448 |
code-review-graph | tests/test_hints.py | .py | """Tests for the context-aware hints system."""
from code_review_graph.hints import (
_MAX_PER_CATEGORY,
SessionState,
generate_hints,
get_session,
infer_intent,
reset_session,
)
class TestSessionState:
def test_fresh_session_exploring(self):
"""A brand-new session with no history... | 196 | 8,090 |
code-review-graph | tests/test_julia_reconciliation.py | .py | """Regression coverage for the safe Julia behavior ported from PR #560."""
from pathlib import Path
import pytest
from code_review_graph.graph import GraphStore
from code_review_graph.incremental import full_build
from code_review_graph.parser import CodeParser
def _parse(source: str):
return CodeParser().pars... | 492 | 14,241 |
code-review-graph | tests/test_search.py | .py | """Tests for the hybrid search engine."""
import tempfile
from pathlib import Path
from code_review_graph.graph import GraphStore
from code_review_graph.parser import NodeInfo
from code_review_graph.search import (
detect_query_kind_boost,
hybrid_search,
rebuild_fts_index,
rrf_merge,
)
class TestHyb... | 342 | 12,788 |
code-review-graph | tests/test_spring_events.py | .py | import json
from pathlib import Path
from code_review_graph.graph import GraphStore
from code_review_graph.incremental import full_build, incremental_update
from code_review_graph.parser import CodeParser
from code_review_graph.tools.query import query_graph
def _parse_java(path: Path, source: str):
return CodeP... | 228 | 7,732 |
code-review-graph | tests/test_spring_config.py | .py | import json
from pathlib import Path
from code_review_graph.graph import GraphStore
from code_review_graph.parser import CodeParser
from code_review_graph.tools.query import query_graph
YAML_SOURCE = b"""
spring:
datasource:
url: jdbc:postgresql://localhost/orders
password: yaml-super-secret
kafka:
bo... | 182 | 7,045 |
code-review-graph | tests/test_spring_endpoints.py | .py | from pathlib import Path
from code_review_graph.graph import GraphStore
from code_review_graph.parser import CodeParser
from code_review_graph.tools.query import query_graph
SOURCE = """
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping({"/api/", "/v2"})
class CatalogController {
... | 135 | 4,137 |
code-review-graph | tests/test_ansible_parser.py | .py | """Regression tests for safe, connected Ansible graph extraction."""
from pathlib import Path
from code_review_graph.graph import GraphStore
from code_review_graph.parser import CodeParser, NodeInfo
def _qualified(node: NodeInfo) -> str:
if node.kind == "File":
return node.file_path
if node.parent_n... | 97 | 2,618 |
code-review-graph | tests/test_eval.py | .py | """Tests for the evaluation framework (scorer, reporter, runner, benchmarks)."""
import csv
import os
import subprocess
import tempfile
from pathlib import Path
import pytest
from code_review_graph.eval.reporter import (
generate_full_report,
generate_markdown_report,
generate_readme_tables,
)
try:
... | 1,318 | 44,373 |
code-review-graph | tests/test_cpp_qt_headers.py | .py | """Regression coverage for C++ and Qt header indexing (issue #463)."""
import shutil
from pathlib import Path
from code_review_graph.graph import GraphStore
from code_review_graph.incremental import full_build
from code_review_graph.parser import CodeParser
FIXTURES = Path(__file__).parent / "fixtures" / "cpp_qt_hea... | 364 | 9,450 |
code-review-graph | tests/test_parser.py | .py | """Tests for the Tree-sitter parser module."""
import tempfile
from pathlib import Path
from code_review_graph.graph import GraphStore
from code_review_graph.incremental import full_build
from code_review_graph.parser import CodeParser
FIXTURES = Path(__file__).parent / "fixtures"
class TestCodeParser:
def set... | 2,492 | 103,939 |
code-review-graph | tests/test_parser_load_probe.py | .py | """Failure-mode tests for bounded tree-sitter parser loading."""
from __future__ import annotations
import os
import subprocess
import sys
from pathlib import Path
from types import SimpleNamespace
import pytest
from code_review_graph import parser as parser_module
from code_review_graph.parser import CodeParser
... | 206 | 6,364 |
code-review-graph | tests/test_cpp_overload_identity.py | .py | """Regression coverage for stable C++ overload identities (#622)."""
from pathlib import Path
from unittest.mock import patch
from code_review_graph.graph import GraphStore
from code_review_graph.incremental import CPP_IDENTITY_VERSION, incremental_update
from code_review_graph.parser import CodeParser, EdgeInfo, Nod... | 1,221 | 40,556 |
code-review-graph | tests/test_uninstall.py | .py | """Destructive-regression tests for the safe uninstall workflow.
Every test uses a fake home and repository. The real user configuration must
never be reachable from this suite.
"""
from __future__ import annotations
import json
import os
import stat
import sys
from pathlib import Path
from unittest.mock import pat... | 881 | 29,281 |
code-review-graph | tests/test_docstring_embeddings.py | .py | """Documentation summaries used by semantic embeddings."""
from pathlib import Path
from unittest.mock import patch
from code_review_graph.embeddings import _node_to_text
from code_review_graph.graph import GraphNode, GraphStore
from code_review_graph.incremental import full_build, incremental_update
from code_review... | 283 | 9,298 |
code-review-graph | tests/test_status_stats.py | .py | """Regression tests for issue #474 — ``status`` must report the live graph.
``get_stats()`` used to derive ``languages`` from every node row in the
database. Virtual rows that are not tied to a real indexed file (for
example the Spring ``Event`` nodes emitted by the event resolver with the
synthetic file path ``"even... | 167 | 6,034 |
code-review-graph | tests/test_enrich.py | .py | """Tests for the PreToolUse search enrichment module."""
import tempfile
from pathlib import Path
from code_review_graph.enrich import (
enrich_file_read,
enrich_search,
extract_pattern,
)
from code_review_graph.graph import GraphStore
from code_review_graph.parser import EdgeInfo, NodeInfo
from code_revi... | 243 | 8,704 |
code-review-graph | tests/test_commonjs_imports.py | .py | """Safe CommonJS/dynamic-import subset reconciled from PR #95."""
from pathlib import Path
from code_review_graph.parser import CodeParser
def _parse(tmp_path: Path, source: str, suffix: str = ".js"):
path = tmp_path / f"app{suffix}"
path.write_text(source, encoding="utf-8")
return path, CodeParser().pa... | 85 | 2,832 |
code-review-graph | tests/test_agent_transparency.py | .py | """Regression coverage for safe agent-facing graph transparency."""
from __future__ import annotations
import subprocess
from pathlib import Path
from types import SimpleNamespace
import pytest
import code_review_graph.main as main_module
import code_review_graph.tools._common as common_module
import code_review_gr... | 465 | 14,881 |
code-review-graph | tests/test_refactor.py | .py | """Tests for graph-powered refactoring operations."""
import tempfile
import threading
import time
from pathlib import Path
from code_review_graph.graph import GraphStore
from code_review_graph.parser import CodeParser, EdgeInfo, NodeInfo
from code_review_graph.refactor import (
REFACTOR_EXPIRY_SECONDS,
_pend... | 1,102 | 46,273 |
code-review-graph | tests/test_custom_languages.py | .py | """Tests for config-driven custom language support (languages.toml, #320).
Erlang is used as the end-to-end grammar: tree_sitter_language_pack ships
it, but code-review-graph has no built-in ``.erl`` support (only Elixir on
the BEAM side), so it exercises the full bring-your-own-language path.
"""
import logging
from... | 482 | 16,516 |
code-review-graph | tests/test_rust_scoped_calls.py | .py | """Scoped/static ``Type::method`` calls are tracked as callers in Rust (#567).
In Rust, ``Type::method()`` / ``Self::method()`` / ``Type::new()`` is the
dominant call form for associated functions and constructors. These used to be
stored as a ``CALLS`` edge whose target was the intermediate ``Type::method``
string, ... | 376 | 12,841 |
code-review-graph | tests/test_transactions.py | .py | """Tests for SQLite transaction robustness and nesting scenarios."""
import sqlite3
import tempfile
import logging
from pathlib import Path
from unittest.mock import patch
import pytest
from code_review_graph.graph import GraphStore
from code_review_graph.parser import NodeInfo, EdgeInfo
from code_review_graph.commu... | 117 | 4,607 |
code-review-graph | tests/test_forget.py | .py | """Tests for the ``forget`` command and its file-matching helper.
``forget`` drops already-parsed files from the graph without a full rebuild,
so the two things worth guarding are (1) the path/glob matching that decides
*which* stored files to drop and (2) the end-to-end command keeping the graph
and its FTS index con... | 184 | 5,970 |
code-review-graph | tests/test_postprocessing.py | .py | """Tests for the shared post-processing pipeline."""
import sqlite3
import tempfile
from pathlib import Path
from unittest.mock import MagicMock, patch
from code_review_graph.graph import GraphStore
from code_review_graph.incremental import full_build, incremental_update
from code_review_graph.parser import EdgeInfo,... | 645 | 22,626 |
code-review-graph | tests/test_notebook.py | .py | """Tests for Jupyter notebook (.ipynb) parsing."""
import json
from pathlib import Path
import pytest
from code_review_graph.parser import _SQL_TABLE_RE, CodeParser
FIXTURES = Path(__file__).parent / "fixtures"
class TestNotebookParsing:
def setup_method(self):
self.parser = CodeParser()
self.... | 446 | 17,479 |
code-review-graph | tests/test_java_call_references.py | .py | from pathlib import Path
import pytest
from code_review_graph.flows import detect_entry_points
from code_review_graph.graph import GraphStore
from code_review_graph.parser import CodeParser, EdgeInfo, NodeInfo
def test_java_method_references_chained_calls_and_constructors_are_calls() -> None:
path = Path("Route... | 87 | 2,629 |
code-review-graph | tests/test_dbt_parser.py | .py | """dbt model SQL parser tests: {{ ref() }} / {{ source() }} extraction."""
from pathlib import Path
from code_review_graph.graph import GraphStore
from code_review_graph.incremental import full_build
from code_review_graph.parser import CodeParser
DBT_MODEL = b"""\
with
source as (
select * from {{ ref('stg_ord... | 188 | 6,112 |
code-review-graph | tests/test_cli_tool_commands.py | .py | """CLI wrappers for graph tools reconciled from PR #95."""
from __future__ import annotations
import json
import sys
from unittest.mock import patch
import pytest
import code_review_graph.tools # noqa: F401 - exposes lazy patch targets
from code_review_graph import cli
@pytest.mark.parametrize(
("arguments",... | 147 | 4,593 |
code-review-graph | tests/test_python_reachability.py | .py | """Regression tests for statically unreachable Python call edges."""
from pathlib import Path
from code_review_graph.graph import GraphStore
from code_review_graph.parser import CodeParser
from code_review_graph.refactor import find_dead_code
def _call_targets(source: bytes) -> set[str]:
"""Return the bare name... | 251 | 5,388 |
code-review-graph | tests/test_embeddings.py | .py | """Tests for the embeddings module."""
import json
import os
import threading
import time
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
from unittest.mock import MagicMock, patch
import pytest
from code_review_graph.embeddings import (
LOCAL_DEFAULT_MODEL,
EmbeddingStore,
GoogleEmbe... | 1,647 | 65,995 |
code-review-graph | tests/test_cli_install.py | .py | """Tests for install CLI platform-specific behavior."""
from __future__ import annotations
import argparse
import json
from pathlib import Path
from code_review_graph import skills, uninstall
from code_review_graph.cli import _handle_init
def _args(tmp_path: Path, platform: str) -> argparse.Namespace:
return a... | 256 | 8,121 |
code-review-graph | tests/test_cli.py | .py | """Tests for CLI helpers and MCP serve command wiring."""
import json
import logging
import sys
from importlib.metadata import PackageNotFoundError
from unittest.mock import MagicMock, patch
from code_review_graph import cli
def test_get_version_falls_back_to_package_attr_when_metadata_missing(
monkeypatch, cap... | 583 | 21,265 |
code-review-graph | tests/test_wiki.py | .py | """Tests for wiki generation."""
import tempfile
from pathlib import Path
from code_review_graph.communities import detect_communities, store_communities
from code_review_graph.graph import GraphStore
from code_review_graph.parser import EdgeInfo, NodeInfo
from code_review_graph.wiki import (
_generate_community_... | 284 | 11,050 |
code-review-graph | tests/test_documentation.py | .py | """Regression checks for user-facing command examples."""
import re
from pathlib import Path
ROOT = Path(__file__).parents[1]
README_FILES = (
"README.md",
"README.hi-IN.md",
"README.ja-JP.md",
"README.ko-KR.md",
"README.zh-CN.md",
)
OPTIONAL_GROUPS = (
"embeddings",
"google-embeddings",
... | 78 | 2,500 |
code-review-graph | tests/test_cli_reconciliation.py | .py | """Current-main regressions for the reconciled CLI contribution stack."""
from __future__ import annotations
import io
import json
import logging
import sys
from types import SimpleNamespace
from unittest.mock import MagicMock, patch
import pytest
import code_review_graph.graph # noqa: F401 - imported so unittest.... | 419 | 13,005 |
code-review-graph | tests/test_integration_v2.py | .py | """Comprehensive end-to-end integration test for the v2 pipeline.
Exercises: flows, communities, FTS search, analyze_changes,
find_dead_code, rename_preview, generate_hints, review_changes_prompt,
generate_wiki, and the Registry API.
"""
import tempfile
from pathlib import Path
from code_review_graph.changes import ... | 425 | 17,110 |
code-review-graph | tests/test_communities.py | .py | """Tests for community/cluster detection."""
import tempfile
from pathlib import Path
import pytest
import code_review_graph.communities as communities_module
from code_review_graph.communities import (
IGRAPH_AVAILABLE,
_compute_cohesion,
_compute_cohesion_batch,
_detect_file_based,
_generate_co... | 1,011 | 38,020 |
code-review-graph | tests/test_integration_git.py | .py | """Integration tests exercising git-dependent code with real temporary repos.
Tests cover:
- get_changed_files with real git history
- parse_git_diff_ranges with real diffs
- incremental_update detecting real file modifications
- base ref injection rejection
- wiki page path traversal protection
"""
from __future__ i... | 888 | 30,463 |
code-review-graph | tests/test_main.py | .py | """Tests for the MCP server entry point.
Focused on the ``_resolve_repo_root`` helper that threads the
``serve --repo <X>`` CLI flag into every tool wrapper, and on the
set of tools that must be registered as async coroutines so the MCP
stdio event loop stays responsive during long-running operations.
"""
from __futu... | 463 | 19,409 |
code-review-graph | tests/test_context_savings.py | .py | """Tests for compact estimated context savings metadata."""
from __future__ import annotations
import json
from code_review_graph.context_savings import (
estimate_context_savings,
estimate_file_tokens,
estimate_tokens,
format_context_savings,
)
def test_estimate_tokens_uses_conservative_character_... | 65 | 1,738 |
code-review-graph | tests/test_action_render.py | .py | """Tests for scripts/render_pr_comment.py (GitHub Action comment renderer)."""
from __future__ import annotations
import importlib.util
import json
import subprocess
import sys
from pathlib import Path
import pytest
REPO_ROOT = Path(__file__).resolve().parents[1]
SCRIPT = REPO_ROOT / "scripts" / "render_pr_comment.... | 372 | 12,855 |
code-review-graph | tests/test_memory.py | .py | """Tests for code_review_graph.memory module."""
from __future__ import annotations
from pathlib import Path
import pytest
from code_review_graph.memory import clear_memories, list_memories, save_result
def test_save_result_basic(tmp_path: Path) -> None:
"""Save Q&A result normally and verify file creation an... | 199 | 6,150 |
code-review-graph | tests/test_windows_path_identity.py | .py | """Regression tests for issue #774: Windows path separators in node identity.
Qualified names and ``file_path`` values are graph identity. They must be
separator-stable across operating systems: a graph built on Windows has to
produce the same identifiers as one built on Linux/macOS, and consumers that
reconstruct ide... | 253 | 8,827 |
code-review-graph | tests/test_spring_java_reconciliation.py | .py | from pathlib import Path
from code_review_graph.parser import CodeParser, EdgeInfo
def _parse_java(source: str) -> tuple[list, list[EdgeInfo]]:
return CodeParser().parse_bytes(Path("SpringReconciliation.java"), source.encode())
def _injected_fields(source: str, class_name: str) -> dict[str, str]:
_, edges ... | 86 | 2,519 |
code-review-graph | tests/test_multilang.py | .py | """Tests for Go, Rust, Java, C, C++, C#, Ruby, PHP, Kotlin, Swift, Solidity, and Vue parsing."""
from pathlib import Path
import pytest
from code_review_graph.parser import CodeParser
FIXTURES = Path(__file__).parent / "fixtures"
class TestGoParsing:
def setup_method(self):
self.parser = CodeParser()
... | 4,334 | 174,277 |
code-review-graph | tests/test_tsconfig_resolver.py | .py | """Tests for the TsconfigResolver class."""
from __future__ import annotations
import json
import tempfile
from pathlib import Path
from code_review_graph.tsconfig_resolver import TsconfigResolver
FIXTURES = Path(__file__).parent / "fixtures"
def _write_config(root: Path, name: str, paths: dict, base_url: str = "... | 134 | 5,471 |
code-review-graph | tests/test_php_laravel.py | .py | """Focused coverage for the PHP, Composer, Blade, and Laravel parser port."""
from __future__ import annotations
import json
from pathlib import Path
from unittest.mock import patch
import pytest
from code_review_graph import parser as parser_module
from code_review_graph.graph import GraphStore
from code_review_gr... | 812 | 26,463 |
code-review-graph | tests/test_tools.py | .py | """Tests for MCP tool functions."""
import os
import tempfile
import time
from pathlib import Path
from unittest.mock import MagicMock
import pytest
import code_review_graph.tools._common as common_module
import code_review_graph.tools.analysis_tools as analysis_module
import code_review_graph.tools.docs as docs_mod... | 2,444 | 93,140 |
code-review-graph | tests/conftest.py | .py | """Shared test fixtures.
Keeps code-review-graph's own per-user state out of the developer's real
home directory. Scoped deliberately: the editor-integration installers in
``skills.py`` write to other user-level locations (``~/.codex``,
``~/.cursor``, ``~/.config/opencode``) that are outside CRG state and are
not cove... | 37 | 1,498 |
code-review-graph | tests/fixtures/test_sample.py | .py | """Tests for sample_python.py - used to verify TESTED_BY edge detection."""
from tests.fixtures.sample_python import AuthService, process_request
def test_authenticate_valid():
service = AuthService("test", "secret123")
assert service.authenticate("secret123") is True
def test_authenticate_invalid():
s... | 20 | 579 |
code-review-graph | tests/fixtures/caller_example.py | .py | """Fixture that imports and calls functions from sample_python."""
from sample_python import create_auth_service
def setup_and_run():
service = create_auth_service()
return service
| 9 | 192 |
code-review-graph | tests/fixtures/multi_call_example.py | .py | """Fixture with multiple calls to the same function from one caller."""
async def _internal_request(url: str, data: bytes) -> dict:
return {"url": url}
async def process_document(content: bytes) -> str:
"""Calls _internal_request twice on different lines."""
first = await _internal_request("http://local... | 14 | 487 |
code-review-graph | tests/fixtures/sample_python.py | .py | """Sample Python file for testing the parser."""
import os
from pathlib import Path # noqa: F401 — used by parser tests
class BaseService:
"""A base service class."""
def __init__(self, name: str):
self.name = name
def start(self) -> None:
print(f"Starting {self.name}")
class AuthSer... | 52 | 1,225 |
code-review-graph | tests/fixtures/sample_callback_refs.py | .py | """Fixture for issue #363: function references in callback positions.
Each `*_callback` function is passed as a bare-identifier argument to
another call. They are never invoked with parens, so without REFERENCES
edge tracking they would be flagged as dead code.
"""
from concurrent.futures import ThreadPoolExecutor
d... | 36 | 789 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.