ASDF.NDArray (asdf v0.1.0)

Copy Markdown View Source

Turns core/ndarray-1.0.0 and core/ndarray-1.1.0 tags into ASDF.Array.

The block payload is not read. Inline data is already in the tree, so those numbers are the YAML values: an inline float is an Elixir float, not a binary32 bit container.

Summary

Functions

Replaces ndarray tags in tree with %ASDF.Array{} views.

Functions

interpret(tree, blocks, source)

@spec interpret(term(), [ASDF.Block.t()], ASDF.Source.t()) ::
  {:ok, term()} | {:error, ASDF.Error.t()}

Replaces ndarray tags in tree with %ASDF.Array{} views.

tree is a YAML value. blocks is the list from ASDF.Block.scan/4. source is the %ASDF.Source{} later reads use. Only core/ndarray-1.0.0 and core/ndarray-1.1.0 are replaced. Other tags go through ASDF.Registry.fetch/1. The block payload is not read.

Returns {:ok, tree}. A missing block, a bad shape, a bad byte order, or both source and data is {:error, %ASDF.Error{reason: :invalid_ndarray}}. Does not raise.

Examples

iex> {:ok, source} = ASDF.Source.open({:binary, <<>>})
...> ASDF.NDArray.interpret(%{"n" => 1}, [], source)
{:ok, %{"n" => 1}}