Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Fixed `Symlog10` to work correctly with lower or upper thresholds smaller than 1, and adds a `linscale` argument [#5279](https://github.com/MakieOrg/Makie.jl/pull/5279)
- Fixed `xlims!`/`ylims!` not fully propagating to linked axis [#5239](https://github.com/MakieOrg/Makie.jl/pull/5239)
- Added support for plotting units with DynamicQuantities.jl [#5280](https://github.com/MakieOrg/Makie.jl/pull/5280)
- Adjusted compute nodes to keep unspecialized types when transitioning from one graph to another [#5302](https://github.com/MakieOrg/Makie.jl/pull/5302)

## [0.24.6] - 2025-08-19

Expand Down
24 changes: 24 additions & 0 deletions ComputePipeline/src/ComputePipeline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,30 @@

compute_identity(inputs, changed, cached) = values(inputs)

function TypedEdge(edge::ComputeEdge, f::typeof(compute_identity), inputs)
if length(inputs) != length(edge.outputs)
error("A `compute_identity` callback requires the length of inputs and outputs to match.")
end

# use input refs as output refs so we don't even need to evaluate the callback
for i in eachindex(values(inputs))
edge.outputs[i].value = inputs[i]
edge.outputs[i].dirty = true
end

return TypedEdge(f, inputs, edge.inputs_dirty, inputs, edge.outputs)
end

function resolve!(edge::TypedEdge{IT, OT, typeof(compute_identity)}) where {IT, OT}
# outputs are identical to inputs, so just copy the input state. To be safe
# don't overwrite any `dirty = true` state with false (maybe a problem if
# the input gets resolved?)
for i in eachindex(edge.inputs_dirty)
edge.output_nodes[i].dirty |= edge.inputs_dirty[i]
end
return
end

"""
add_input!([callback], compute_graph, name::Symbol, node::Computed)

Expand Down Expand Up @@ -997,7 +1021,7 @@

Inputs can be Symbols referring to compute nodes in `compute_graph`, or compute
nodes from any graph. These can also be mixed. Outputs are always Symbols naming
the new nodes generated by this functon.

Check failure on line 1024 in ComputePipeline/src/ComputePipeline.jl

View workflow job for this annotation

GitHub Actions / check

functon ==> function

The callback function `f` will be called with the values of the inputs as arguments.
If the output is a `::Symbol`, the function is expected to return a value, otherwise
Expand Down
44 changes: 44 additions & 0 deletions ComputePipeline/test/unit_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -799,3 +799,47 @@ end
e3 = graph2.merged3.parent
@test e3.inputs == [graph1.a1, graph2.a2]
end

@testset "compute_identity" begin
graph1 = ComputeGraph()
add_input!(graph1, :a1, Ref{Any}(1))
map!(x -> Ref{Any}(x), graph1, :a1, :b1)

graph2 = ComputeGraph()
add_input!(graph2, :b1, graph1.b1)
graph2.b1[]
@test graph2.b1.value isa Ref{Any}

edge = graph2.b1.parent
@test edge.callback == ComputePipeline.compute_identity
@test length(edge.inputs) == length(edge.outputs)
for (in, out) in zip(edge.inputs, edge.outputs)
@test in.value === out.value
@test !ComputePipeline.isdirty(in)
@test !ComputePipeline.isdirty(out)
end

update!(graph1, a1 = 5.0)

for (in, out) in zip(edge.inputs, edge.outputs)
@test in.value === out.value
@test ComputePipeline.isdirty(in)
@test ComputePipeline.isdirty(out)
end

graph1.b1[]

for (in, out) in zip(edge.inputs, edge.outputs)
@test in.value === out.value
@test !ComputePipeline.isdirty(in)
@test ComputePipeline.isdirty(out)
end

graph2.b1[]

for (in, out) in zip(edge.inputs, edge.outputs)
@test in.value === out.value
@test !ComputePipeline.isdirty(in)
@test !ComputePipeline.isdirty(out)
end
end
Loading