mcp-stata 1.21.0__cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mcp_stata/__init__.py +3 -0
- mcp_stata/__main__.py +4 -0
- mcp_stata/_native_ops.abi3.so +0 -0
- mcp_stata/config.py +20 -0
- mcp_stata/discovery.py +548 -0
- mcp_stata/graph_detector.py +601 -0
- mcp_stata/models.py +64 -0
- mcp_stata/native_ops.py +87 -0
- mcp_stata/server.py +1233 -0
- mcp_stata/smcl/smcl2html.py +88 -0
- mcp_stata/stata_client.py +4638 -0
- mcp_stata/streaming_io.py +264 -0
- mcp_stata/test_stata.py +56 -0
- mcp_stata/ui_http.py +999 -0
- mcp_stata/utils.py +159 -0
- mcp_stata-1.21.0.dist-info/METADATA +486 -0
- mcp_stata-1.21.0.dist-info/RECORD +20 -0
- mcp_stata-1.21.0.dist-info/WHEEL +5 -0
- mcp_stata-1.21.0.dist-info/entry_points.txt +2 -0
- mcp_stata-1.21.0.dist-info/licenses/LICENSE +661 -0
mcp_stata/native_ops.py
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from typing import Iterable, Any, Tuple
|
|
5
|
+
|
|
6
|
+
logger = logging.getLogger(__name__)
|
|
7
|
+
|
|
8
|
+
try:
|
|
9
|
+
from mcp_stata import _native_ops as _native
|
|
10
|
+
except Exception: # pragma: no cover - optional module
|
|
11
|
+
_native = None
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def argsort_numeric(
|
|
15
|
+
columns: Iterable["numpy.ndarray"],
|
|
16
|
+
descending: list[bool],
|
|
17
|
+
nulls_last: list[bool],
|
|
18
|
+
) -> list[int] | None:
|
|
19
|
+
if _native is None:
|
|
20
|
+
return None
|
|
21
|
+
cols = list(columns)
|
|
22
|
+
if not cols:
|
|
23
|
+
return []
|
|
24
|
+
try:
|
|
25
|
+
return _native.argsort_numeric(cols, descending, nulls_last)
|
|
26
|
+
except Exception as e:
|
|
27
|
+
logger.warning(f"Native numeric sort failed: {e}")
|
|
28
|
+
return None
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def argsort_mixed(
|
|
32
|
+
columns: Iterable[object],
|
|
33
|
+
is_string: list[bool],
|
|
34
|
+
descending: list[bool],
|
|
35
|
+
nulls_last: list[bool],
|
|
36
|
+
) -> list[int] | None:
|
|
37
|
+
if _native is None:
|
|
38
|
+
return None
|
|
39
|
+
cols = list(columns)
|
|
40
|
+
if not cols:
|
|
41
|
+
return []
|
|
42
|
+
try:
|
|
43
|
+
return _native.argsort_mixed(cols, is_string, descending, nulls_last)
|
|
44
|
+
except Exception as e:
|
|
45
|
+
logger.warning(f"Native mixed sort failed: {e}")
|
|
46
|
+
return None
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def smcl_to_markdown(smcl_text: str) -> str | None:
|
|
50
|
+
if _native is None:
|
|
51
|
+
return None
|
|
52
|
+
try:
|
|
53
|
+
return _native.smcl_to_markdown(smcl_text)
|
|
54
|
+
except Exception as e:
|
|
55
|
+
logger.warning(f"Native SMCL conversion failed: {e}")
|
|
56
|
+
return None
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def fast_scan_log(smcl_content: str, rc_default: int) -> Tuple[str, str, int | None] | None:
|
|
60
|
+
if _native is None:
|
|
61
|
+
return None
|
|
62
|
+
try:
|
|
63
|
+
return _native.fast_scan_log(smcl_content, rc_default)
|
|
64
|
+
except Exception as e:
|
|
65
|
+
logger.warning(f"Native log scanning failed: {e}")
|
|
66
|
+
return None
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def compute_filter_indices(
|
|
70
|
+
data_numeric: dict[str, "numpy.ndarray"],
|
|
71
|
+
data_string: dict[str, list[str]],
|
|
72
|
+
filter_json: str,
|
|
73
|
+
row_count: int,
|
|
74
|
+
) -> list[int] | None:
|
|
75
|
+
if _native is None:
|
|
76
|
+
return None
|
|
77
|
+
try:
|
|
78
|
+
return _native.compute_filter_indices(
|
|
79
|
+
data_numeric,
|
|
80
|
+
data_string,
|
|
81
|
+
filter_json,
|
|
82
|
+
row_count
|
|
83
|
+
)
|
|
84
|
+
except Exception as e:
|
|
85
|
+
logger.warning(f"Native filtering failed: {e}")
|
|
86
|
+
return None
|
|
87
|
+
|