From 30e7e434c7257c3a705df40d3e42e072958e46e5 Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Sat, 25 May 2024 12:37:48 -0700 Subject: [PATCH 1/2] Initialize uninitialized BigFloat array --- Project.toml | 2 +- src/MaybeInplace.jl | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index a8d3720..2b3b61b 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "MaybeInplace" uuid = "bb5d69b7-63fc-4a16-80bd-7e42200c7bdb" authors = ["Avik Pal and contributors"] -version = "0.1.2" +version = "0.1.3" [deps] ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" diff --git a/src/MaybeInplace.jl b/src/MaybeInplace.jl index f443a53..30b6397 100644 --- a/src/MaybeInplace.jl +++ b/src/MaybeInplace.jl @@ -290,6 +290,11 @@ used by `@bangbang` to determine if an array can be setindex-ed or not. @inline __similar(::CannotSetindex, x) = x @inline __similar(::CanSetindex, x) = similar(x) +@inline function __similar(::CanSetindex, x::AbstractArray{<:BigFloat}) + y = similar(x) + fill!(y, zero(eltype(y))) + return y +end const OP_MAPPING = Dict{Symbol, Function}(:copyto! => __copyto!!, :.-= => __sub!!, :.+= => __add!!, :.*= => __mul!!, :./= => __div!!, :copy => __copy) From b6487c7eff29ff53461d12d3809e7bb0512019eb Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Sat, 25 May 2024 12:39:50 -0700 Subject: [PATCH 2/2] Add some tests --- .github/workflows/CI.yml | 1 - .github/workflows/Downstream.yml | 3 +++ test/basictests.jl | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 83deee5..a0ccefe 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -20,7 +20,6 @@ jobs: matrix: version: - '1' - - '~1.11.0-0' os: - ubuntu-latest - macOS-latest diff --git a/.github/workflows/Downstream.yml b/.github/workflows/Downstream.yml index bd8372f..fb65210 100644 --- a/.github/workflows/Downstream.yml +++ b/.github/workflows/Downstream.yml @@ -48,6 +48,9 @@ jobs: @info "Not compatible with this release. No problem." exception=err exit(0) # Exit immediately, as a success end + env: + RETESTITEMS_NWORKERS: 4 + RETESTITEMS_NWORKER_THREADS: 2 - uses: julia-actions/julia-processcoverage@v1 - uses: codecov/codecov-action@v3 with: diff --git a/test/basictests.jl b/test/basictests.jl index 5a61f1b..7bd84e6 100644 --- a/test/basictests.jl +++ b/test/basictests.jl @@ -24,6 +24,11 @@ function matmul!!(y, x, z) return y end +function get_similar(x) + @bb z = similar(x) + return z +end + @testset "copyto!" begin x = [1.0, 1.0] y = [0.0, 0.0] @@ -88,3 +93,15 @@ end @test matmul!!(y, x, z) == @SVector[2.0, 2.0] @test y == @SVector[0.0, 0.0] end + +@testset "similar" begin + x = [1.0, 1.0] + z = get_similar(x) + + @test_nowarn z[1] + + x = BigFloat[1.0, 1.0] + z = get_similar(x) + + @test_nowarn z[1] # Without correct similar this would throw UndefRefError +end