Skip to content

Commit d371eda

Browse files
Merge pull request #24 from Waltham-Data-Science/claude/create-ndi-bridge-files-SGIO6
Add MATLAB-Python bridge contracts for epoch and common namespaces
2 parents e439a0d + f44a895 commit d371eda

4 files changed

Lines changed: 710 additions & 7 deletions

File tree

src/ndi/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
# Import session and cache modules (Phase 7)
4242
from .cache import Cache
4343
from .calculator import Calculator
44-
from .common import PathConstants, get_logger, getLogger, timestamp
44+
from .common import PathConstants, getLogger, timestamp
4545
from .database import Database, open_database
4646
from .dataset import Dataset, DatasetDir
4747
from .document import Document
@@ -100,7 +100,7 @@ def version() -> tuple:
100100
"open_database",
101101
"PathConstants",
102102
"timestamp",
103-
"get_logger",
103+
"getLogger",
104104
"time",
105105
"daq",
106106
"file",

src/ndi/common/__init__.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,6 @@ def getLogger(name: str = "ndi"):
154154
return logging.getLogger(name)
155155

156156

157-
# Keep old name for backwards compatibility
158-
get_logger = getLogger
159-
160-
161157
# ---------------------------------------------------------------------------
162158
# Singleton cache — mirrors MATLAB ndi.common.getCache
163159
# ---------------------------------------------------------------------------
@@ -260,7 +256,6 @@ def assertDIDInstalled() -> None:
260256
"PathConstants",
261257
"timestamp",
262258
"getLogger",
263-
"get_logger",
264259
"getCache",
265260
"getDatabaseHierarchy",
266261
"assertDIDInstalled",
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# ndi_matlab_python_bridge.yaml — src/ndi/common/
2+
# The Primary Contract for the ndi.common namespace.
3+
4+
project_metadata:
5+
bridge_version: "1.1"
6+
naming_policy: "Strict MATLAB Mirror"
7+
indexing_policy: "Semantic Parity (1-based for user concepts, 0-based for internal data)"
8+
9+
# =========================================================================
10+
# Standalone functions
11+
# =========================================================================
12+
functions:
13+
14+
- name: timestamp
15+
type: function
16+
matlab_path: null
17+
python_path: "ndi/common/__init__.py"
18+
input_arguments: []
19+
output_arguments:
20+
- name: ts
21+
type_python: "str"
22+
decision_log: >
23+
Python-specific utility. No direct MATLAB equivalent.
24+
Returns ISO 8601 timestamp in UTC.
25+
26+
- name: getLogger
27+
type: function
28+
matlab_path: "+ndi/+common/getLogger.m"
29+
python_path: "ndi/common/__init__.py"
30+
input_arguments:
31+
- name: name
32+
type_matlab: "char"
33+
type_python: "str"
34+
default: "'ndi'"
35+
output_arguments:
36+
- name: logger
37+
type_python: "logging.Logger"
38+
decision_log: "Exact match."
39+
40+
- name: getCache
41+
type: function
42+
matlab_path: "+ndi/+common/getCache.m"
43+
python_path: "ndi/common/__init__.py"
44+
input_arguments: []
45+
output_arguments:
46+
- name: cache
47+
type_python: "Cache"
48+
decision_log: "Exact match. Returns a global singleton."
49+
50+
- name: getDatabaseHierarchy
51+
type: function
52+
matlab_path: "+ndi/+common/getDatabaseHierarchy.m"
53+
python_path: "ndi/common/__init__.py"
54+
input_arguments: []
55+
output_arguments:
56+
- name: hierarchy
57+
type_python: "dict[str, Any]"
58+
decision_log: >
59+
Exact match. Reads document definitions from ndi_common/database_documents.
60+
Result is cached after first call.
61+
62+
- name: assertDIDInstalled
63+
type: function
64+
matlab_path: "+ndi/+common/assertDIDInstalled.m"
65+
python_path: "ndi/common/__init__.py"
66+
input_arguments: []
67+
output_arguments: []
68+
decision_log: >
69+
Exact match. Raises ImportError if 'did' package not installed.
70+
MATLAB equivalent raises error if DID toolbox is missing.
71+
72+
# =========================================================================
73+
# Classes
74+
# =========================================================================
75+
classes:
76+
77+
# =========================================================================
78+
# ndi.common.PathConstants
79+
# =========================================================================
80+
- name: PathConstants
81+
type: class
82+
matlab_path: "+ndi/+common/PathConstants.m"
83+
python_path: "ndi/common/__init__.py"
84+
python_class: "PathConstants"
85+
86+
properties:
87+
- name: NDI_ROOT
88+
type_matlab: "char"
89+
type_python: "Path"
90+
access: "class property (read-only)"
91+
decision_log: "Exact match. Python uses pathlib.Path."
92+
93+
- name: COMMON_FOLDER
94+
type_matlab: "char"
95+
type_python: "Path"
96+
access: "class property (read-only)"
97+
decision_log: "Exact match. Python uses pathlib.Path."
98+
99+
- name: DOCUMENT_PATH
100+
type_matlab: "char"
101+
type_python: "Path"
102+
access: "class property (read-only)"
103+
decision_log: "Exact match. Python uses pathlib.Path."
104+
105+
- name: SCHEMA_PATH
106+
type_matlab: "char"
107+
type_python: "Path"
108+
access: "class property (read-only)"
109+
decision_log: "Exact match. Python uses pathlib.Path."
110+
111+
methods:
112+
- name: set_paths
113+
kind: classmethod
114+
input_arguments:
115+
- name: ndi_root
116+
type_python: "Path | None"
117+
default: "None"
118+
- name: common_folder
119+
type_python: "Path | None"
120+
default: "None"
121+
- name: document_path
122+
type_python: "Path | None"
123+
default: "None"
124+
- name: schema_path
125+
type_python: "Path | None"
126+
default: "None"
127+
output_arguments: []
128+
decision_log: >
129+
Python-specific method for programmatic path overrides.
130+
MATLAB uses environment variables or property assignment.

0 commit comments

Comments
 (0)