mef3io 0.3.0__tar.gz

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.
Files changed (137) hide show
  1. mef3io-0.3.0/.github/workflows/bump-version.yml +57 -0
  2. mef3io-0.3.0/.github/workflows/ci.yml +91 -0
  3. mef3io-0.3.0/.github/workflows/docs.yml +39 -0
  4. mef3io-0.3.0/.github/workflows/release.yml +118 -0
  5. mef3io-0.3.0/.gitignore +16 -0
  6. mef3io-0.3.0/CLAUDE.md +124 -0
  7. mef3io-0.3.0/CMakeLists.txt +26 -0
  8. mef3io-0.3.0/LICENSE +202 -0
  9. mef3io-0.3.0/PKG-INFO +378 -0
  10. mef3io-0.3.0/README.md +147 -0
  11. mef3io-0.3.0/VERSION +1 -0
  12. mef3io-0.3.0/benchmarks/README.md +97 -0
  13. mef3io-0.3.0/benchmarks/bindings_benchmark.py +73 -0
  14. mef3io-0.3.0/benchmarks/compression_test.py +177 -0
  15. mef3io-0.3.0/benchmarks/mef_benchmark.py +538 -0
  16. mef3io-0.3.0/bindings/python/mef3io_ext.cpp +457 -0
  17. mef3io-0.3.0/core/CMakeLists.txt +47 -0
  18. mef3io-0.3.0/core/include/mef3io/byteio.hpp +86 -0
  19. mef3io-0.3.0/core/include/mef3io/c_api.h +162 -0
  20. mef3io-0.3.0/core/include/mef3io/crc.hpp +15 -0
  21. mef3io-0.3.0/core/include/mef3io/crypto.hpp +56 -0
  22. mef3io-0.3.0/core/include/mef3io/errors.hpp +45 -0
  23. mef3io-0.3.0/core/include/mef3io/headers.hpp +156 -0
  24. mef3io-0.3.0/core/include/mef3io/metadata.hpp +29 -0
  25. mef3io-0.3.0/core/include/mef3io/parallel.hpp +61 -0
  26. mef3io-0.3.0/core/include/mef3io/reader.hpp +74 -0
  27. mef3io-0.3.0/core/include/mef3io/records.hpp +50 -0
  28. mef3io-0.3.0/core/include/mef3io/red.hpp +44 -0
  29. mef3io-0.3.0/core/include/mef3io/session.hpp +149 -0
  30. mef3io-0.3.0/core/include/mef3io/session_writer.hpp +97 -0
  31. mef3io-0.3.0/core/include/mef3io/types.hpp +90 -0
  32. mef3io-0.3.0/core/include/mef3io/version.hpp +16 -0
  33. mef3io-0.3.0/core/include/mef3io/writer.hpp +55 -0
  34. mef3io-0.3.0/core/src/aes.cpp +157 -0
  35. mef3io-0.3.0/core/src/c_api.cpp +343 -0
  36. mef3io-0.3.0/core/src/crc.cpp +63 -0
  37. mef3io-0.3.0/core/src/headers.cpp +273 -0
  38. mef3io-0.3.0/core/src/metadata.cpp +84 -0
  39. mef3io-0.3.0/core/src/password.cpp +82 -0
  40. mef3io-0.3.0/core/src/reader.cpp +66 -0
  41. mef3io-0.3.0/core/src/records.cpp +254 -0
  42. mef3io-0.3.0/core/src/red.cpp +322 -0
  43. mef3io-0.3.0/core/src/session.cpp +380 -0
  44. mef3io-0.3.0/core/src/session_writer.cpp +272 -0
  45. mef3io-0.3.0/core/src/sha256.cpp +71 -0
  46. mef3io-0.3.0/core/src/writer.cpp +450 -0
  47. mef3io-0.3.0/core/tests/test_core.cpp +267 -0
  48. mef3io-0.3.0/docs/cpp.md +121 -0
  49. mef3io-0.3.0/docs/design.md +304 -0
  50. mef3io-0.3.0/docs/encryption_model.md +100 -0
  51. mef3io-0.3.0/docs/examples.md +24 -0
  52. mef3io-0.3.0/docs/index.md +67 -0
  53. mef3io-0.3.0/docs/install.md +77 -0
  54. mef3io-0.3.0/docs/legacy_comparison.md +98 -0
  55. mef3io-0.3.0/docs/matlab.md +85 -0
  56. mef3io-0.3.0/docs/mef3_format.md +218 -0
  57. mef3io-0.3.0/docs/python.md +151 -0
  58. mef3io-0.3.0/docs/releasing.md +41 -0
  59. mef3io-0.3.0/examples/01_write_and_read.py +49 -0
  60. mef3io-0.3.0/examples/02_int32_primitive.py +41 -0
  61. mef3io-0.3.0/examples/03_appending.py +62 -0
  62. mef3io-0.3.0/examples/04_segment_map.py +50 -0
  63. mef3io-0.3.0/examples/05_annotations.py +49 -0
  64. mef3io-0.3.0/examples/06_encryption.py +42 -0
  65. mef3io-0.3.0/examples/07_legacy_mef_tools_style.py +65 -0
  66. mef3io-0.3.0/examples/08_legacy_compatibility.py +153 -0
  67. mef3io-0.3.0/examples/09_encryption_replicability.py +230 -0
  68. mef3io-0.3.0/examples/README.md +22 -0
  69. mef3io-0.3.0/for_agents/mef3io_handoff.md +241 -0
  70. mef3io-0.3.0/matlab/+mef3io/Reader.m +76 -0
  71. mef3io-0.3.0/matlab/+mef3io/Writer.m +104 -0
  72. mef3io-0.3.0/matlab/README.md +69 -0
  73. mef3io-0.3.0/matlab/benchmark_mef3io.m +63 -0
  74. mef3io-0.3.0/matlab/build_mex.m +47 -0
  75. mef3io-0.3.0/matlab/mef3io_mex.cpp +440 -0
  76. mef3io-0.3.0/matlab/test_mef3io.m +116 -0
  77. mef3io-0.3.0/mkdocs.yml +47 -0
  78. mef3io-0.3.0/pyproject.toml +77 -0
  79. mef3io-0.3.0/python/mef3io/__init__.py +46 -0
  80. mef3io-0.3.0/python/mef3io/_reader.py +137 -0
  81. mef3io-0.3.0/python/mef3io/_writer.py +135 -0
  82. mef3io-0.3.0/python/mef3io/cache.py +111 -0
  83. mef3io-0.3.0/python/mef3io/compat.py +239 -0
  84. mef3io-0.3.0/python/mef3io/pure/__init__.py +16 -0
  85. mef3io-0.3.0/scripts/dev_build.sh +22 -0
  86. mef3io-0.3.0/tests/conftest.py +31 -0
  87. mef3io-0.3.0/tests/generate_golden.py +261 -0
  88. mef3io-0.3.0/tests/golden/enc_both.mefd/ch1.timd/ch1-000000.segd/ch1-000000.tdat +0 -0
  89. mef3io-0.3.0/tests/golden/enc_both.mefd/ch1.timd/ch1-000000.segd/ch1-000000.tidx +0 -0
  90. mef3io-0.3.0/tests/golden/enc_both.mefd/ch1.timd/ch1-000000.segd/ch1-000000.tmet +0 -0
  91. mef3io-0.3.0/tests/golden/enc_both.npz +0 -0
  92. mef3io-0.3.0/tests/golden/fractional_fs.mefd/ch1.timd/ch1-000000.segd/ch1-000000.tdat +0 -0
  93. mef3io-0.3.0/tests/golden/fractional_fs.mefd/ch1.timd/ch1-000000.segd/ch1-000000.tidx +0 -0
  94. mef3io-0.3.0/tests/golden/fractional_fs.mefd/ch1.timd/ch1-000000.segd/ch1-000000.tmet +0 -0
  95. mef3io-0.3.0/tests/golden/fractional_fs.npz +0 -0
  96. mef3io-0.3.0/tests/golden/manifest.json +132 -0
  97. mef3io-0.3.0/tests/golden/multi_channel.mefd/ch1.timd/ch1-000000.segd/ch1-000000.tdat +0 -0
  98. mef3io-0.3.0/tests/golden/multi_channel.mefd/ch1.timd/ch1-000000.segd/ch1-000000.tidx +0 -0
  99. mef3io-0.3.0/tests/golden/multi_channel.mefd/ch1.timd/ch1-000000.segd/ch1-000000.tmet +0 -0
  100. mef3io-0.3.0/tests/golden/multi_channel.mefd/ch2.timd/ch2-000000.segd/ch2-000000.tdat +0 -0
  101. mef3io-0.3.0/tests/golden/multi_channel.mefd/ch2.timd/ch2-000000.segd/ch2-000000.tidx +0 -0
  102. mef3io-0.3.0/tests/golden/multi_channel.mefd/ch2.timd/ch2-000000.segd/ch2-000000.tmet +0 -0
  103. mef3io-0.3.0/tests/golden/multi_channel.npz +0 -0
  104. mef3io-0.3.0/tests/golden/multi_segment.mefd/ch1.timd/ch1-000000.segd/ch1-000000.tdat +0 -0
  105. mef3io-0.3.0/tests/golden/multi_segment.mefd/ch1.timd/ch1-000000.segd/ch1-000000.tidx +0 -0
  106. mef3io-0.3.0/tests/golden/multi_segment.mefd/ch1.timd/ch1-000000.segd/ch1-000000.tmet +0 -0
  107. mef3io-0.3.0/tests/golden/multi_segment.mefd/ch1.timd/ch1-000001.segd/ch1-000001.tdat +0 -0
  108. mef3io-0.3.0/tests/golden/multi_segment.mefd/ch1.timd/ch1-000001.segd/ch1-000001.tidx +0 -0
  109. mef3io-0.3.0/tests/golden/multi_segment.mefd/ch1.timd/ch1-000001.segd/ch1-000001.tmet +0 -0
  110. mef3io-0.3.0/tests/golden/multi_segment.npz +0 -0
  111. mef3io-0.3.0/tests/golden/nan_gap_long.mefd/ch1.timd/ch1-000000.segd/ch1-000000.tdat +0 -0
  112. mef3io-0.3.0/tests/golden/nan_gap_long.mefd/ch1.timd/ch1-000000.segd/ch1-000000.tidx +0 -0
  113. mef3io-0.3.0/tests/golden/nan_gap_long.mefd/ch1.timd/ch1-000000.segd/ch1-000000.tmet +0 -0
  114. mef3io-0.3.0/tests/golden/nan_gap_long.npz +0 -0
  115. mef3io-0.3.0/tests/golden/nan_gap_short.mefd/ch1.timd/ch1-000000.segd/ch1-000000.tdat +0 -0
  116. mef3io-0.3.0/tests/golden/nan_gap_short.mefd/ch1.timd/ch1-000000.segd/ch1-000000.tidx +0 -0
  117. mef3io-0.3.0/tests/golden/nan_gap_short.mefd/ch1.timd/ch1-000000.segd/ch1-000000.tmet +0 -0
  118. mef3io-0.3.0/tests/golden/nan_gap_short.npz +0 -0
  119. mef3io-0.3.0/tests/golden/plain_single.mefd/ch1.timd/ch1-000000.segd/ch1-000000.tdat +0 -0
  120. mef3io-0.3.0/tests/golden/plain_single.mefd/ch1.timd/ch1-000000.segd/ch1-000000.tidx +0 -0
  121. mef3io-0.3.0/tests/golden/plain_single.mefd/ch1.timd/ch1-000000.segd/ch1-000000.tmet +0 -0
  122. mef3io-0.3.0/tests/golden/plain_single.npz +0 -0
  123. mef3io-0.3.0/tests/golden/with_annotations.mefd/ch1.timd/ch1-000000.segd/ch1-000000.tdat +0 -0
  124. mef3io-0.3.0/tests/golden/with_annotations.mefd/ch1.timd/ch1-000000.segd/ch1-000000.tidx +0 -0
  125. mef3io-0.3.0/tests/golden/with_annotations.mefd/ch1.timd/ch1-000000.segd/ch1-000000.tmet +0 -0
  126. mef3io-0.3.0/tests/golden/with_annotations.mefd/ch1.timd/ch1.rdat +0 -0
  127. mef3io-0.3.0/tests/golden/with_annotations.mefd/ch1.timd/ch1.ridx +0 -0
  128. mef3io-0.3.0/tests/golden/with_annotations.npz +0 -0
  129. mef3io-0.3.0/tests/test_p1_headers.py +74 -0
  130. mef3io-0.3.0/tests/test_p2_read.py +98 -0
  131. mef3io-0.3.0/tests/test_p3_reader.py +90 -0
  132. mef3io-0.3.0/tests/test_p4_write.py +88 -0
  133. mef3io-0.3.0/tests/test_p5_write.py +129 -0
  134. mef3io-0.3.0/tests/test_p6_threads.py +71 -0
  135. mef3io-0.3.0/tests/test_p7_compat_cache.py +194 -0
  136. mef3io-0.3.0/tests/test_p8_append.py +233 -0
  137. mef3io-0.3.0/tests/test_p9_robustness.py +172 -0
