Packages

Read and write Advanced Scientific Data Format (ASDF) 1.5.0 files from Elixir.

Current section

Files

Jump to
asdf docs python-asdf-gaps.md
Raw

docs/python-asdf-gaps.md

# Gaps with Python asdf

Compared on 4 December 2026. This library is 0.1.0 and targets ASDF standard 1.5.0. The reference library is [asdf 6.0.0](https://github.com/asdf-format/asdf) (released 19 October 2026), which writes core schemas 1.6.0 from asdf-standard 1.5.0. The package version and the core-schemas version are different numbers.

Both libraries use file format 1.0.0 and one YAML 1.1 document. A default Python file carries `#ASDF_STANDARD 1.6.0`. This library writes `1.5.0` and still opens a `1.0.z` file whose comment says `1.6.0`. The comment does not add 1.6.0 behavior. core-1.6.0 lists `ndarray-1.1.0` and omits `ndarray-1.0.0`. This library emits `ndarray-1.0.0` for every dtype except float16, which uses `ndarray-1.1.0`.

The Python round trip and both CI rows in [Compatibility](compatibility.md) are **not run**. The tables below are a reading of both codebases. They are not a measured interop result.

## What stops a file Python wrote

An unknown compression label and a non-finite YAML scalar abort `ASDF.open/1` before the tree is usable. The array rows fail later, when the payload is decoded.

| Capability | Python asdf 6.0.0 | This library | Effect |
| --- | --- | --- | --- |
| `bzp2` blocks | Built in | `:unsupported_compression` | Open fails |
| `lz4` and any other compression label | `lz4` is an optional extra; other codecs are extensions | `:unknown_compression` | Open fails when the file uses that label |
| YAML `.inf` and `.nan` | Accepted | `:unsupported_float` | Open fails |
| Streamed shape `['*', …]` | One uncompressed last block, `source: -1` | Shape must be a list of non-negative integers | Decode fails |
| Exploded ndarray (a sibling `.asdf` file) | Opens the sibling and reads block 0 | The URI is stored; decode returns `:external_disabled` | Decode fails |
| `ucs4` arrays | Decoded as Unicode | The datatype parses; the decoder returns `:invalid_ndarray` | Decode fails |
| Negative strides | Read with NumPy order `"A"` | `:unsupported_stride` | Decode fails |

A default Python write is uncompressed, so `bzp2` and `lz4` are absent from that file. They are present in any file that asked for them. `bzp2` ships with every asdf 6.0.0 install. `lz4` does not.

`:permissive` does not recover these rows. Its two recoveries are a duplicate YAML key and a block index that does not match the forward scan.

## What a written file is missing

An ordinary asdf 6.0.0 file is `#ASDF 1.0.0`, `#ASDF_STANDARD 1.6.0`, YAML 1.1, root tag `asdf-1.1.0`, history with `asdf_library` and extension metadata, uncompressed blocks, an MD5 of the stored bytes, a block index, and `ndarray-1.1.0` for the arrays in the 1.6.0 examples. Python 4.0.0's notes say older standards stay readable. That claim was not retested here.

| Contents of a default 6.0.0 file | Python asdf 6.0.0 | `ASDF.write/3` |
| --- | --- | --- |
| `#ASDF 1.0.0`, `%YAML 1.1`, `%TAG ! tag:stsci.edu:asdf/` | Written | Written |
| Root `asdf-1.1.0` for a map | Written | A bare map is wrapped with that tag |
| Default compression none, zlib available | `"input"` by default, zlib on request | `:none` by default, `:zlib` on request |
| Checksum and block index | Written; the index is omitted for a streamed file | Written when any block exists |
| `#ASDF_STANDARD 1.6.0` | Default | Hardcoded `1.5.0` |
| `history`, `asdf_library`, extension metadata | Written | Omitted. Whether the schema requires them was not checked |
| ndarray tag | 1.6.0 examples use `ndarray-1.1.0` | `ndarray-1.0.0`, except float16 |
| Non-C view | Saved as the view since 6.0.0 | Packed to C order. Strides and offset are dropped |
| Streamed block | Supported | The flag is never set |
| Structured, `ucs4`, and complex binary samples | Written | `:unsupported_write` |
| `bzp2` and `lz4` | Writable (`lz4` needs the extra) | No writer clause |
| Anchors for a recursive tree | Emitted | No anchor or alias emitter |
| Exploded sibling files | One file per block | A relative path may be recorded. The sibling file is not created |
| Schema check on write | Documented since 4.0.0 | `write/3` does not validate |
| Integer and boolean keys | Legal from core schemas 1.6.0 | `:invalid_key` unless every key is a binary |
| `.inf` and `.nan` | Representable | `:unsupported_float` |

## Partial types

These open, and the value is a narrower Elixir term than the Python object.

| Capability | Python asdf 6.0.0 | This library |
| --- | --- | --- |
| `ndarray-1.0.0` and `ndarray-1.1.0` | `numpy.ndarray` | `%ASDF.Array{}`. Payloads stay unread until `to_list`, `slice`, or `stream` |
| Integer, float64, and ascii arrays | NumPy values | Exact integers, Elixir floats, ascii binaries |
| float16 and float32 | NumPy values, including non-finite | `%ASDF.Float16{}` and `%ASDF.Float32{}` until `widen: true`, which raises on infinity and NaN |
| complex64 and complex128 arrays | NumPy complex | `%ASDF.Complex{}`. complex64 keeps binary32 bits until widen |
| `complex-1.0.0` scalar, `integer-1.1.0` | Python `complex`, `IntegerType` | `%ASDF.Tagged{}` |
| software, history, extension metadata | Small records | `%ASDF.Tagged{}`. Several of the schemas are vendored |
| Structured dtype | A list of fields | Read as maps in field order. There is no struct write clause |
| Positive strides that are not C order | Byte strides | `to_list` gathers them. `slice` returns `:unsupported_slice` |
| ndarray schema | Validated, with `ndim` and `datatype` checks | `ndarray`, `integer`, and `datatype` schemas are skipped as `:cyclic_ref` |
| Tag handlers | `Converter` and `ManifestExtension`, on read and write | `ASDF.Registry` is empty, read-side, and does not cover the two ndarray tags |
| `ndarray-1.2.0` | Registered. Active when core schemas 1.7.0 are enabled | Stays tagged. A default 6.0.0 process does not write it |

## Already the same

File format `1.0.0` for a file this library writes, and any `1.0.z` patch on read. One YAML 1.1 document ended by `...`. The root tag `tag:stsci.edu:asdf/core/asdf-1.1.0` for a bare map. Uncompressed blocks and zlib. An MD5 of the stored bytes and a block index on a non-streamed file. Block payloads left unread at open (`lazy_load` defaults to true in Python; this library reads headers only). Unknown tags kept as tagged nodes when validation is off. Both libraries default that validation to off. Neither memory-maps by default.

Units, time, FITS, coordinates, transforms, and GWCS are outside the asdf package. They ship in asdf-astropy and gwcs. Without those packages, Python keeps the tagged YAML and warns. This library already does that for every tag it does not decode. ASDF-in-FITS was removed from asdf in 3.0.0.

## Stricter on purpose

These stay. They reject inputs the Python defaults accept, and they are checks rather than missing features.

| Check | Python asdf 6.0.0 | This library |
| --- | --- | --- |
| MD5 | Written by default. Open skips the check unless asked | Checked when the payload is read and any checksum byte is set |
| Block index | A bad index warns and the reader scans | `:strict` requires the offset list. `:permissive` keeps the scan and warns |
| bool8 | A NumPy bool | A byte other than 0 or 1 is `:invalid_ndarray` |
| YAML 1.1 words `yes`, `on`, `null`, `010` | The emitter was not compared | Double-quoted, so they stay strings |
| Size caps | No matching cap was recorded | `ASDF.Limits`. A declared block above `max_block_bytes` is `:decompression_bomb` before inflate |

## Tooling

`asdftool` provides `info`, `diff`, `edit`, `explode`, `implode`, `search`, `validate`, `tags`, and `extensions`. `mix asdf.inspect` prints the format version, the standard version, the top-level keys, and each block's compression and sizes. It does not decode payloads. In-place update, search, copy, and history editing have no counterparts here. Opening an `http` or `https` URI needs the optional `fsspec` extra in Python. This library stores the URI and does not fetch it.

## Not measured

- `ASDF.PythonOracleTest` checks three scalar keys when asdf **exactly** 6.0.0 imports. `python3 -c "import asdf"` failed on 30 November 2026 and was not repeated. The test never looks at a block, a dtype, a 1.6.0 comment, or a history entry.
- The Linux and macOS CI rows in the compatibility matrix have workflow files and no recorded run from this tree.
- The core-1.5.0 manifest was not line-checked for `ndarray-1.0.0`, `ndarray-1.1.0`, and `integer-1.1.0`.
- Whether `asdf-1.1.0` requires `history` was not checked.
- Python's duplicate-key behavior and its handling of YAML merge keys were not recorded.
- Byte-identical zlib output was not compared.

## Roadmap

0.1.0 is the current release. Each version below is one delivery. The same list is on the landing page. The checks in [Stricter on purpose](#stricter-on-purpose) stay in every release.

| Release | Delivery | Done when |
| --- | --- | --- |
| 0.2.0 | Ordinary files round-trip with asdf 6.0.0 | A written file and an uncompressed default Python file open in the other library. The written file uses one manifest: the standard comment, ndarray tags including float16, and integer tags agree, and `history` and `asdf_library` are written when that schema requires them. asdf 6.0.0 reads back a map plus C-contiguous int, float64, float32, and float16 arrays. The Python file carries core schemas 1.6.0, history, a checksum, and a block index; the numeric block decodes and history stays `%ASDF.Tagged{}`. YAML `.inf` and `.nan`, and non-finite float16 and float32 payloads, open as an explicit term. Finite float16 and float32 stay bit containers, and `widen: true` still raises on a non-finite value. The oracle runs. |
| 0.3.0 | `bzp2` and `lz4` blocks | A `bzp2` block round-trips. An `lz4` block round-trips when the codec is available. Any other compression label remains an error. |
| 0.4.0 | String and structured columns | `ucs4` and a structured dtype round-trip. |
| 0.5.0 | Strided arrays | A negative stride round-trips. `ASDF.Array.slice/2` accepts an array that is not C order. |
| 0.6.0 | Streamed blocks | A streamed shape `*` round-trips: one uncompressed last block, and no block index. |
| 0.7.0 | External blocks | An external block is written as a sibling file under `external_root` and opened on read. A path with `..`, a leading `/`, or a `://` URI remains rejected. |
| 0.8.0 | Complex binary samples | complex64 and complex128 arrays round-trip as binary blocks. |
| 0.9.0 | Cyclic trees | A cyclic mapping round-trips through anchors and aliases. |
| 0.10.0 | Integer and boolean keys | Integer and boolean mapping keys round-trip. |
| 0.11.0 | Validated writes | `ASDF.write/3` validates the tree before it returns, including the ndarray schemas that 0.1.0 skips. |

Diff, edit, explode, implode, and search are outside this series. So are units, time, coordinates, FITS, transforms, and GWCS. asdf 6.0.0 keeps those in asdf-astropy, gwcs, and `asdftool`.