Skip to content

Commit d8a546d

Browse files
committed
Fix tests
1 parent 10ea80c commit d8a546d

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "BlockSparseArrays"
22
uuid = "2c9a651f-6452-4ace-a6ac-809f4280fbb4"
33
authors = ["ITensor developers <[email protected]> and contributors"]
4-
version = "0.2.9"
4+
version = "0.2.10"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
@@ -11,6 +11,7 @@ DerivableInterfaces = "6c5e35bf-e59e-4898-b73c-732dcc4ba65f"
1111
DiagonalArrays = "74fd4be6-21e2-4f6f-823a-4360d37c7a77"
1212
Dictionaries = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4"
1313
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
14+
GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
1415
GradedUnitRanges = "e2de450a-8a67-46c7-b59c-01d5a3d041c5"
1516
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1617
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"

src/blocksparsearrayinterface/blocksparsearrayinterface.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ using BlockArrays:
1515
blocks,
1616
findblockindex
1717
using DerivableInterfaces: DerivableInterfaces, @interface, DefaultArrayInterface
18+
using GPUArraysCore: @allowscalar
1819
using LinearAlgebra: Adjoint, Transpose
1920
using SparseArraysBase:
2021
AbstractSparseArrayInterface,
@@ -65,9 +66,7 @@ end
6566
@interface ::AbstractBlockSparseArrayInterface function Base.getindex(
6667
a::AbstractArray{<:Any,0}
6768
)
68-
# TODO: Use `Block()[]` once https://github.com/JuliaArrays/BlockArrays.jl/issues/430
69-
# is fixed.
70-
return a[BlockIndex()]
69+
return @allowscalar a[Block()[]]
7170
end
7271

7372
# a[1:2, 1:2]
@@ -158,7 +157,7 @@ end
158157
)
159158
a_b = blocks(a)[]
160159
# `value[]` handles scalars and 0-dimensional arrays.
161-
a_b[] = value[]
160+
@allowscalar a_b[] = value[]
162161
# Set the block, required if it is structurally zero.
163162
blocks(a)[] = a_b
164163
return a
File renamed without changes.

test/basics/test_basics.jl renamed to test/test_basics.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,30 +183,30 @@ arrayts = (Array, JLArray)
183183
@test blocksize(a) == ()
184184
@test blocksizes(a) == fill(())
185185
@test iszero(blockstoredlength(a))
186-
@test iszero(@allowscalar(a[]))
187-
@test iszero(@allowscalar(a[CartesianIndex()]))
186+
@test iszero(a[])
187+
@test iszero([CartesianIndex()])
188188
@test a[Block()] == dev(fill(0))
189-
@test iszero(@allowscalar(a[Block()][]))
190-
@test @allowscalar(a[Block()[]]) == 0
189+
@test iszero(a[Block()][])
190+
@test iszero(a[Block()[]])
191191
@test Array(a) isa Array{elt,0}
192192
@test Array(a) == fill(0)
193193
for b in (
194-
(b = copy(a); @allowscalar b[] = 2; b),
195-
(b = copy(a); @allowscalar b[CartesianIndex()] = 2; b),
196-
(b = copy(a); @allowscalar b[CartesianIndex()] = 2; b),
194+
(b = copy(a); b[] = 2; b),
195+
(b = copy(a); b[CartesianIndex()] = 2; b),
196+
(b = copy(a); b[CartesianIndex()] = 2; b),
197197
# Regression test for https://github.com/ITensor/BlockSparseArrays.jl/issues/27.
198-
(b = copy(a); @allowscalar b[Block()] = dev(fill(2)); b),
198+
(b = copy(a); b[Block()] = dev(fill(2)); b),
199199
)
200200
@test size(b) == ()
201201
@test isone(length(b))
202202
@test blocksize(b) == ()
203203
@test blocksizes(b) == fill(())
204204
@test isone(blockstoredlength(b))
205-
@test @allowscalar(b[]) == 2
206-
@test @allowscalar(b[CartesianIndex()]) == 2
205+
@test b[] == 2
206+
@test b[CartesianIndex()] == 2
207207
@test b[Block()] == dev(fill(2))
208-
@test @allowscalar(b[Block()][]) == 2
209-
@test @allowscalar(b[Block()[]]) == 2
208+
@test b[Block()][] == 2
209+
@test b[Block()[]] == 2
210210
@test Array(b) isa Array{elt,0}
211211
@test Array(b) == fill(2)
212212
end
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)