|
1 | | -using FunctionImplementations: DefaultArrayStyle, Style, style |
2 | | -using SparseArraysBase: AbstractSparseArrayStyle, SparseArrayStyle, sparse_style, |
3 | | - sparsezeros |
| 1 | +using FunctionImplementations: DefaultArrayImplementationStyle, ImplementationStyle, style |
| 2 | +using SparseArraysBase: AbstractSparseArrayImplementationStyle, |
| 3 | + SparseArrayImplementationStyle, sparse_style, sparsezeros |
4 | 4 | using Test: @test, @testset |
5 | 5 |
|
6 | | -module TestSparseStyleUtils |
7 | | - using SparseArraysBase: AbstractSparseArray, AbstractSparseArrayStyle |
| 6 | +module TestSparseImplementationStyleUtils |
| 7 | + using SparseArraysBase: AbstractSparseArray, AbstractSparseArrayImplementationStyle |
8 | 8 | using FunctionImplementations: FunctionImplementations |
9 | | - struct MySparseArrayStyle <: AbstractSparseArrayStyle end |
| 9 | + struct MySparseArrayImplementationStyle <: AbstractSparseArrayImplementationStyle end |
10 | 10 | struct MySparseArray{T, N} <: AbstractSparseArray{T, N} |
11 | 11 | size::NTuple{N, Int} |
12 | 12 | end |
13 | | - FunctionImplementations.Style(::Type{<:MySparseArray}) = MySparseArrayStyle() |
| 13 | + FunctionImplementations.ImplementationStyle(::Type{<:MySparseArray}) = |
| 14 | + MySparseArrayImplementationStyle() |
14 | 15 | end |
15 | 16 |
|
16 | 17 | @testset "Combine Sparse Styles" begin |
17 | | - @test sparse_style ≡ SparseArrayStyle() |
18 | | - @test Style(SparseArrayStyle(), SparseArrayStyle()) ≡ SparseArrayStyle() |
19 | | - @test Style(TestSparseStyleUtils.MySparseArrayStyle(), SparseArrayStyle()) ≡ |
20 | | - SparseArrayStyle() |
21 | | - @test Style(SparseArrayStyle(), TestSparseStyleUtils.MySparseArrayStyle()) ≡ |
22 | | - SparseArrayStyle() |
23 | | - @test style(TestSparseStyleUtils.MySparseArray{Float64, 2}((2, 2))) ≡ |
24 | | - TestSparseStyleUtils.MySparseArrayStyle() |
25 | | - @test style(sparsezeros(2, 2), TestSparseStyleUtils.MySparseArray{Float64, 2}((2, 2))) ≡ |
26 | | - SparseArrayStyle() |
27 | | - |
| 18 | + @test sparse_style ≡ SparseArrayImplementationStyle() |
| 19 | + @test ImplementationStyle(SparseArrayImplementationStyle(), SparseArrayImplementationStyle()) ≡ SparseArrayImplementationStyle() |
| 20 | + @test ImplementationStyle(TestSparseImplementationStyleUtils.MySparseArrayImplementationStyle(), SparseArrayImplementationStyle()) ≡ |
| 21 | + SparseArrayImplementationStyle() |
| 22 | + @test ImplementationStyle(SparseArrayImplementationStyle(), TestSparseImplementationStyleUtils.MySparseArrayImplementationStyle()) ≡ |
| 23 | + SparseArrayImplementationStyle() |
| 24 | + @test style(TestSparseImplementationStyleUtils.MySparseArray{Float64, 2}((2, 2))) ≡ |
| 25 | + TestSparseImplementationStyleUtils.MySparseArrayImplementationStyle() |
| 26 | + @test style(sparsezeros(2, 2), TestSparseImplementationStyleUtils.MySparseArray{Float64, 2}((2, 2))) ≡ |
| 27 | + SparseArrayImplementationStyle() |
28 | 28 | # Regression tests for ambiguity caused by combining AbstractSparseArrayStyle with |
29 | 29 | # DefaultArrayStyle. |
30 | | - @test Style(TestSparseStyleUtils.MySparseArrayStyle(), DefaultArrayStyle()) ≡ |
31 | | - TestSparseStyleUtils.MySparseArrayStyle() |
32 | | - @test style(TestSparseStyleUtils.MySparseArray{Float64, 2}((2, 2)), randn(2, 2)) ≡ |
33 | | - TestSparseStyleUtils.MySparseArrayStyle() |
| 30 | + @test ImplementationStyle( |
| 31 | + TestSparseImplementationStyleUtils.MySparseArrayImplementationStyle(), |
| 32 | + DefaultArrayImplementationStyle(), |
| 33 | + ) ≡ |
| 34 | + TestSparseImplementationStyleUtils.MySparseArrayImplementationStyle() |
| 35 | + @test style(TestSparseImplementationStyleUtils.MySparseArray{Float64, 2}((2, 2)), randn(2, 2)) ≡ |
| 36 | + TestSparseImplementationStyleUtils.MySparseArrayImplementationStyle() |
34 | 37 | end |
0 commit comments