JuliaDiff / JuliaDiff/ChainRulesTestUtils.jl
define `rand_tangent` for `Dict`s
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 50
- Forks
- 18
- PR merge metrics
- No merged PRs in 30d
Description
Currently it hits the fallback and errors:
julia> FiniteDifferences.rand_tangent(Dict("a"=>1))
ERROR: UndefRefError: access to undefined reference
Stacktrace:
[1] getindex
@ ./array.jl:801 [inlined]
[2] _broadcast_getindex
@ ./broadcast.jl:614 [inlined]
[3] _getindex
@ ./broadcast.jl:645 [inlined]
[4] _getindex
@ ./broadcast.jl:644 [inlined]
[5] _broadcast_getindex
@ ./broadcast.jl:620 [inlined]
[6] getindex
@ ./broadcast.jl:575 [inlined]
[7] macro expansion
@ ./broadcast.jl:984 [inlined]
[8] macro expansion
@ ./simdloop.jl:77 [inlined]
[9] copyto!
@ ./broadcast.jl:983 [inlined]
[10] copyto!
@ ./broadcast.jl:936 [inlined]
[11] copy
@ ./broadcast.jl:908 [inlined]
[12] materialize
@ ./broadcast.jl:883 [inlined]
[13] rand_tangent(rng::Random._GLOBAL_RNG, x::Vector{String})
@ FiniteDifferences ~/JuliaEnvs/test/alex/dev/FiniteDifferences/src/rand_tangent.jl:33
[14] (::FiniteDifferences.var"#3#5"{Random._GLOBAL_RNG, Dict{String, Int64}})(field_name::Symbol)
@ FiniteDifferences ~/JuliaEnvs/test/alex/dev/FiniteDifferences/src/rand_tangent.jl:52
[15] map (repeats 2 times)
@ ./tuple.jl:216 [inlined]
[16] rand_tangent(rng::Random._GLOBAL_RNG, x::Dict{String, Int64})
@ FiniteDifferences ~/JuliaEnvs/test/alex/dev/FiniteDifferences/src/rand_tangent.jl:51
[17] rand_tangent(x::Dict{String, Int64})
@ FiniteDifferences ~/JuliaEnvs/test/alex/dev/FiniteDifferences/src/rand_tangent.jl:8
[18] top-level scope
@ REPL[82]:1
we probably just need to write a dispatch of rand_tangent for Dicts, but it's kind of annoying because the keys can be different types and one can't map over dicts.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/rand_tangent.jl, especially the rand_tangent methods shown in the stack trace, and reproduce the Dict example from the issue. Define Dict support without relying on mapping over the dictionary; done means rand_tangent(Dict("a" => 1)) no longer reaches the fallback error and handles dictionaries whose keys have different types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100