Skip to content

New array element accessor methods#228

Merged
embray merged 8 commits into
asdf-format:mainfrom
embray:issue-227
Jul 13, 2026
Merged

New array element accessor methods#228
embray merged 8 commits into
asdf-format:mainfrom
embray:issue-227

Conversation

@embray

@embray embray commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Description

This resolves #227 by providing a suite of functions (and convenience macros) for accessing single elements of an ndarray safely regardless of word alignment, endianness, or source datatype. It complements the other asdf_ndarray_read_* methods.

Also takes care of UB surrounding word alignment on the general read conversions as well.

Adds support for builds with UBSan enabled (which raised this issue in the first place) and updates the docs accordingly.

Also takes care of the long-standing problem (but for which there was not a written issue) of not shipping certain configured defines in the installed headers (esp. ASDF_LOG_ENABLED).

AI Disclosure

No AI tools used.

embray added 6 commits July 10, 2026 16:15
This currently fails mostly due to a couple very minor issues, but
mainly due to the problem discussed in asdf-formatgh-227
This resolves the long-standing (but undocumented) bug that certain
macros controlling code compiled with libasdf (specifically ASDF_LOG
calls) did not get a value defined for ASDF_LOG_ENABLED, causing log
calls to pass silently.  This now provides another home for
configure-time values that *should* be shipped in the public API.

In particular this was needed to test for float16 support for some of
the new ndarray APIs to be added on this branch.  But it's an issue that
needed resolution in the first place.

asdf-formatgh-227
…ce macros)

This provides a safer element-wise access to ndarrays; add documentation
of its usage and why it should be used over direct pointer casts on the
raw data.

asdf-formatgh-227
asdf/config.h is generated at build time, but is needed for Hawkmoth to
successfully read the headers.  This generates a temporary copy of
config.h for use just in the docbuild in case this condition is
encountered (which it would be, e.g., on RTD)

asdf-formatgh-227
@embray embray added bug Something isn't working enhancement New feature or request labels Jul 13, 2026
@embray
embray merged commit 8d0bfc8 into asdf-format:main Jul 13, 2026
12 checks passed
@embray
embray deleted the issue-227 branch July 13, 2026 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Correct handling of unaligned arrays in reading and writing

1 participant