Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in PartitionEdge with mixed vertex types, generalize partitioned_vertices to AbstractGraph #46

Merged
merged 2 commits into from
Jan 23, 2024

Conversation

JoeyT1994
Copy link
Contributor

@JoeyT1994 JoeyT1994 commented Jan 23, 2024

This is a quick PR to fix a bug and make a few small minor changes:

  1. A bug was fixed in the definition of PartitionEdge which was preventing the construction of a PartitionEdge from a NamedEdge{Tuple{V,V'}} where V and V' are different types
  2. partitioned_vertices(g; args...) which passes to various partitioning backends now acts on an AbstractGraph type so one can directly pass types such as a DataGraph or ITensorNetwork to it.

@codecov-commenter
Copy link

Codecov Report

Attention: 31 lines in your changes are missing coverage. Please review.

Comparison is base (40f0edd) 78.83% compared to head (e9d0402) 77.95%.
Report is 7 commits behind head on main.

Files Patch % Lines
...aphs/partitionedgraphs/abstractpartitionedgraph.jl 37.14% 22 Missing ⚠️
src/Graphs/partitionedgraphs/partitionedgraph.jl 76.00% 6 Missing ⚠️
src/Graphs/partitionedgraphs/partitionedge.jl 0.00% 2 Missing ⚠️
.../Graphs/partitionedgraphs/abstractpartitionedge.jl 0.00% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #46      +/-   ##
==========================================
- Coverage   78.83%   77.95%   -0.88%     
==========================================
  Files          31       31              
  Lines        1167     1184      +17     
==========================================
+ Hits          920      923       +3     
- Misses        247      261      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mtfishman
Copy link
Member

I was only suggesting having subgraph(::PartitionedGraph, ::PartitionVertex) return an unpartitioned graph, I still think subgraph(::PartitionedGraph, ::Vector{<:PartitionVertex}) should return a partitioned graph.

@mtfishman
Copy link
Member

Some inspiration for that design comes from BlockArrays.jl:

julia> using BlockArrays

julia> a = BlockArray(randn(4, 4), [2, 2], [2, 2])
2×2-blocked 4×4 BlockMatrix{Float64}:
 -0.00134562   0.716063-0.0813348  -0.777815
  0.219591     1.08181-0.0702123   1.43331 
 ────────────────────────┼───────────────────────
 -0.64773     -0.1782460.0260001  -1.36855 
 -0.355566    -0.3518-0.203171    3.71155 

julia> a[Block(1, 1)]
2×2 Matrix{Float64}:
 -0.00134562  0.716063
  0.219591    1.08181

julia> a[BlockRange(1:2, 1:1)]
2×1-blocked 4×2 BlockMatrix{Float64}:
 -0.00134562   0.716063
  0.219591     1.08181 
 ──────────────────────
 -0.64773     -0.178246
 -0.355566    -0.3518  

i.e. indexing with just a single block returns a non-blocked array, while indexing with a range of blocks preserves the block structure.

@JoeyT1994
Copy link
Contributor Author

I see. I actually think that is already the behavior so I have reverted it back to that. I just forgot to call it that way in ITensorNetwork.jl

@mtfishman
Copy link
Member

@mtfishman mtfishman changed the title Bug Fix. Small Changes Fix bug in PartitionEdge with mixed vertex types, generalize partitioned_vertices to AbstractGraph Jan 23, 2024
@mtfishman mtfishman merged commit 569e829 into ITensor:main Jan 23, 2024
8 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants