Skip to content

[doc-sync] docs(pyOpenMS): fix get_data_view() empty return behavior in README - #8879

Merged
timosachsenberg merged 1 commit into
developfrom
doc-sync/fix-pyopenms-readme-view-empty-behavior-7f9192237820232a
Mar 11, 2026
Merged

timosachsenberg merged 1 commit into
developfrom
doc-sync/fix-pyopenms-readme-view-empty-behavior-7f9192237820232a

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Summary

This PR fixes an inaccuracy in src/pyOpenMS/README.md introduced by #8857 (the zero-copy API naming unification commit).

Source files that triggered this review

  • src/pyOpenMS/bindings/bind_kernel.cpp — get_data_view() implementation for FloatDataArray / IntegerDataArray
  • src/pyOpenMS/pyopenms/addons/deprecated_mv_aliases.py — _mv → _view deprecation convention
  • src/pyOpenMS/tests/unittests/test_zerocopy_conventions.py — convention tests

Documentation file updated

  • src/pyOpenMS/README.md — one-line fix in the "Adding Pythonic Methods" section

Change made and why

Before:

- `get_data_view()`: Return zero-copy writable view (None if empty, document lifetime). Deprecated alias: `get_data_mv()`
```

**After:**
```
- `get_data_view()`: Return zero-copy writable view (empty ndarray if empty, document lifetime). Deprecated alias: `get_data_mv()`

Why: The _view-suffix methods return an empty ndarray when the container is empty, not None. This is:

  1. Explicitly documented in the C++ binding docstring: "Returns a zero-copy writable view of the data as numpy array (empty array if empty)"
  2. Verified by test_zerocopy_conventions.py which asserts isinstance(arr, np.ndarray) and len(arr) == 0 (not None)
  3. Consistent with the naming convention comment in that test file: _view = typed zero-copy column view, returns empty ndarray(T) if empty

The incorrect "None if empty" description was accidentally copied into the new get_data_view() entry during the rename in #8857.

Generated by Documentation Sync Agent · ◷

The _view zero-copy methods return an empty ndarray when the container
is empty, not None. This was incorrectly documented as 'None if empty'
after the zero-copy API naming unification in #8857.

The actual implementation in bind_kernel.cpp returns an empty ndarray
with shape (0,), consistent with its docstring 'empty array if empty'.
This is confirmed by test_zerocopy_conventions.py which asserts
isinstance(arr, np.ndarray) and len(arr) == 0.

Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant