Skip to content

Document interface of library#346

Open
emstoudenmire wants to merge 23 commits intomainfrom
MS_doc_interface
Open

Document interface of library#346
emstoudenmire wants to merge 23 commits intomainfrom
MS_doc_interface

Conversation

@emstoudenmire
Copy link
Copy Markdown
Contributor

@emstoudenmire emstoudenmire commented Apr 27, 2026

This PR adds documentation of which methods we may consider "interface", and thus should keep and add docstrings for, versus deprecated methods we may want to delete. Methods not in the two files interface_methods.md and deprecated_methods.md are considered internal, developer-facing methods.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 27, 2026

Your PR no longer requires formatting changes. Thank you for your contribution!

Comment thread docs/src/interface_methods.md Outdated
Comment thread docs/src/interface_methods.md Outdated
Comment thread docs/src/deprecated_methods.md
Comment thread docs/src/deprecated_methods.md Outdated
Comment thread docs/src/deprecated_methods.md
Comment thread docs/src/interface_methods.md Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.26%. Comparing base (8c12dcd) to head (825584b).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #346   +/-   ##
=======================================
  Coverage   73.26%   73.26%           
=======================================
  Files          66       66           
  Lines        3183     3183           
=======================================
  Hits         2332     2332           
  Misses        851      851           
Flag Coverage Δ
docs 47.16% <ø> (ø)

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.

Comment thread docs/src/interface_methods.md Outdated
Comment thread docs/src/interface_methods.md Outdated
@mtfishman
Copy link
Copy Markdown
Member

@emstoudenmire can you bump the version, fix the docs build, and format just so we can get tests passing?

Also, I noticed you are just including the function signatures in the docs. For functions that have docstrings, can you insert the docstring instead of just putting the function signature?

Comment thread docs/src/interface_methods.md Outdated
Comment thread docs/src/interface_methods.md Outdated
Comment thread docs/src/interface_methods.md Outdated
Comment thread docs/src/interface_methods.md Outdated
Comment thread docs/src/interface_methods.md Outdated
Comment thread docs/src/interface_methods.md Outdated
Comment thread docs/src/interface_methods.md Outdated
@mtfishman mtfishman marked this pull request as ready for review April 30, 2026 14:08
Comment thread docs/src/interface_methods.md Outdated
Comment thread docs/src/interface_methods.md Outdated
Comment thread docs/src/interface_methods.md Outdated
Comment thread docs/src/experimental_methods.md Outdated
Comment on lines +9 to +36
* Copy constructor (`itensornetwork.jl`):
```julia
ITensorNetwork{V}(tn::ITensorNetwork)
```

* From vertex-tensor pairings (`itensornetwork.jl`):
```julia
# Dictionary of vertices => tensors
ITensorNetwork(ts::AbstractDictionary{<:Any, ITensor})
ITensorNetwork(ts::AbstractDict{<:Any, ITensor})

# Vector of `vertex => ITensor` pairs
ITensorNetwork(ts::AbstractVector{<:Pair{<:Any, ITensor}})

# Vector of vertices, vector of ITensors
ITensorNetwork(vertices::AbstractVector, tensors::AbstractVector{ITensor})
```

* From a collection of ITensorNetworks. Merges (Kronecker or tensor product) of input networks (`itensornetwork.jl`):
```julia
ITensorNetwork(itns::Vector{ITensorNetwork})
```

* From a vector of `ITensor`s, with vertex labels auto-assigned to `eachindex(ts)`.
Edges are inferred from shared indices (`itensornetwork.jl`):
```julia
ITensorNetwork(ts::AbstractVector{ITensor})
```
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can compress this down:

# `keys(tensors)` are vertices, `values(tensors)` are tensors on those vertices
ITensorNetwork(tensors)
ITensorNetwork{V}(tensors)

# Collection of vertices, collection of tensors
ITensorNetwork(vertices, tensors)
ITensorNetwork{V}(vertices, tensors)

That actually encompasses all of them (potentially even ITensorNetwork{V}(tn::ITensorNetwork), since keys(tn) should be the vertices and values(tn) should be the tensors, though we'd have to double check if that would work in practice).

Also, I don't particularly like the ITensorNetwork(itns::Vector{ITensorNetwork}) since it doesn't fit into that generic framework very well, I think we should move that to "deprecated".

Note that this doesn't necessarily fully reflect the current state of the code: the constructors are not that generic, some of the ones I wrote above may not exist yet, etc. However, I think for these docs we can do some mixture of summarizing the current code and resummarizing in a way we want the code to be (though please write a comment when these docs diverge from the current code, indicating that they reflect plans for the code).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting point. Just made this change and I like the idea of the docs being slightly "aspirational" so we can keep working the code toward the docs.

About the last constructor above, though, the ITensorNetwork(ts::AbstractVector{ITensor}) one. That doesn't seem to quite fit either description. I guess keep it as a separate item?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's encompassed by ITensorNetwork(tensors), keys(::AbstractVector) and values(::AbstractVector) are defined as we would want them to be for this design:

julia> keys(["x", "y", "z"])
3-element LinearIndices{1, Tuple{Base.OneTo{Int64}}}:
 1
 2
 3

julia> values(["x", "y", "z"])
3-element Vector{String}:
 "x"
 "y"
 "z"

@emstoudenmire
Copy link
Copy Markdown
Contributor Author

By the way, the interface page has gotten quite small... It's nice to see. Once we can build the main features back on top (assuming they aren't already) , such as BP, constructor codes (e.g. fermionic states) based on BP, and solvers, that will be a good situation.

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