Skip to content

Conversation

@VinceNeede
Copy link
Contributor

@VinceNeede VinceNeede commented Apr 9, 2025

Description

The constructor for AbstractMPS subtypes now accepts a vector of tags as keyword to be used during the factorization. This is then used by setindex!(::MPST, ::ITensor, ::UnitRange) to set the proper inds tags. This fixes #104 Issue, improving readability.

Fixes #104

If practical and applicable, please include a minimal demonstration of the previous behavior and new behavior below.

Minimal demonstration of previous behavior

using ITensorMPS

s = siteinds("Qubit",3)
st = random_mps(s)
stm = movesite(st, 1=>3)

println(stm)

Output

MPS
[1] ((dim=2|id=834|"Qubit,Site,n=2"), (dim=2|id=590|"Link,n=1"))
[2] ((dim=2|id=590|"Link,n=1"), (dim=2|id=502|"Qubit,Site,n=3"), (dim=2|id=864|"Link,n=1"))
[3] ((dim=2|id=864|"Link,n=1"), (dim=2|id=138|"Qubit,Site,n=1"))

Minimal demonstration of new behavior

New Output

MPS
[1] ((dim=2|id=384|"Qubit,Site,n=2"), (dim=2|id=128|"Link,l=1"))
[2] ((dim=2|id=128|"Link,l=1"), (dim=2|id=986|"Qubit,Site,n=3"), (dim=2|id=66|"Link,l=2"))
[3] ((dim=2|id=66|"Link,l=2"), (dim=2|id=375|"Qubit,Site,n=1"))

How Has This Been Tested?

Please add tests that verify your changes to a file in the test directory.

Please give a summary of the tests that you added to verify your changes.

  • Test over the permutations that ITensorMPS.hasdefaultlinktags returns true

Checklist:

  • My code follows the style guidelines of this project. Please run using JuliaFormatter; format(".") in the base directory of the repository (~/.julia/dev/ITensorMPS) to format your code according to our style guidelines.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that verify the behavior of the changes I made.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • Any dependent changes have been merged and published in downstream modules.

@codecov
Copy link

codecov bot commented Apr 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.27%. Comparing base (03520b6) to head (f08ff48).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #137   +/-   ##
=======================================
  Coverage   90.26%   90.27%           
=======================================
  Files          54       54           
  Lines        3575     3577    +2     
=======================================
+ Hits         3227     3229    +2     
  Misses        348      348           
Flag Coverage Δ
docs 18.36% <0.00%> (-0.02%) ⬇️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@VinceNeede
Copy link
Contributor Author

The TypeError happened when firstindex was equal to lastindex, resulting in linktags of type Any[]. This should solve the error. I have run test_mps.jl and it didn't report errors this time.

@mtfishman
Copy link
Member

Thanks @VinceNeede, can you change this line:

version = "0.3.16"
to version = "0.3.17" so we can register it in a new version of the package?

@VinceNeede
Copy link
Contributor Author

Removed the type restriction on tags and changed the documentation, and bumped to 0.3.17

@mtfishman
Copy link
Member

The format check failed because we just updated the version of the formatter we are using, I'm fixing the formatting separately in #138 and then I'll update this PR accordingly.

@mtfishman mtfishman merged commit 68cc1e8 into ITensor:main Apr 11, 2025
11 of 12 checks passed
@VinceNeede VinceNeede deleted the Issue_104 branch April 11, 2025 07:07
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.

movesite messes the tags on the links of mps

2 participants