Skip to content

Commit

Permalink
Rename Edge to Link (#2023)
Browse files Browse the repository at this point in the history
*everywhere*

This is automatic rename, and then slowly staging the changes. Main
exceptions found so far:
- UGrid uses edge_dimension and similar names
- Networkx has a Graph edges attribute and methods
- Graphs.jl has an edges method and keywords

@visr The only breaking change are that output arrow tables now have
`link_id` instead of `edge_id`. I don't think there's a way around that.
  • Loading branch information
evetion authored Jan 30, 2025
1 parent 2bdf71c commit 57ad0e1
Show file tree
Hide file tree
Showing 83 changed files with 1,518 additions and 1,498 deletions.
12 changes: 6 additions & 6 deletions core/ext/RibasimMakieExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ function Ribasim.plot_basin_data(model::Model)
f
end

function Ribasim.plot_flow!(model::Model, ax::Axis, edge_metadata::Ribasim.EdgeMetadata)
function Ribasim.plot_flow!(model::Model, ax::Axis, link_metadata::Ribasim.LinkMetadata)
flow_data = DataFrame(Ribasim.flow_table(model))
flow_data = filter(:edge_id => ==(edge_metadata.id), flow_data)
label = "$(edge_metadata.edge[1])$(edge_metadata.edge[2])"
flow_data = filter(:link_id => ==(link_metadata.id), flow_data)
label = "$(link_metadata.link[1])$(link_metadata.link[2])"
scatterlines!(ax, flow_data.time, flow_data.flow_rate; label)
return nothing
end

function Ribasim.plot_flow(model::Model; skip_conservative_out = true)
f = Figure()
ax = Axis(f[1, 1]; xlabel = "time", ylabel = "flow rate [m³s⁻¹]")
for edge_metadata in values(model.integrator.p.graph.edge_data)
for link_metadata in values(model.integrator.p.graph.edge_data)
if skip_conservative_out &&
edge_metadata.edge[1].type in Ribasim.conservative_nodetypes
link_metadata.link[1].type in Ribasim.conservative_nodetypes
continue
end
Ribasim.plot_flow!(model, ax, edge_metadata)
Ribasim.plot_flow!(model, ax, link_metadata)
end
axislegend(ax)
f
Expand Down
6 changes: 3 additions & 3 deletions core/regression_test/regression_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ end

# Testbench for flow.arrow
@test flow.time == flow_bench.time
@test flow.edge_id == flow_bench.edge_id
@test flow.link_id == flow_bench.edge_id
@test flow.from_node_id == flow_bench.from_node_id
@test flow.to_node_id == flow_bench.to_node_id
@test all(q -> abs(q) < 0.01, flow.flow_rate - flow_bench.flow_rate)
Expand Down Expand Up @@ -167,7 +167,7 @@ end

# Testbench for flow.arrow
@test flow.time == flow_bench.time
@test flow.edge_id == flow_bench.edge_id
@test flow.link_id == flow_bench.edge_id
@test flow.from_node_id == flow_bench.from_node_id
@test flow.to_node_id == flow_bench.to_node_id
@test all(q -> abs(q) < 0.01, flow.flow_rate - flow_bench.flow_rate)
Expand Down Expand Up @@ -234,7 +234,7 @@ end

# Testbench for flow.arrow
@test flow.time == flow_bench.time
@test flow.edge_id == flow_bench.edge_id
@test flow.link_id == flow_bench.edge_id
@test flow.from_node_id == flow_bench.from_node_id
@test flow.to_node_id == flow_bench.to_node_id

Expand Down
2 changes: 1 addition & 1 deletion core/src/Ribasim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ using DiffEqCallbacks:
SavedValues,
SavingCallback

# The network defined by the Node and Edge table is converted to a graph internally.
# The network defined by the Node and Link table is converted to a graph internally.
using Graphs:
DiGraph, Edge, edges, inneighbors, nv, outneighbors, induced_subgraph, is_connected
# Convenience functionality built on top of Graphs. Used to store e.g. node and edge metadata
Expand Down
Loading

0 comments on commit 57ad0e1

Please sign in to comment.