Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ the ASDF tree, as well as extract block data. Inline comments provide further e
// Get just a raw pointer to the ndarray data block (if uncompressed).
// Optionally returns the size in bytes as well
size_t size = 0;
const void *data = asdf_ndarray_data_raw(ndarray, &size);
const void *data = asdf_ndarray_data(ndarray, &size);

if (data == NULL) {
fprintf(stderr, "error reading ndarray data\n");
Expand Down
3 changes: 3 additions & 0 deletions changes/+ndarray-data.general
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
`asdf_ndarray_data_raw()` is renamed to just `asdf_ndarray_data()`;
the former still exists as well but returns raw compressed data in the case of
compressed arrays.
2 changes: 1 addition & 1 deletion changes/62.feature
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Support for inline ndarray data: inline data is parsed when reading the ndarray data (e.g. with `asdf_ndarray_data_raw`) and can also be set to be written inline with `asdf_ndarray_storage_set(ndarray, ASDF_ARRAY_STORAGE_INLINE)`.
Support for inline ndarray data: inline data is parsed when reading the ndarray data (e.g. with `asdf_ndarray_data`) and can also be set to be written inline with `asdf_ndarray_storage_set(ndarray, ASDF_ARRAY_STORAGE_INLINE)`.
1 change: 1 addition & 0 deletions changes/94.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
New ``asdf dd`` command in the command-line interface.
23 changes: 22 additions & 1 deletion include/asdf/core/ndarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,27 @@ ASDF_DECLARE_EXTENSION(ndarray, asdf_ndarray_t);


/** ndarray methods */

/**
* Return a pointer to the ndarray data
*
* ..todo::
*
* Finish documenting me.
*/
ASDF_EXPORT const void *asdf_ndarray_data(asdf_ndarray_t *ndarray, size_t *size);


/**
* Return a pointer to the raw (compressed, in the case of compressed arrays) ndarray
* data
*
* On non-compressed arrays this is equivalent to `asdf_ndarray_data`.
*
* ..todo::
*
* Finish documenting me.
*/
ASDF_EXPORT const void *asdf_ndarray_data_raw(asdf_ndarray_t *ndarray, size_t *size);

/**
Expand Down Expand Up @@ -287,7 +308,7 @@ ASDF_EXPORT void asdf_ndarray_storage_set(asdf_ndarray_t *ndarray, asdf_array_st
* the binary block underlying the array, if any. This will be `NULL`, for
* example, if the ndarray used inline data.
*/
ASDF_EXPORT const asdf_block_t *asdf_ndarray_block(asdf_ndarray_t *ndarray);
ASDF_EXPORT asdf_block_t *asdf_ndarray_block(asdf_ndarray_t *ndarray);


/**
Expand Down
17 changes: 15 additions & 2 deletions src/core/ndarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static asdf_ndarray_internal_t *asdf_ndarray_internal(asdf_ndarray_t *ndarray, b
}


const asdf_block_t *asdf_ndarray_block(asdf_ndarray_t *ndarray) {
asdf_block_t *asdf_ndarray_block(asdf_ndarray_t *ndarray) {
if (!ndarray || !ndarray->internal)
return NULL;

Expand Down Expand Up @@ -1263,7 +1263,7 @@ ASDF_REGISTER_EXTENSION(


/* ndarray methods */
const void *asdf_ndarray_data_raw(asdf_ndarray_t *ndarray, size_t *size) {
const void *asdf_ndarray_data_impl(asdf_ndarray_t *ndarray, size_t *size, bool raw) {
if (!ndarray || !ndarray->internal)
return NULL;

Expand Down Expand Up @@ -1301,10 +1301,23 @@ const void *asdf_ndarray_data_raw(asdf_ndarray_t *ndarray, size_t *size) {
ndarray->internal->block = block;
}

if (raw)
return asdf_block_data_raw(ndarray->internal->block, size);

return asdf_block_data(ndarray->internal->block, size);
}


const void *asdf_ndarray_data_raw(asdf_ndarray_t *ndarray, size_t *size) {
return asdf_ndarray_data_impl(ndarray, size, true);
}


const void *asdf_ndarray_data(asdf_ndarray_t *ndarray, size_t *size) {
return asdf_ndarray_data_impl(ndarray, size, false);
}


uint64_t asdf_ndarray_size(const asdf_ndarray_t *ndarray) {
if (UNLIKELY(!ndarray || ndarray->ndim == 0))
return 0;
Expand Down
Loading
Loading