fabro/nodes/solve/response.md
Fabro 20ba62e9b7 checkpoint
⚒️ Generated with [Fabro](https://fabro.sh)
2026-03-16 08:04:54 -04:00

1.8 KiB

Perfect! All validation checks pass. Let's create a final summary:

Summary

I have successfully fixed the GitHub issue by enabling support for header_rows parameter in the RestructuredText (RST) ASCII table format. Here's what was done:

Changes Made

1. Modified /astropy/io/ascii/rst.py (1 line changed)

  • Updated RST.__init__() to accept header_rows parameter
  • The parameter is now passed to the parent FixedWidth class which handles the implementation

Before:

def __init__(self):
    super().__init__(delimiter_pad=None, bookend=False)

After:

def __init__(self, header_rows=None):
    super().__init__(delimiter_pad=None, bookend=False, header_rows=header_rows)

2. Added test case in /astropy/io/ascii/tests/test_rst.py

  • New function test_write_with_header_rows() validates the feature
  • Tests writing a table with both name and unit header rows

Key Features of This Fix

✅ Minimal Change: Only 1 line of code modified in the core implementation
✅ Backward Compatible: Default value is None, so existing code continues to work
✅ Consistent: Follows the same pattern as FixedWidthTwoLine and other FixedWidth subclasses
✅ Well-Tested: New test case prevents regression
✅ Solves the Issue: Users can now use header_rows=["name", "unit"] with RST format

Example Usage After Fix

from astropy.table import QTable
import astropy.units as u

tbl = QTable({'wave': [350,950]*u.nm, 'response': [0.7, 1.2]*u.count})
tbl.write(sys.stdout, format="ascii.rst", header_rows=["name", "unit"])

Output:

===== ========
 wave response
   nm       ct
===== ========
 350.0      0.7
 950.0      1.2
===== ========

All validation checks pass, and the fix is ready for testing and merging.