@@ -0,0 +1,57 @@
1
+ name: bump-version
2
+
3
+ # Manual release trigger: bumps the repo-root VERSION file (the single source
4
+ # of truth for Python, C++, and later MATLAB), commits, tags vX.Y.Z, and
5
+ # dispatches the release workflow on that tag.
6
+ on:
7
+ workflow_dispatch:
8
+ inputs:
9
+ bump:
10
+ description: "patch | minor | major, or an explicit version like 1.2.3"
11
+ required: true
12
+ default: "patch"
13
+
14
+ permissions:
15
+ contents: write
16
+ actions: write
17
+
18
+ jobs:
19
+ bump:
20
+ runs-on: ubuntu-latest
21
+ steps:
22
+ - uses: actions/checkout@v4
23
+
24
+ - name: Compute new version
25
+ id: ver
26
+ run: |
27
+ cur=$(tr -d ' \n' < VERSION)
28
+ IFS=. read -r major minor patch <<< "$cur"
29
+ case "${{ inputs.bump }}" in
30
+ patch) new="$major.$minor.$((patch + 1))" ;;
31
+ minor) new="$major.$((minor + 1)).0" ;;
32
+ major) new="$((major + 1)).0.0" ;;
33
+ *)
34
+ new="${{ inputs.bump }}"
35
+ [[ "$new" =~ ^[0-9]+\.[0-9]+\.[0-9]+([a-z0-9.]*)?$ ]] || { echo "bad version: $new"; exit 1; }
36
+ ;;
37
+ esac
38
+ echo "current $cur -> new $new"
39
+ echo "new=$new" >> "$GITHUB_OUTPUT"
40
+
41
+ - name: Commit VERSION and tag
42
+ run: |
43
+ new="${{ steps.ver.outputs.new }}"
44
+ echo "$new" > VERSION
45
+ git config user.name "github-actions[bot]"
46
+ git config user.email "github-actions[bot]@users.noreply.github.com"
47
+ git add VERSION
48
+ git commit -m "Release v$new"
49
+ git tag "v$new"
50
+ git push origin "HEAD:${{ github.ref_name }}" "refs/tags/v$new"
51
+
52
+ # Tags pushed with GITHUB_TOKEN do not trigger push events (recursion
53
+ # guard), so start the release run on the new tag explicitly.
54
+ - name: Dispatch release workflow
55
+ env:
56
+ GH_TOKEN: ${{ github.token }}
57
+ run: gh workflow run release.yml --ref "v${{ steps.ver.outputs.new }}"
@@ -0,0 +1,91 @@
1
+ name: ci
2
+
3
+ on:
4
+ push:
5
+ branches: [main, dev]
6
+ pull_request:
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ cpp-tests:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - name: Build and run C++ unit tests
15
+ run: |
16
+ cmake -S core -B build-core -DMEF3IO_BUILD_TESTS=ON
17
+ cmake --build build-core -j
18
+ ctest --test-dir build-core --output-on-failure
19
+
20
+ python-tests:
21
+ name: pytest ${{ matrix.os }} / py${{ matrix.python-version }}
22
+ strategy:
23
+ fail-fast: false
24
+ matrix:
25
+ include:
26
+ - { os: ubuntu-latest, python-version: "3.10" }
27
+ - { os: ubuntu-latest, python-version: "3.12" }
28
+ - { os: ubuntu-latest, python-version: "3.13" }
29
+ - { os: macos-latest, python-version: "3.13" }
30
+ runs-on: ${{ matrix.os }}
31
+ steps:
32
+ - uses: actions/checkout@v4
33
+ - uses: actions/setup-python@v5
34
+ with:
35
+ python-version: ${{ matrix.python-version }}
36
+ - name: Install package with the oracle test stack
37
+ run: |
38
+ python -m pip install --upgrade pip
39
+ pip install ".[test]"
40
+ - name: Version sanity (single source of truth)
41
+ run: |
42
+ python -c "import mef3io; print('mef3io', mef3io.__version__)"
43
+ python -c "import mef3io, pathlib; v = pathlib.Path('VERSION').read_text().strip(); assert mef3io.__version__ == v, (mef3io.__version__, v)"
44
+ - name: Run test suite
45
+ run: python -m pytest tests -q
46
+
47
+ # Windows has no reliable pymef oracle build; verify compile + import + the
48
+ # oracle-free subset instead. Full Windows coverage happens in cibuildwheel.
49
+ windows-smoke:
50
+ runs-on: windows-latest
51
+ steps:
52
+ - uses: actions/checkout@v4
53
+ - uses: actions/setup-python@v5
54
+ with:
55
+ python-version: "3.13"
56
+ - name: Install and smoke-test
57
+ run: |
58
+ python -m pip install --upgrade pip
59
+ pip install .
60
+ python -c "import mef3io; assert mef3io.have_cpp_backend(); print('cpp backend OK,', mef3io.__version__)"
61
+
62
+ # Newest CPython, oracle-free (the legacy pymef stack may lag new Pythons):
63
+ # compile, import, and a full write/read round trip.
64
+ python-latest-smoke:
65
+ runs-on: ubuntu-latest
66
+ steps:
67
+ - uses: actions/checkout@v4
68
+ - uses: actions/setup-python@v5
69
+ with:
70
+ python-version: "3.14"
71
+ - name: Install and round-trip
72
+ run: |
73
+ python -m pip install --upgrade pip
74
+ pip install .
75
+ python -c "
76
+ import tempfile
77
+ import numpy as np
78
+ import mef3io
79
+ p = tempfile.mkdtemp() + '/s.mefd'
80
+ w = mef3io.Writer(p, overwrite=True)
81
+ d = np.sin(np.arange(1000) / 9)
82
+ d[100:200] = np.nan
83
+ w.write('ch', d, 1577836800000000, 256.0, precision=3)
84
+ w.close()
85
+ r = mef3io.Reader(p)
86
+ x = r.read('ch')
87
+ assert len(x) == 1000 and np.isnan(x[100:200]).all()
88
+ ok = ~np.isnan(d)
89
+ assert np.allclose(x[ok], np.round(d[ok], 3))
90
+ print('py3.14 round trip OK,', mef3io.__version__)
91
+ "
@@ -0,0 +1,39 @@
1
+ name: docs
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ workflow_dispatch:
7
+
8
+ permissions:
9
+ contents: read
10
+ pages: write
11
+ id-token: write
12
+
13
+ concurrency:
14
+ group: pages
15
+ cancel-in-progress: true
16
+
17
+ jobs:
18
+ build:
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ - uses: actions/setup-python@v5
23
+ with:
24
+ python-version: "3.12"
25
+ - run: pip install "mkdocs-material>=9,<10" "mkdocs>=1.6,<2"
26
+ - run: mkdocs build --strict
27
+ - uses: actions/upload-pages-artifact@v3
28
+ with:
29
+ path: site
30
+
31
+ deploy:
32
+ needs: build
33
+ runs-on: ubuntu-latest
34
+ environment:
35
+ name: github-pages
36
+ url: ${{ steps.deployment.outputs.page_url }}
37
+ steps:
38
+ - id: deployment
39
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,118 @@
1
+ name: release
2
+
3
+ # Builds wheels for every supported platform/arch and publishes to PyPI.
4
+ # Triggered by a version tag (created by the bump-version workflow, which also
5
+ # dispatches this workflow explicitly — tags pushed with GITHUB_TOKEN do not
6
+ # fire tag-push events). A plain workflow_dispatch on a branch is a dry run:
7
+ # wheels are built and uploaded as artifacts, but publishing is skipped.
8
+ on:
9
+ push:
10
+ tags: ["v*"]
11
+ workflow_dispatch:
12
+
13
+ jobs:
14
+ wheels:
15
+ name: wheels ${{ matrix.label }}
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ include:
20
+ - { os: ubuntu-latest, label: linux-x86_64 }
21
+ - { os: ubuntu-24.04-arm, label: linux-aarch64 }
22
+ - { os: windows-latest, label: windows-amd64 }
23
+ # CPython ships official Windows-on-ARM binaries from 3.11.
24
+ - { os: windows-11-arm, label: windows-arm64, cibw_build: "cp311-* cp312-* cp313-* cp314-*" }
25
+ # One macOS runner builds both arm64 and x86_64 (see pyproject).
26
+ - { os: macos-latest, label: macos }
27
+ runs-on: ${{ matrix.os }}
28
+ steps:
29
+ - uses: actions/checkout@v4
30
+ - name: Build wheels
31
+ uses: pypa/cibuildwheel@v3.4.1
32
+ env:
33
+ CIBW_BUILD: ${{ matrix.cibw_build || '' }}
34
+ - uses: actions/upload-artifact@v4
35
+ with:
36
+ name: wheels-${{ matrix.label }}
37
+ path: ./wheelhouse/*.whl
38
+
39
+ sdist:
40
+ runs-on: ubuntu-latest
41
+ steps:
42
+ - uses: actions/checkout@v4
43
+ - name: Build sdist
44
+ run: pipx run build --sdist
45
+ - uses: actions/upload-artifact@v4
46
+ with:
47
+ name: sdist
48
+ path: dist/*.tar.gz
49
+
50
+ # MATLAB MEX binaries for the platforms MATLAB supports. Free MathWorks
51
+ # licensing on GitHub-hosted runners applies to public repos; on a private
52
+ # repo these jobs need a MathWorks batch token (they don't block PyPI).
53
+ mex:
54
+ name: mex ${{ matrix.label }}
55
+ strategy:
56
+ fail-fast: false
57
+ matrix:
58
+ include:
59
+ - { os: ubuntu-latest, label: linux-x86_64 } # mexa64
60
+ - { os: windows-latest, label: windows-amd64 } # mexw64
61
+ - { os: macos-latest, label: macos-arm64 } # mexmaca64
62
+ runs-on: ${{ matrix.os }}
63
+ steps:
64
+ - uses: actions/checkout@v4
65
+ - uses: matlab-actions/setup-matlab@v2
66
+ with:
67
+ release: latest
68
+ - name: Build and test the MEX
69
+ uses: matlab-actions/run-command@v2
70
+ with:
71
+ command: cd('matlab'); build_mex; test_mef3io
72
+ - uses: actions/upload-artifact@v4
73
+ with:
74
+ name: mex-${{ matrix.label }}
75
+ path: matlab/*.mex*
76
+
77
+ publish:
78
+ if: startsWith(github.ref, 'refs/tags/')
79
+ needs: [wheels, sdist]
80
+ runs-on: ubuntu-latest
81
+ steps:
82
+ - uses: actions/download-artifact@v4
83
+ with:
84
+ path: dist
85
+ merge-multiple: true
86
+ - uses: actions/setup-python@v5
87
+ with:
88
+ python-version: "3.12"
89
+ - name: Publish to PyPI
90
+ env:
91
+ TWINE_USERNAME: __token__
92
+ TWINE_PASSWORD: ${{ secrets.PYPI_Token_General }}
93
+ run: |
94
+ python -m pip install --upgrade pip twine
95
+ twine upload --skip-existing dist/*.whl dist/*.tar.gz
96
+
97
+ # GitHub release with the MEX binaries attached (their extensions are
98
+ # platform-unique: mexa64 / mexw64 / mexmaca64, so they upload flat).
99
+ github-release:
100
+ if: startsWith(github.ref, 'refs/tags/')
101
+ needs: [mex]
102
+ permissions:
103
+ contents: write
104
+ runs-on: ubuntu-latest
105
+ steps:
106
+ - uses: actions/download-artifact@v4
107
+ with:
108
+ pattern: "mex-*"
109
+ path: mexbin
110
+ merge-multiple: true
111
+ - name: Create release and attach MEX binaries
112
+ env:
113
+ GH_TOKEN: ${{ github.token }}
114
+ run: |
115
+ gh release create "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" \
116
+ --title "$GITHUB_REF_NAME" --generate-notes || true
117
+ gh release upload "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" \
118
+ --clobber mexbin/*.mex*
@@ -0,0 +1,16 @@
1
+ build/
2
+ build-core/
3
+ dist/
4
+ wheelhouse/
5
+ *.egg-info/
6
+ __pycache__/
7
+ *.pyc
8
+ .pytest_cache/
9
+ python/mef3io/_mef3io*.so
10
+ python/mef3io/_mef3io*.pyd
11
+ # reference sources (meflib/pymef/mef3_dump), kept next to the repo but untracked
12
+ ../reference_files/
13
+ reference_files/
14
+ .idea/
15
+ matlab/*.mex*
16
+ site/
mef3io-0.3.0/CLAUDE.md ADDED
@@ -0,0 +1,124 @@
1
+ # mef3io — assistant context
2
+
3
+ A single C++17/20 core for **MEF 3.0** read+write, wrapped for Python via
4
+ nanobind. The high-level semantics of the legacy `mef_tools` (float scaling,
5
+ NaN discontinuities, precision inference, the int32-counts + conversion-factor
6
+ primitive path) live in **C++** so all bindings behave identically. Video is out
7
+ of scope. The legacy `mef_tools`/`pymef` stack is the correctness oracle.
8
+
9
+ Status: read + write complete, cross-validated **both directions** vs
10
+ pymef/mef_tools (values, NaN gaps, times, encryption none/L1+L2, fractional fs,
11
+ records). In-segment append + per-segment map implemented. ~112 Python tests +
12
+ standalone C++ Catch2 tests. Wheel builds via `python -m build`. Parallel
13
+ decode/encode, byte-deterministic across threads.
14
+
15
+ ## Build & test (use the active conda env for everything)
16
+
17
+ ```bash
18
+ scripts/dev_build.sh # builds build/dev, symlinks _mef3io*.so into python/mef3io/
19
+ python -m pytest tests # conftest.py sets up paths; pymef needed as oracle
20
+ # C++ unit tests:
21
+ cmake -S core -B build-core -DMEF3IO_BUILD_TESTS=ON && cmake --build build-core && ctest --test-dir build-core
22
+ python -m build --wheel # wheel
23
+ ```
24
+
25
+ This is the standalone mef3io repo (github.com/bnelair/mef3io), migrated out of
26
+ the original `mef_tools` repo in July 2026. The legacy `mef_tools` oracle now
27
+ comes from the pip-installed `mef-tools` package (`pip install mef3io[test]`);
28
+ `tests/conftest.py` still prefers a local checkout if one exists in a parent
29
+ directory. `reference_files/` (meflib/pymef/mef3_dump) stayed in the old repo.
30
+
31
+ ## Module map
32
+
33
+ `core/` (C++): `types` (aliases + format constants), `byteio` (LE field IO, no
34
+ packed-struct casts), `crc` (Koopman-32), `crypto` (SHA-256, AES-128-ECB,
35
+ two-level password), `headers` (UniversalHeader, MetadataSection1/2/3,
36
+ TimeSeriesIndex, RedBlockHeader — parse/serialize by explicit offset),
37
+ `metadata` (.tmet loader: CRC→password→decrypt), `red` (decode + encode),
38
+ `session` (lazy .mefd/.timd/.segd tree, indexed reads, `collect_blocks`),
39
+ `reader` (gridding, NaN fill, scaling, parallel decode), `records` (read+write),
40
+ `writer` (segment writer), `session_writer` (precision inference, quantization,
41
+ NaN splitting, segments), `parallel.hpp`.
42
+
43
+ `python/mef3io/`: `Reader`, `Writer` (incl. `write_annotations`), `compat`
44
+ (mef_tools.io drop-in; `MefReader`/`MefWriter` are also re-exported at the top
45
+ level — `from mef3io import MefReader, MefWriter` — via lazy `__getattr__`),
46
+ `cache` (opt-in warm start), `pure` (stub). `bindings/python/mef3io_ext.cpp` =
47
+ nanobind. `matlab/` = MEX + `+mef3io` classes. `examples/` = runnable scripts
48
+ (write/read, int32, append, segment map, annotations, encryption, legacy
49
+ style). Docs site: MkDocs Material from `docs/` (`mkdocs.yml`; nav pages
50
+ index/install/python/matlab/cpp/examples/releasing + the reference docs),
51
+ deployed to GitHub Pages by `.github/workflows/docs.yml` on push to main —
52
+ keep `mkdocs build --strict` green; `for_agents/` (repo root) holds agent handoff docs, outside the site. `docs/design.md` = full design; `docs/encryption_model.md` = crypto
53
+ model; `docs/mef3_format.md` = format reference.
54
+
55
+ ## Format gotchas (do NOT relearn the hard way)
56
+
57
+ - **Times are stored NEGATED on disk** as meflib's "recording-time-offset
58
+ applied" marker. User uUTC = `(t>=0)?t:(-t+rto)` (read), `disk = rto-absolute`
59
+ (write). Applies to UH start/end AND block/record times. rto=0 in fixtures.
60
+ Missing this makes every time-range read return 0 samples.
61
+ - **Encryption is all-or-nothing pairing**: section 2 → L1 key, section 3 → L2
62
+ key, by password presence. "Level-1 only" is not a valid file. Decrypt a
63
+ section only when its stored level is strictly positive; unencrypted files
64
+ carry -1/-2 (`0xFF`/`0xFE`). See docs/encryption_model.md.
65
+ - **Password scheme**: bytes = terminal byte of each UTF-8 char, 16, zero-pad.
66
+ L1 field = SHA256(L1)[:16]; L2 field = SHA256(L2)[:16] XOR L1. L2 access
67
+ derives putative L1 = SHA256(pwd)[:16] XOR L2field, checks its hash.
68
+ - **RED data blocks are UNENCRYPTED** even in encrypted sessions (meflib
69
+ default); only metadata s2/s3 and record bodies are encrypted.
70
+ - **Index file_offset is FILE-relative** (includes the 1024 B UH); first block
71
+ offset = 1024. Windowed reads must read only the needed byte range
72
+ (`collect_blocks` uses `read_file_range`), not the whole `.tdat`.
73
+ - **RED encode**: first emitted byte is junk (meflib overwrites stats[255] then
74
+ restores) → drop emitted[0], payload = emitted[1:] at offset 304; stored
75
+ difference_bytes = generated+1. Lossless no-detrend/no-scale, pymef-readable.
76
+ Constants: TOP_VALUE 0x80000000, CARRY_CHECK 0x7F800000, SHIFT_BITS 23,
77
+ EXTRA_BITS 7, BOTTOM_VALUE 0x800000, PAD_BYTE 0x7e, 8-byte alignment.
78
+ - **Records**: header 24 B (crc@0,type[4]@4,vmaj@9,vmin@10,enc@11,bytes@12,
79
+ time@16). Body padded to 16-byte multiple with 0x7e. L2-encrypted when the
80
+ session is encrypted. `.ridx` entry 24 B (type@0,vmaj@5,vmin@6,enc@7,
81
+ offset@8,time@16). file_offset FILE-relative.
82
+ - **Oracle**: use `pymef` `read_ts_channels_sample([ch],[0,nsamp])` for decoded
83
+ int32 (no gap NaN) and `read_ts_channels_uutc` for gap-filled. `mef3_dump` is
84
+ NOT usable (reads the encryption sentinel byte unsigned). Manifest `nsamp` !=
85
+ stored nsamp (it's get_raw_data length incl. gaps) — compare vs pymef
86
+ basic_info.
87
+
88
+ ## Known limitations / next steps
89
+
90
+ - **In-segment append implemented** (`append_time_series_segment` +
91
+ `SessionWriter` hydration): non-first writes extend the channel's last
92
+ segment in place (.tdat streamed-CRC append, .tidx extend, .tmet s2 rewrite);
93
+ `new_segment=True` forces a fresh segment. Appends validate fs/ufact/start
94
+ time vs on-disk metadata (`WriteConflictError` → Python RuntimeError); float
95
+ appends reuse the segment's precision. `Reader.segments(ch)` maps what data
96
+ is where per segment. First appended block keeps discontinuity=true (readers
97
+ are time-gridded so contiguous appends stay seamless).
98
+ - **Do NOT `pip install -e .` for C++ dev** — scikit-build-core's editable hook
99
+ loads an install-time extension snapshot that shadows the dev_build symlink
100
+ (meta-path beats sys.path). Keep mef3io uninstalled; use scripts/dev_build.sh.
101
+ - Pure-Python backend is a stub. Records write covers Note/EDFA/SyLg/Seiz.
102
+ Cache is Python-level (a C++ warm-start is future).
103
+ - **MATLAB binding implemented**: flat C ABI (`core/include/mef3io/c_api.h`,
104
+ Catch2-tested) → single command-dispatch MEX (`matlab/mef3io_mex.cpp`) →
105
+ `+mef3io` Reader/Writer classes. Build with `matlab/build_mex.m` (C++20
106
+ compiler; do NOT add -fvisibility=hidden — it hides the MEX version symbols
107
+ → "not supported in current release"). `matlab/test_mef3io.m` = round trip;
108
+ validated cross-language both directions vs Python/pymef with R2026a.
109
+ Append-overlap check has half-a-sample-period slack (per-block half-us time
110
+ rounding can store a segment end ~1 us past the grid-exact end).
111
+ - Distribution: **version single source of truth = repo-root `VERSION` file**
112
+ (pyproject regex provider → wheel metadata; CMake → `mef3io::version()` and
113
+ the extension's `__version__`; `mef3io.__version__` prefers installed dist
114
+ metadata). Release flow: manually run the `bump-version` workflow
115
+ (patch/minor/major or explicit) → commits VERSION, tags vX.Y.Z, dispatches
116
+ `release.yml` → cibuildwheel on linux x86_64+aarch64, windows AMD64+ARM64
117
+ (cp311+ on ARM), macOS arm64+x86_64, + sdist → twine upload using the
118
+ `PYPI_Token_General` secret. `ci.yml` = tests on push/PR (main, dev). PyPI
119
+ name not yet reserved. Then: benchmark vs legacy, cut mef_tools 3.0 as a
120
+ compat re-export. Keep mef3io brand-neutral; brainmaze-mef3-server should
121
+ depend on it (see docs/design.md).
122
+
123
+ Benchmarks: `benchmarks/mef_benchmark.py` (write/open/seq/parallel vs mef_tools
124
+ & NWB-Zarr) and `benchmarks/compression_test.py` (file size / compression).
@@ -0,0 +1,26 @@
1
+ # Top-level build for the mef3io Python extension (driven by scikit-build-core).
2
+ cmake_minimum_required(VERSION 3.26)
3
+
4
+ # Single source of truth for the version (shared with the wheel metadata via
5
+ # pyproject.toml's regex provider, and with C++ via mef3io/version.hpp).
6
+ file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" MEF3IO_VERSION LIMIT_COUNT 1)
7
+ project(mef3io VERSION ${MEF3IO_VERSION} LANGUAGES CXX)
8
+
9
+ add_subdirectory(core)
10
+
11
+ # --- nanobind extension ---
12
+ find_package(Python 3.10 REQUIRED COMPONENTS Interpreter Development.Module)
13
+
14
+ # Locate nanobind's CMake config via the installed package.
15
+ execute_process(
16
+ COMMAND "${Python_EXECUTABLE}" -m nanobind --cmake_dir
17
+ OUTPUT_STRIP_TRAILING_WHITESPACE
18
+ OUTPUT_VARIABLE NB_DIR)
19
+ list(APPEND CMAKE_PREFIX_PATH "${NB_DIR}")
20
+ find_package(nanobind CONFIG REQUIRED)
21
+
22
+ nanobind_add_module(_mef3io STABLE_ABI bindings/python/mef3io_ext.cpp)
23
+ target_link_libraries(_mef3io PRIVATE mef3io_core)
24
+ target_compile_features(_mef3io PRIVATE cxx_std_20)
25
+
26
+ install(TARGETS _mef3io LIBRARY DESTINATION mef3io)
mef3io-0.3.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+