Skip to content

Commit 30857e8

Browse files
authored
Define interface for Broadcast.DefaultArrayStyle (#15)
1 parent a2c1cc5 commit 30857e8

File tree

5 files changed

+8
-5
lines changed

5 files changed

+8
-5
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DerivableInterfaces"
22
uuid = "6c5e35bf-e59e-4898-b73c-732dcc4ba65f"
33
authors = ["ITensor developers <[email protected]> and contributors"]
4-
version = "0.3.9"
4+
version = "0.3.10"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

src/abstractarrayinterface.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# TODO: Add `ndims` type parameter.
22
abstract type AbstractArrayInterface <: AbstractInterface end
33

4-
# TODO: Define as `DefaultArrayInterface()`.
54
function interface(::Type{<:Broadcast.AbstractArrayStyle})
6-
return error("Not defined.")
5+
return DefaultArrayInterface()
76
end
87

98
function interface(::Type{<:Broadcast.Broadcasted{<:Style}}) where {Style}
File renamed without changes.
File renamed without changes.

test/basics/test_defaultarrayinterface.jl renamed to test/test_defaultarrayinterface.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using Test: @testset, @test, @inferred
2-
using DerivableInterfaces: @interface, DefaultArrayInterface
1+
using Test: @inferred, @testset, @test
2+
using DerivableInterfaces: @interface, DefaultArrayInterface, interface
33

44
# function wrappers to test type-stability
55
_getindex(A, i...) = @interface DefaultArrayInterface() A[i...]
@@ -30,3 +30,7 @@ end
3030
a = @inferred _mapreduce(Returns(2), +, A)
3131
@test a == mapreduce(Returns(2), +, A)
3232
end
33+
34+
@testset "Broadcast.DefaultArrayStyle" begin
35+
@test interface(Broadcast.DefaultArrayStyle) == DefaultArrayInterface()
36+
end

0 commit comments

Comments
 (0)