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

[GradedAxes] Introduce LabelledUnitRangeDual #1571

Merged
merged 17 commits into from
Nov 7, 2024

Conversation

ogauthe
Copy link
Contributor

@ogauthe ogauthe commented Nov 6, 2024

This PR aims to fix cases where dual information is lost while slicing a BlockSparseArray. There are 2 cases:

  • slicing a GradedUnitRangeDual with a Block now produces a (non-blocked) LabelledUnitRangeDual, which preserves dual information
  • slicing a GradedUnitRangeDual with a vector of Block or BlockIndexRange produces a BlockVector whose only axis is a GradedUnitRangeDual. This is needed in views of BlockSparseArray.

@ogauthe ogauthe force-pushed the LabelledUnitRangeDual branch from a352498 to 8e988c0 Compare November 6, 2024 22:21
@mtfishman mtfishman changed the title [NDTensors][GradedAxes] introduce LabelledUnitRangeDual [GradedAxes] introduce LabelledUnitRangeDual Nov 7, 2024
@mtfishman mtfishman changed the title [GradedAxes] introduce LabelledUnitRangeDual [GradedAxes] Introduce LabelledUnitRangeDual Nov 7, 2024
@mtfishman
Copy link
Member

Looks good to me, ready to merge from your end?

@ogauthe
Copy link
Contributor Author

ogauthe commented Nov 7, 2024

With this PR, we now have an error with

label(dual(labelled(1:1, "x")))
ERROR: MethodError: no method matching dual(::String)

Closest candidates are:
  dual(::NDTensors.SymmetrySectors.Ising)
   @ NDTensors ~/Documents/itensor/ITensors.jl/NDTensors/src/lib/SymmetrySectors/src/sector_definitions/ising.jl:24
  dual(::NDTensors.SymmetrySectors.Fib)
   @ NDTensors ~/Documents/itensor/ITensors.jl/NDTensors/src/lib/SymmetrySectors/src/sector_definitions/fib.jl:24
  dual(::NDTensors.SymmetrySectors.TrivialSector)
   @ NDTensors ~/Documents/itensor/ITensors.jl/NDTensors/src/lib/SymmetrySectors/src/sector_definitions/trivial.jl:15
  ...

Stacktrace:
 [1] label(a::LabelledUnitRangeDual{LabelledInteger{Int64, String}, LabelledUnitRange{Int64, UnitRange{Int64}, String}})
   @ NDTensors.GradedAxes ~/Documents/itensor/ITensors.jl/NDTensors/src/lib/GradedAxes/src/labelledunitrangedual.jl:16
 [2] top-level scope
   @ REPL[12]:1

Maybe we should default dual(x) = x.

@mtfishman
Copy link
Member

Maybe we should default dual(x) = x.

That would make sense as a definition, we do that as a default definition for unit ranges anyway.

@ogauthe
Copy link
Contributor Author

ogauthe commented Nov 7, 2024

Ready to merge!

@mtfishman
Copy link
Member

Ready to merge!

Great, thanks. I'll merge once tests pass.

@mtfishman mtfishman merged commit 6555e0e into ITensor:main Nov 7, 2024
12 checks passed
@ogauthe ogauthe deleted the LabelledUnitRangeDual branch November 7, 2024 23:18
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.

2 participants