> using AxisArrays
> v1=AxisArray([1,2,3],[:a,:b,:c])
1-dimensional AxisArray{Int64,1,...} with axes:
:row, [:a, :b, :c]
And data, a 3-element Vector{Int64}:
1
2
3
> v1 + [1,2,3]
3-element Vector{Int64}:
2
4
6
> @which v1 + [1,2,3]
+(A::AbstractArray, B::AbstractArray) in Base at arraymath.jl:6
As you can see, when I call v1 + [1,2,3], the add method worked in v1.value . I thought there must be a + method attaced to Bae.:(+)(v::AxisArray,z::Vector), but when I call @which v1 + [1,2,3], the result show that it derectively call the original Base.+ rather than some custom added method. So I would guess the author of the package add some other more lower function to AxisArray struct.
Here it falls back to + defined on AbstractArray, because AxisArray is subtyped based on AbstractArray as shown below (from AxisArray impl)
struct AxisArray{T,N,D,Ax} <: AbstractArray{T,N}
data::D # D <:AbstractArray, enforced in constructor to avoid dispatch bugs (https://github.com/JuliaLang/julia/issues/6383)
axes::Ax # Ax<:NTuple{N, Axis}, but with specialized Axis{...} types
AxisArray{T,N,D,Ax}(data::AbstractArray{T,N}, axs::Tuple{Vararg{Axis,N}}) where {T,N,D,Ax} = new{T,N,D,Ax}(data, axs)
end
So, it works if you also implement your type to be a subtype of AbstractArray (iff it is feasible in your case…!!)