Skip to content

test: add property-based roundtrip tests for to_feather/from_feather#4239

Open
TaiSakuma wants to merge 1 commit into
scikit-hep:mainfrom
TaiSakuma:test-to-from-feather-roundtrip
Open

test: add property-based roundtrip tests for to_feather/from_feather#4239
TaiSakuma wants to merge 1 commit into
scikit-hep:mainfrom
TaiSakuma:test-to-from-feather-roundtrip

Conversation

@TaiSakuma

Copy link
Copy Markdown
Member

Adds property-based roundtrip tests for ak.to_feather/ak.from_feather, the fifth member of the family after buffers, numpy (#4215, #4225), parquet (#4218), and arrow (#4231). Arrays are generated with hypothesis-awkward.

Three tests:

  • test_roundtrip — option-free arrays reconstruct exactly (ak.array_equal).
  • test_roundtrip_masked — option-type arrays roundtrip through nullable feather columns; content classes are not compared because from_feather normalizes option layouts.
  • test_roundtrip_stable — one write/read cycle brings the conversion to a fixed point: the roundtrip may lose type information (anonymous single-field records unwrap, a zero-field record loses its length), but converting the reconstruction again produces an identical Arrow table (pyarrow.Table.equals).

Unlike the parquet sibling, the tests perform real file I/O: to_feather passes its destination through os.fsdecode, so an fsspec memory:// path is not accepted. The files go to a module-scoped tmp_path_factory directory (a function-scoped fixture would trip Hypothesis' function_scoped_fixture health check) with a per-thread filename for pytest-run-parallel.

The generation predicates separate two kinds of exclusion, which is also a structure proposal for eventually refactoring the sibling files: feather_compatible and feather_stable encode limits of the table representation itself, while has_issues composes one _has_issue_NNNN function per known issue (#4221, #4222, #4229) so that each released fix deletes exactly one function; #4230 and #4238 are excluded by strategy flags and #4219 by the dtype filter. When all cited issues are fixed, the filters reduce to the two format-limit predicates.

#4238 (union-type arrays produce an invalid feather file; root cause apache/arrow#50623) was found while validating these tests.

Validation: 10,000 examples per test under the nightly profile (~3 min), fixed seeds 1–8, pytest-xdist, and a 20,000-example equivalence check between the decomposed predicates and the originally validated merged predicate.

🤖 Generated with Claude Code

Add three Hypothesis tests in tests/properties/operations/:

- test_roundtrip: option-free arrays reconstruct exactly
- test_roundtrip_masked: option-type arrays roundtrip through nullable
  feather columns, without comparing content classes
- test_roundtrip_stable: one write/read cycle brings the conversion to
  a fixed point, compared as Arrow tables

`to_feather` requires a real filesystem path (its destination goes
through `os.fsdecode`), so unlike the parquet sibling the tests write
to a module-scoped `tmp_path_factory` directory, with a per-thread
filename for pytest-run-parallel.

Generation excludes arrays affected by known issues, one predicate
function per issue so each released fix deletes exactly one function:
scikit-hep#4221, scikit-hep#4222, and scikit-hep#4229 in `has_issues`, scikit-hep#4230 and scikit-hep#4238 via strategy
flags, and scikit-hep#4219 in the dtype filter. The format's own limits live in
`feather_compatible` and `feather_stable`, which are all that remains
when the cited issues are fixed.

Validated with 10,000 examples per test (nightly profile), fixed seeds
1-8, and under pytest-xdist.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions github-actions Bot added the type/test PR title type: test (set automatically) label Jul 23, 2026
@TaiSakuma
TaiSakuma requested a review from ianna July 23, 2026 23:16
TaiSakuma added a commit to TaiSakuma/awkward that referenced this pull request Jul 23, 2026
Split the generation predicates of test_to_from_arrow.py into the
structure introduced by the feather sibling (scikit-hep#4239): `arrow_compatible`
and `table_compatible` hold the permanent limits of the conversion
(mergeable union contents merge on read, an optioned unknown gains an
option, plus the table-wrapping record clauses), while `has_issues`
composes one `_has_issue_NNNN` function per known issue (scikit-hep#4221, scikit-hep#4222,
scikit-hep#4228, scikit-hep#4229) so each released fix deletes exactly one function. The
filters name both parts inline, and the stability test's filter is now
literally `not has_issues(a)`.

No behavioral change: a 40,000-example equivalence check against the
original merged predicates over all four generation domains found no
disagreement.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.03%. Comparing base (802b733) to head (d9a0560).

Additional details and impacted files

@github-actions

Copy link
Copy Markdown

The documentation preview is ready to be viewed at http://preview.awkward-array.org.s3-website.us-east-1.amazonaws.com/PR4239

@ikrommyd

ikrommyd commented Jul 24, 2026

Copy link
Copy Markdown
Member

Just a general comment @TaiSakuma, I'd advise on focusing to property testing for the actual common awkward functions first. It's a lot more useful for the users. I would bet that not a single person has ever used this function. At least I've never seen it or used it myself and there are no instances of ak.to_feather/ak.from_buffer in all of github that are outside of just awkward forks.

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

Labels

type/test PR title type: test (set automatically)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants