Skip to content

Add lazy DATA helpers (only_text docs, as_memmap, read_events) - #39

Open
jahnzh wants to merge 2 commits into
whitews:developfrom
jahnzh:feature/lazy-event-read
Open

Add lazy DATA helpers (only_text docs, as_memmap, read_events)#39
jahnzh wants to merge 2 commits into
whitews:developfrom
jahnzh:feature/lazy-event-read

Conversation

@jahnzh

@jahnzh jahnzh commented Aug 6, 2026

Copy link
Copy Markdown

Summary

  • Document and stabilize only_text=True as the supported metadata probe (README + FlowData docstring); retain DATA offsets / dtype metadata for later lazy access.
  • Add data_byte_range, numpy_dtype(), as_memmap(), and read_events(indices=...) for uniform $DATATYPE=F/D layouts; raise UnsupportedLazyDataError for ASCII, integer, variable bit-width, and in-memory handles without a path.
  • read_events(..., preprocess=True) — default matches as_array() (gain/log/timestep). Shared _apply_preprocessing() keeps lazy and eager paths aligned. Use preprocess=False or as_memmap() for raw stored DATA.
  • ignore_offset_error warning parity on the lazy mmap offset correction path.
  • Unit tests on existing data/fcs_files/ fixtures (little- and big-endian float, integer rejection, variable-bit rejection, preprocess default vs as_array()).

Three-tier lazy access model

API Output
as_memmap() Raw on-disk values, mmap, native dtype
read_events(..., preprocess=False) Raw stored DATA, float64, copied/subset
read_events() / as_array() Preprocessed float64 (default)

Closes / related: #38

Test plan

  • PYTHONPATH=src python3 -m pytest tests/test_lazy_data.py tests/test_flowdata.py -q (30 passed)
  • read_events() default preprocess matches as_array(preprocess=True) on lazy path
  • Review docstring / README wording for only_text + lazy helpers
  • Confirm memmap path does not change existing full-load behaviour

Made with Cursor

jahnzh and others added 2 commits August 6, 2026 15:19
Document only_text as the supported metadata probe, expose DATA byte
range / numpy dtype helpers, and add as_memmap() plus read_events() for
uniform F/D layouts (with clear errors for ASCII and variable bit-widths).

Co-authored-by: Cursor <cursoragent@cursor.com>
Add preprocess=True default to read_events() so lazy subsampling
returns the same gain/log/timestep-corrected values as as_array().
Extract shared _apply_preprocessing() and warn on ignore_offset_error
in the lazy mmap path. Document raw access via preprocess=False or
as_memmap() in README and tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jahnzh
jahnzh marked this pull request as ready for review August 10, 2026 09:36
Copilot AI lite review requested due to automatic review settings August 10, 2026 09:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a supported “metadata-only” (only_text=True) workflow and new lazy DATA access helpers to FlowData, enabling mmap-backed access and indexed row reads for uniform IEEE float FCS layouts while keeping lazy and eager preprocessing consistent.

Changes:

  • Documented and stabilized only_text=True as a metadata probe (README + FlowData docstring) while retaining DATA offsets/metadata for later access.
  • Added lazy DATA helpers: data_byte_range, numpy_dtype(), as_memmap(), read_events(indices=..., preprocess=...), plus shared _apply_preprocessing() to keep behavior aligned with as_array().
  • Added unit tests covering memmap parity, endian handling, preprocessing defaults, and unsupported layouts/handles.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
tests/test_lazy_data.py New tests for lazy/mmap helpers, preprocessing parity, and rejection paths.
src/flowio/flowdata.py Implements DATA byte-range/dtype helpers, memmap + indexed reads, and shared preprocessing.
src/flowio/exceptions.py Adds UnsupportedLazyDataError for unsupported lazy access scenarios.
README.md Documents only_text=True as the metadata probe and introduces lazy DATA access usage.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/flowio/flowdata.py
Comment on lines +713 to +716
return (
self._dataset_offset + self.data_start,
self._dataset_offset + self.data_stop,
)
Comment thread src/flowio/flowdata.py
Comment on lines +862 to +866
if self.events is not None and indices is None:
return self.as_array(preprocess=preprocess)

if self.events is not None:
events_2d = np.reshape(
@codecov

codecov Bot commented Aug 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 37.61468% with 68 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.10%. Comparing base (3880a63) to head (e2ecd6a).

Files with missing lines Patch % Lines
src/flowio/flowdata.py 36.44% 68 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (3880a63) and HEAD (e2ecd6a). Click for more details.

HEAD has 3 uploads less than BASE
Flag BASE (3880a63) HEAD (e2ecd6a)
5 2
Additional details and impacted files
@@             Coverage Diff              @@
##           develop      #39       +/-   ##
============================================
- Coverage    93.56%   83.10%   -10.46%     
============================================
  Files            7        7               
  Lines          497      586       +89     
============================================
+ Hits           465      487       +22     
- Misses          32       99       +67     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants