c2ImageD11 0.2.1__tar.gz → 0.4.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 (56) hide show
  1. c2imaged11-0.4.0/.github/workflows/docs.yml +71 -0
  2. c2imaged11-0.4.0/.github/workflows/release.yml +82 -0
  3. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/.github/workflows/test-aarch64.yml +1 -1
  4. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/.github/workflows/test.yml +16 -0
  5. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/AGENTS.md +52 -0
  6. {c2imaged11-0.2.1/c2ImageD11.egg-info → c2imaged11-0.4.0}/PKG-INFO +1 -1
  7. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/c2ImageD11/__init__.py +15 -7
  8. {c2imaged11-0.2.1 → c2imaged11-0.4.0/c2ImageD11.egg-info}/PKG-INFO +1 -1
  9. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/c2ImageD11.egg-info/SOURCES.txt +5 -15
  10. c2imaged11-0.4.0/lib/interface/_cImageD11.c2py +2325 -0
  11. c2imaged11-0.4.0/lib/interface/_cImageD11_wrapper.c +28442 -0
  12. c2imaged11-0.4.0/lib/interface/c2py.h +2522 -0
  13. c2imaged11-0.4.0/lib/meson.build +223 -0
  14. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/setup.py +1 -2
  15. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/tests/test_equivalence.py +7 -5
  16. c2imaged11-0.4.0/tests/test_typecheck.py +63 -0
  17. c2imaged11-0.4.0/tests/test_variants.py +163 -0
  18. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/tools/harvester.py +158 -93
  19. c2imaged11-0.2.1/lib/interface/_cImageD11.c2py +0 -705
  20. c2imaged11-0.2.1/lib/interface/_cImageD11_wrapper.c +0 -27638
  21. c2imaged11-0.2.1/lib/interface/c2py_runtime.c +0 -847
  22. c2imaged11-0.2.1/lib/interface/c2py_runtime.h +0 -760
  23. c2imaged11-0.2.1/lib/meson.build +0 -69
  24. c2imaged11-0.2.1/lib/src/core/ImageD11_cmath.h +0 -45
  25. c2imaged11-0.2.1/lib/src/core/cImageD11.h +0 -69
  26. c2imaged11-0.2.1/lib/src/core/cimaged11utils.c +0 -93
  27. c2imaged11-0.2.1/lib/src/geometry/cdiffraction.c +0 -464
  28. c2imaged11-0.2.1/lib/src/geometry/cdiffraction.h +0 -16
  29. c2imaged11-0.2.1/lib/src/geometry/closest.c +0 -1299
  30. c2imaged11-0.2.1/lib/src/imageproc/blobs.c +0 -292
  31. c2imaged11-0.2.1/lib/src/imageproc/blobs.h +0 -152
  32. c2imaged11-0.2.1/lib/src/imageproc/connectedpixels.c +0 -648
  33. c2imaged11-0.2.1/lib/src/imageproc/darkflat.c +0 -757
  34. c2imaged11-0.2.1/lib/src/imageproc/localmaxlabel.c +0 -220
  35. c2imaged11-0.2.1/lib/src/imageproc/sparse_image.c +0 -1191
  36. c2imaged11-0.2.1/lib/src/imageproc/splat.c +0 -77
  37. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/.githooks/check_all_pythons.sh +0 -0
  38. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/.githooks/pre-commit +0 -0
  39. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/.githooks/pre-push +0 -0
  40. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/.github/workflows/test-py27.yml +0 -0
  41. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/LICENSE +0 -0
  42. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/MANIFEST.in +0 -0
  43. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/README.md +0 -0
  44. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/c2ImageD11.egg-info/dependency_links.txt +0 -0
  45. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/c2ImageD11.egg-info/not-zip-safe +0 -0
  46. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/c2ImageD11.egg-info/requires.txt +0 -0
  47. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/c2ImageD11.egg-info/top_level.txt +0 -0
  48. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/lib/interface/c2py_amd64.h +0 -0
  49. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/lib/interface/c2py_arm64.h +0 -0
  50. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/lib/interface/c2py_ppc64.h +0 -0
  51. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/pyproject.toml +0 -0
  52. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/setup.cfg +0 -0
  53. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/tests/benchmark_timing.py +0 -0
  54. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/tests/conftest.py +0 -0
  55. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/tests/test_buffer.py +0 -0
  56. {c2imaged11-0.2.1 → c2imaged11-0.4.0}/tools/strip_c2py.py +0 -0
