Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

22 Commits

Repository files navigation

AxisArrayConversion

StableDevBuild StatusCoverage

AxisArrayConversion

AxisArrayConversion.jl allows converting between AxisArrays.jl like packages.

Supporting more arrays

Conversions between two array types is provided by using the path

MyArray -> NamedTuple -> OtherArray

This has multiple advantages:

  • For N array types, only 2N methods must be implemented.
  • Conversion can be implemented between packages that don't know about each other.

In order to support MyArray, the following must be implemented:

function AxisArrayConversion.namedtuple(arr::MyArray)
...return (axes=..., values=...)
endfunction AxisArrayConversion.from_namedtuple(::Type{MyArray}, nt::NamedTuple)
...= nt.axes
...= nt.values
returnMyArray(...)
end

And now any fancy conversion should work

using MyArrays, OtherArrays
using AxisArrayConversion: to
using Test
ma =MyArrays(...)
oa =to(OtherArray, ma)
@test oa isa OtherArrays.OtherArray
@test ma ==to(MyArray, oa)

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages