Skip to content

Commit 41823a0

Browse files
authored
specialize zero and fill! (#240)
* specialize zero and fill! * version bump to v1.9.0
1 parent 481220f commit 41823a0

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

Project.toml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "OffsetArrays"
22
uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
3-
version = "1.8.0"
3+
version = "1.9.0"
44

55
[deps]
66
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
@@ -9,6 +9,7 @@ Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
99
Adapt = "2, 3"
1010
Aqua = "0.5"
1111
CatIndices = "0.2"
12+
DistributedArrays = "0.6"
1213
Documenter = "0.26"
1314
EllipsisNotation = "1"
1415
FillArrays = "0.11"
@@ -19,6 +20,7 @@ julia = "0.7, 1"
1920
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
2021
CatIndices = "aafaddc9-749c-510e-ac4f-586e18779b91"
2122
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
23+
DistributedArrays = "aaf54ef3-cdf8-58ed-94cc-d582ad619b94"
2224
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
2325
EllipsisNotation = "da5c29d0-fa7d-589e-88eb-ea29b0a81949"
2426
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
@@ -27,4 +29,4 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
2729
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2830

2931
[targets]
30-
test = ["Aqua", "CatIndices", "DelimitedFiles", "Documenter", "Test", "LinearAlgebra", "EllipsisNotation", "StaticArrays", "FillArrays"]
32+
test = ["Aqua", "CatIndices", "DistributedArrays", "DelimitedFiles", "Documenter", "Test", "LinearAlgebra", "EllipsisNotation", "StaticArrays", "FillArrays"]

src/OffsetArrays.jl

+3
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,9 @@ Base.trues(inds::NTuple{N, Union{Integer, AbstractUnitRange}}) where {N} =
375375
Base.falses(inds::NTuple{N, Union{Integer, AbstractUnitRange}}) where {N} =
376376
fill!(similar(BitArray, inds), false)
377377

378+
Base.zero(A::OffsetArray) = parent_call(zero, A)
379+
Base.fill!(A::OffsetArray, x) = parent_call(Ap -> fill!(Ap, x), A)
380+
378381
## Indexing
379382

380383
# Note this gets the index of the parent *array*, not the index of the parent *range*

test/runtests.jl

+13
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ using EllipsisNotation
99
using Adapt
1010
using StaticArrays
1111
using FillArrays
12+
using DistributedArrays
1213

1314
DocMeta.setdocmeta!(OffsetArrays, :DocTestSetup, :(using OffsetArrays); recursive=true)
1415

@@ -2037,6 +2038,18 @@ end
20372038
B = fill(5, 3, -1:1)
20382039
@test axes(B) == (1:3,-1:1)
20392040
@test all(B.==5)
2041+
2042+
@testset "fill!" begin
2043+
D = dzeros((2,2))
2044+
DO = OffsetArray(D, 2, 2)
2045+
fill!(DO, 1)
2046+
@test all(isequal(1), DO)
2047+
@test all(iszero, zero(DO))
2048+
2049+
S = SVector{2,Int}(1,1)
2050+
SO = OffsetVector(S, -1)
2051+
@test zero(SO) isa typeof(SO)
2052+
end
20402053
end
20412054

20422055
@testset "broadcasting" begin

0 commit comments

Comments
 (0)