@@ -0,0 +1,71 @@
1
+ name: docs
2
+
3
+ on:
4
+ workflow_run:
5
+ workflows: [CI]
6
+ types: [completed]
7
+ branches: [master]
8
+
9
+ permissions:
10
+ contents: read
11
+ actions: read
12
+ pages: write
13
+ id-token: write
14
+
15
+ concurrency:
16
+ group: pages
17
+ cancel-in-progress: false
18
+
19
+ jobs:
20
+ build-docs:
21
+ if: github.event.workflow_run.conclusion == 'success'
22
+ runs-on: ubuntu-latest
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+
26
+ - name: Setup Python
27
+ uses: actions/setup-python@v5
28
+ with:
29
+ python-version: '3.12'
30
+
31
+ - name: Download wheel from CI
32
+ uses: dawidd6/action-download-artifact@v6
33
+ with:
34
+ workflow: test.yml
35
+ run_id: ${{ github.event.workflow_run.id }}
36
+ name: dist-linux
37
+ path: dist/
38
+ github_token: ${{ secrets.GITHUB_TOKEN }}
39
+
40
+ - name: Install c2ImageD11 wheel
41
+ run: pip install dist/*.whl
42
+
43
+ - name: Install ImageD11 (for comparison section)
44
+ run: >
45
+ pip install ImageD11 --only-binary :all: --no-deps
46
+ || echo "ImageD11 not available"
47
+
48
+ - name: Install doc deps
49
+ run: pip install numpy c2py23 mkdocs-material
50
+
51
+ - name: Generate docs
52
+ run: python tools/generate_docs.py
53
+
54
+ - name: Build site
55
+ run: mkdocs build -f docs/mkdocs.yml
56
+
57
+ - name: Upload artifact
58
+ uses: actions/upload-pages-artifact@v3
59
+ with:
60
+ path: site
61
+
62
+ deploy:
63
+ needs: build-docs
64
+ runs-on: ubuntu-latest
65
+ environment:
66
+ name: github-pages
67
+ url: ${{ steps.deployment.outputs.page_url }}
68
+ steps:
69
+ - name: Deploy to GitHub Pages
70
+ id: deployment
71
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,82 @@
1
+ name: release
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ permissions:
8
+ contents: write
9
+ actions: read
10
+
11
+ jobs:
12
+ attach-wheels:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - name: Download dist-linux (x86_64)
18
+ uses: dawidd6/action-download-artifact@v6
19
+ continue-on-error: true
20
+ with:
21
+ workflow: test.yml
22
+ workflow_conclusion: success
23
+ branch: master
24
+ name: dist-linux
25
+ path: dist/
26
+ workflow_search: true
27
+ if_no_artifact_found: warn
28
+ github_token: ${{ secrets.GITHUB_TOKEN }}
29
+
30
+ - name: Download dist-linux-aarch64
31
+ uses: dawidd6/action-download-artifact@v6
32
+ continue-on-error: true
33
+ with:
34
+ workflow: test-aarch64.yml
35
+ workflow_conclusion: success
36
+ branch: master
37
+ name: dist-linux-aarch64
38
+ path: dist/
39
+ workflow_search: true
40
+ if_no_artifact_found: warn
41
+ github_token: ${{ secrets.GITHUB_TOKEN }}
42
+
43
+ - name: Download dist-windows
44
+ uses: dawidd6/action-download-artifact@v6
45
+ continue-on-error: true
46
+ with:
47
+ workflow: test.yml
48
+ workflow_conclusion: success
49
+ branch: master
50
+ name: dist-windows
51
+ path: dist/
52
+ workflow_search: true
53
+ if_no_artifact_found: warn
54
+ github_token: ${{ secrets.GITHUB_TOKEN }}
55
+
56
+ - name: Re-upload as artifact (bridge to pypi-publish)
57
+ uses: actions/upload-artifact@v4
58
+ with:
59
+ name: release-wheels
60
+ path: dist/
61
+
62
+ - name: Upload to GitHub Release
63
+ uses: softprops/action-gh-release@v2
64
+ with:
65
+ files: dist/*.whl
66
+ fail_on_unmatched_files: false
67
+
68
+ pypi-publish:
69
+ needs: attach-wheels
70
+ runs-on: ubuntu-latest
71
+ environment:
72
+ name: pypi
73
+ permissions:
74
+ id-token: write
75
+ steps:
76
+ - name: Download release wheels
77
+ uses: actions/download-artifact@v4
78
+ with:
79
+ name: release-wheels
80
+ path: dist/
81
+
82
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -48,4 +48,4 @@ jobs:
48
48
 
49
49
  - name: Run tests
50
50
  run: |
51
- python -m pytest tests/test_buffer.py tests/test_equivalence.py -v
51
+ python -m pytest tests/test_buffer.py tests/test_equivalence.py tests/test_variants.py -v
@@ -38,6 +38,10 @@ jobs:
38
38
  rm -f dist/*.whl
39
39
  mv /tmp/wheelhouse/*.whl dist/
40
40
 
41
+ - name: Build sdist
42
+ run: |
43
+ python setup.py sdist
44
+
41
45
  - uses: actions/upload-artifact@v4
42
46
  with:
43
47
  name: dist-linux
@@ -80,6 +84,11 @@ jobs:
80
84
  run: |
81
85
  cd "$(mktemp -d)" && python -m pytest "$GITHUB_WORKSPACE/tests/" -v
82
86
 
87
+ - name: Verify docs integrity
88
+ run: |
89
+ cd "$GITHUB_WORKSPACE"
90
+ python tools/verify_docs.py
91
+
83
92
  windows-wheel:
84
93
  runs-on: windows-latest
85
94
  defaults:
@@ -166,6 +175,13 @@ jobs:
166
175
  move %GITHUB_WORKSPACE%\c2ImageD11\__init__.py %GITHUB_WORKSPACE%\c2ImageD11\__init__.py.bak
167
176
  cd %TEMP% && python -m pytest %GITHUB_WORKSPACE%\tests\ -v
168
177
 
178
+ - name: Benchmark (Python 3.12 only)
179
+ if: matrix.python-version == '3.12'
180
+ run: |
181
+ cd %TEMP% && python %GITHUB_WORKSPACE%\lib\functions\score\bench.py
182
+ cd %TEMP% && python %GITHUB_WORKSPACE%\lib\functions\score_and_refine\bench.py
183
+ continue-on-error: true
184
+
169
185
  linux-test:
170
186
  needs: [linux-test-matrix]
171
187
  if: always()
@@ -9,6 +9,21 @@ shared library `_cImageD11.so` that can be distributed like a ctypes library
9
9
  All C functions are exposed directly by c2py23's generated wrapper -- no
10
10
  hand-written adapter code.
11
11
 
12
+ ## RULES
13
+
14
+ ### NO CTYPES
15
+
16
+ **Never use `ctypes` anywhere in this project.** Not in benchmarks, not in
17
+ tests, not in tools. The sole exception is `lib/functions/score_and_refine/
18
+ measure_flags.py` which is a standalone research tool that builds its own .so
19
+ files and measures them directly -- it does not ship.
20
+
21
+ The c2py23 module exposes every C function as a Python-callable name.
22
+ Variant dispatch uses `when:` conditions in the C2PY_BEGIN YAML blocks.
23
+ Performance counters use `_c2py_perf_read(ptr, bytearray)`, not ctypes.
24
+ CPU feature flags are checked internally by the wrapper C code -- there is
25
+ no reason to read or write them from Python.
26
+
12
27
  ## Current Status
13
28
 
14
29
  - Meson (in `lib/`) builds `_cImageD11.so` directly via `shared_module()`
@@ -265,3 +280,40 @@ is deferred.
265
280
  `_cImageD11_AMD64.pyd`. Linux test matrix 3.8-3.13, Windows 3.10-3.13.
266
281
  - **Compiler warnings:** all fixed (RAD/DEG, printf %td, explicit casts).
267
282
  - **c2py23 HEAD tracking:** regenerated wrappers committed in git, un-pinned.
283
+
284
+ ## Build copy step
285
+
286
+ After `ninja`, always copy to both names:
287
+
288
+ ```bash
289
+ cp build/libc2ImageD11/_cImageD11.so c2ImageD11/_cImageD11.so
290
+ cp build/libc2ImageD11/_cImageD11.so c2ImageD11/_cImageD11_$(python3 -c "import platform; print(platform.machine())").so
291
+ ```
292
+
293
+ Or use a helper script.
294
+
295
+ ## score_and_refine optimization workflow
296
+
297
+ Files live in `lib/functions/score_and_refine/`:
298
+
299
+ - `score_and_refine.c` — original C reference, kept as baseline
300
+ - `score_and_refine.hpp` — C++ template (C99 + templates, no stdlib)
301
+ - `score_and_refine_f64.cpp` — f64 instantiation (gv.type == double)
302
+ - `score_and_refine_f32.cpp` — f32 instantiation (gv.type == float)
303
+ - `bench.py` — benchmarks f64 vs f32 at multiple problem sizes
304
+ - `test_data.py` — reproducible test data generator
305
+ - `score_and_refine_f64_avx2.cpp` (future)
306
+ - `score_and_refine_f64_avx512.cpp` (future)
307
+ - `score_and_refine_f32_avx2.cpp` (future)
308
+ - `score_and_refine_f32_avx512.cpp` (future)
309
+
310
+ Variants share the same Python name `score_and_refine`. c2py23 dispatches via
311
+ `when:` conditions on `gv.format` and CPU feature flags. Overloads from
312
+ variant `.cpp` files are prepended before the `.c` baseline in the
313
+ generated dispatch chain (first-match wins).
314
+
315
+ Harvester now scans `.cpp` files and merges `C2PY_BEGIN` blocks with the
316
+ same `py_sig` by prepending `c_overloads` from each variant.
317
+
318
+ Meson: `project()` includes `'cpp'`. C++ sources in `c2_sources_cpp`.
319
+ Per-ISA flags via separate `static_library()` targets (future).
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: c2ImageD11
3
- Version: 0.2.1
3
+ Version: 0.4.0
4
4
  Summary: C extensions for ImageD11 (c2py23 binding)
5
5
  Author-email: Jon Wright <wright@esrf.fr>
6
6
  Project-URL: Homepage, https://github.com/jonwright/c2ImageD11
@@ -10,7 +10,7 @@ Provides:
10
10
 
11
11
  from __future__ import absolute_import, division, print_function, unicode_literals
12
12
 
13
- __version__ = "0.2.1"
13
+ __version__ = "0.4.0"
14
14
 
15
15
  import os
16
16
  import platform
@@ -61,34 +61,42 @@ if _mod is not None:
61
61
  # Make _cImageD11 importable as c2ImageD11._cImageD11
62
62
  sys.modules[__name__]._cImageD11 = _mod
63
63
 
64
+ # Save raw C functions before any overwrites
65
+ _blobproperties_c = _mod.blobproperties
66
+ _sparse_blob2Dproperties_c = _mod.sparse_blob2Dproperties
67
+
64
68
  # Re-export all non-private names from the loaded module
65
69
  for _k in dir(_mod):
66
70
  if not _k.startswith("_"):
67
71
  globals()[_k] = getattr(_mod, _k)
68
72
 
73
+ # ---- score_and_refine: single entry point, AoS/SoA dispatch in c2py23 wrapper ----
69
74
 
70
- _blobproperties_c = _mod.blobproperties # save raw C function
75
+ import numpy as np
71
76
 
72
77
  def blobproperties(data, labels, npk, omega=0.0, verbose=0):
73
78
  """Allocate results and call C blobproperties, matching f2py convention."""
74
- import numpy as np
75
79
  results = np.zeros((npk, 36), dtype=np.float64)
76
80
  _blobproperties_c(data, labels, npk, results, omega, verbose)
77
81
  return results
78
82
 
79
- _sparse_blob2Dproperties_c = _mod.sparse_blob2Dproperties
80
-
81
83
  def sparse_blob2Dproperties(v, i, j, labels, npk):
82
84
  """Allocate results and call C sparse_blob2Dproperties, matching f2py convention."""
83
- import numpy as np
84
85
  results = np.zeros((npk, 11), dtype=np.float64)
85
86
  _sparse_blob2Dproperties_c(v, i, j, labels, npk, results)
86
87
  return results
87
88
 
88
- # Replace raw C functions on submodule with allocation wrappers
89
+ # Replace raw C functions on submodule with wrappers
89
90
  _mod.blobproperties = blobproperties
90
91
  _mod.sparse_blob2Dproperties = sparse_blob2Dproperties
91
92
 
93
+ # -----------------------------------------------------------------------
94
+ # OpenMP minimum ng threshold. Must match the `ng > 50000` guard in
95
+ # lib/functions/score_and_refine/score_and_refine.hpp. Measured cutoff:
96
+ # ng <= 10000 | single-thread; ng > 10000 | ~2x speedup on x86_64.
97
+ # -----------------------------------------------------------------------
98
+ OMP_MIN_NG = 10000
99
+
92
100
 
93
101
  # -----------------------------------------------------------------------
94
102
  # OpenMP safety
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: c2ImageD11
3
- Version: 0.2.1
3
+ Version: 0.4.0
4
4
  Summary: C extensions for ImageD11 (c2py23 binding)
5
5
  Author-email: Jon Wright <wright@esrf.fr>
6
6
  Project-URL: Homepage, https://github.com/jonwright/c2ImageD11
@@ -7,6 +7,8 @@ setup.py
7
7
  .githooks/check_all_pythons.sh
8
8
  .githooks/pre-commit
9
9
  .githooks/pre-push
10
+ .github/workflows/docs.yml
11
+ .github/workflows/release.yml
10
12
  .github/workflows/test-aarch64.yml
11
13
  .github/workflows/test-py27.yml
12
14
  .github/workflows/test.yml
@@ -20,27 +22,15 @@ c2ImageD11.egg-info/top_level.txt
20
22
  lib/meson.build
21
23
  lib/interface/_cImageD11.c2py
22
24
  lib/interface/_cImageD11_wrapper.c
25
+ lib/interface/c2py.h
23
26
  lib/interface/c2py_amd64.h
24
27
  lib/interface/c2py_arm64.h
25
28
  lib/interface/c2py_ppc64.h
26
- lib/interface/c2py_runtime.c
27
- lib/interface/c2py_runtime.h
28
- lib/src/core/ImageD11_cmath.h
29
- lib/src/core/cImageD11.h
30
- lib/src/core/cimaged11utils.c
31
- lib/src/geometry/cdiffraction.c
32
- lib/src/geometry/cdiffraction.h
33
- lib/src/geometry/closest.c
34
- lib/src/imageproc/blobs.c
35
- lib/src/imageproc/blobs.h
36
- lib/src/imageproc/connectedpixels.c
37
- lib/src/imageproc/darkflat.c
38
- lib/src/imageproc/localmaxlabel.c
39
- lib/src/imageproc/sparse_image.c
40
- lib/src/imageproc/splat.c
41
29
  tests/benchmark_timing.py
42
30
  tests/conftest.py
43
31
  tests/test_buffer.py
44
32
  tests/test_equivalence.py
33
+ tests/test_typecheck.py
34
+ tests/test_variants.py
45
35
  tools/harvester.py
46
36
  tools/strip_c2py.py