Skip to content

Writing masked columns with serialize_method="data_mask" has no effect #18704

Open

Description

@mhvk

Description

Writing a table to ecsv, I should be able to have masked sky coordinates have a separate mask column, but this does not work.

Expected behavior

The mask is written as a separate column.

How to Reproduce

# Put your Python code snippet here.
from astropy.table import QTable
from astropy.coordinates import SkyCoord
from astropy.units import Unit as U
from astropy.utils.masked import Masked

qt = QTable()
qt["sc"] = SkyCoord(ra=Masked([1.0, 2.0, 3.0], [True, False, False]),
                    dec=Masked([5.0, 6.0, 7.0], [True, False, False]),
                    unit="hourangle,deg")
qt["q"] = Masked([0.0, 8.0, 9.0], mask=[False, True, False]) << U("km")
qt.write("test.ecsv", serialize_method="data_mask", overwrite=True)

This gives

cat test.ecsv
# %ECSV 1.0
# ---
# datatype:
# - {name: sc.ra, unit: deg, datatype: float64}
# - {name: sc.dec, unit: deg, datatype: float64}
# - {name: q, unit: km, datatype: float64}
# - {name: q.mask, datatype: bool}
# meta: !!omap
# - __serialized_columns__:
#     q:
#       __class__: astropy.units.quantity.Quantity
#       unit: !astropy.units.Unit {unit: km}
#       value: !astropy.table.SerializedColumn
#         __class__: astropy.utils.masked.core.MaskedNDArray
#         data: !astropy.table.SerializedColumn {name: q}
#         mask: !astropy.table.SerializedColumn {name: q.mask}
#     sc:
#       __class__: astropy.coordinates.sky_coordinate.SkyCoord
#       dec: !astropy.table.SerializedColumn
#         __class__: astropy.coordinates.angles.core.Latitude
#         unit: &id001 !astropy.units.Unit {unit: deg}
#         value: !astropy.table.SerializedColumn
#           __class__: astropy.utils.masked.core.MaskedNDArray
#           data: !astropy.table.SerializedColumn {name: sc.dec}
#       frame: icrs
#       ra: !astropy.table.SerializedColumn
#         __class__: astropy.coordinates.angles.core.Longitude
#         unit: *id001
#         value: !astropy.table.SerializedColumn
#           __class__: astropy.utils.masked.core.MaskedNDArray
#           data: !astropy.table.SerializedColumn {name: sc.ra}
#         wrap_angle: !astropy.coordinates.Angle
#           unit: *id001
#           value: 360.0
#       representation_type: spherical
# schema: astropy-2.0
sc.ra sc.dec q q.mask
"" "" 0.0 False
29.999999999999996 6.0 8.0 True
44.99999999999999 7.0 9.0 False

Versions

import astropy
astropy.system_info()
# Paste the result here

Activity

  1. pllim commented on Jul 20, 2026

    @pllim
    Member

    Someone proposed #20094 but it might be AI-generated/assisted. Is it worth enabling CI for?

  2. nomad3 commented on Jul 28, 2026

    @nomad3
    Contributor

    Yes, I believe it is worth enabling full CI. To clarify, this is an AI-assisted contribution: I used OpenAI Codex and Anthropic Claude Code as development and review assistants, with human direction and review throughout. I have reviewed and understand the submitted implementation and tests, take responsibility for the contribution and its licensing compliance, and will engage directly with reviewer questions and feedback.

    The branch has been rebased onto current main without changing either patch. Local validation passed the table, ECSV, and masked-table suites (2,930 passed, 183 skipped, 14 xfailed), the FITS and available HDF5 connector tests (175 passed, 123 skipped), and the full pre-commit suite on the changed files. I added the disclosure and current validation to the PR body and marked the PR ready for review. I would appreciate full CI being enabled when convenient.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions