Skip to content

site[s] convenient constructors for unit ranges/axes #21

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

Merged
merged 2 commits into from
Feb 2, 2025
Merged

Conversation

mtfishman
Copy link
Member

@mtfishman mtfishman commented Feb 2, 2025

For example, site("S=1/2") is now a shorthand for AbstractUnitRange(SiteType("S=1/2")), and sites("S=1/2", 4) is a shorthand for [AbstractUnitRange(SiteType("S=1/2")) for _ in 1:4]. These are generalizations of siteind and siteinds defined in ITensors.jl/ITensorMPS.jl.

Additionally, a unit range type can be passed as the first argument for customization, i.e.:

julia> using QuantumOperatorDefinitions: site

julia> site(UnitRange{Int32}, "S=1/2") === Int32(1):Int32(2)
true

The idea is that the next generation versions of siteind and siteinds (being developed in ITensor/ITensorMPS.jl#108) can just be defined as:

siteind(name::String; kwargs...) = site(Index, name; kwargs...)
siteinds(name::String, nsites::Int; kwargs...) = sites(Index, name, nsites; kwargs...)

where customizations like symmetry sectors and Hilbert space dimensions (in the case of bosons/qudits) can be passed as keyword arguments.

Copy link

codecov bot commented Feb 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.50%. Comparing base (e08b46e) to head (65b4830).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #21      +/-   ##
==========================================
+ Coverage   68.65%   69.50%   +0.85%     
==========================================
  Files          13       13              
  Lines         536      551      +15     
==========================================
+ Hits          368      383      +15     
  Misses        168      168              
Flag Coverage Δ
docs 27.82% <0.00%> (-0.80%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@mtfishman mtfishman merged commit a9614a1 into main Feb 2, 2025
12 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.

1 participant