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

[NDTensors] split dual into UnitRangeDual and GradedUnitRangeDual #1529

Closed
wants to merge 107 commits into from

Conversation

ogauthe
Copy link
Contributor

@ogauthe ogauthe commented Sep 12, 2024

This PR aims to simplify the use of GradedAxes.dual, especially to be used in a BlockSparseArray. It proposes to split the UnitRangeDual type into two different types:

  • a generic UnitRangeDual{<:AbstractUnitRange} <: AbstractUnitRange
  • a labelled GradedUnitRangeDual{<:LabelledInteger,<:AbstractGradedUnitRange} <: AbstractGradedUnitRange

This should simplify slicing a BlockSparseArray with dual axes and allows to preserve labels or take their dual.

This branch is built on top of #1363 and should only be merged once #1363 is completed. It does not make any change in Sectors.

@ogauthe
Copy link
Contributor Author

ogauthe commented Sep 16, 2024

Currently, this branche solves:

  • preserving labels in blocklengths(dual(...))
g = gradedrange([U1(1) => 2, U1(2) => 2])
@test GradedAxes.blocklengths(dual(g)) isa Vector{<:LabelledInteger}  #    # broken in main and in non-abelian_fusion
  • preserving GradedUnitRange behavior when slicing:
blocklengths(dual(gradedrange([U1(0) => 2, U1(1) => 2])[1:3])) isa Vector  # broken in main and in non-abelian_fusion
  • manipulating arrays with DualGradedUnitRange
r = gradedrange([U1(0) => 2, U1(1) => 2])[1:3]
a = BlockSparseArray{Float64}(r, r)
b = BlockSparseArray{Float64}(dual(r),dual(r))
@test a[:, :] isa BlockSparseArray   # broken in main and in non-abelian_fusion
@test b[:, :] isa BlockSparseArray   # broken in main and in non-abelian_fusion

Meaning one can create and manipulate BlockSparseArray with GradedUnitRange or its dual (not just BlockedOneTo). However axes(a[:,:]) are still Base.IdentityUnitRange(GradedUnitRangeDual{...}), which creates other issues.

It also adds many tests, including broken ones.

@mtfishman
Copy link
Member

What parts of this PR rely on #1363? It would be simpler to review and merge this if it was separate from #1363.

@ogauthe
Copy link
Contributor Author

ogauthe commented Sep 16, 2024

replaced by #1531

@ogauthe ogauthe closed this Sep 16, 2024
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