Conversation
…to test/utils.jl
Pull non-basic constructors that are only used by tests out of `src/` and
into a new `test/utils.jl` helper file. Each test that needs them does
`include("utils.jl")` inside its gensym module. The file is intentionally
named `utils.jl` so the `ITensorPkgSkeleton.runtests` runner does not
auto-pick it up (the runner only globs `test_*.jl`).
What moved:
- `random_tensornetwork` (12 method specializations, including the
`Distribution`- and `IsUnderlyingGraph`-based variants) — moved from
`src/specialitensornetworks.jl` to `test/utils.jl`.
- `random_ttn` and `random_mps` — moved from
`src/treetensornetworks/treetensornetwork.jl` to `test/utils.jl`.
These thin wrappers around `random_tensornetwork` had no real consumers
in `src/` (only docstring examples) and a single test reference.
- `ModelHamiltonians.tight_binding`, `heisenberg`, `ising`, plus the
internal helpers `to_callable`, `nth_nearest_neighbors`,
`next_nearest_neighbors` — moved from `src/lib/ModelHamiltonians/` to
a `ModelHamiltonians` submodule in `test/utils.jl`. Test sites continue
to call them as `ModelHamiltonians.ising(...)` etc.
What was deleted outright:
- `delta_network` (and the entire `src/specialitensornetworks.jl`) — the
only consumer was `ModelNetworks.ising_network`, which itself had no
consumers.
- `ModelHamiltonians.hubbard` — no consumers.
- `src/lib/ModelNetworks/` (`ising_network`, `ising_network_state`) — no
consumers; the lone `using ITensorNetworks.ModelNetworks: ModelNetworks`
in `test/test_belief_propagation.jl` was an unused import.
- `random_ttn` / `random_mps` jldoctest examples in `src/normalize.jl`,
`src/expect.jl`, `src/treetensornetworks/abstracttreetensornetwork.jl`
(per the rule that doc examples should not depend on functions being
removed). The `[`random_ttn`](@ref)` / `[`random_mps`](@ref)` references
in `See also:` lists were dropped as well.
`docs/src/computing_properties.md`, `tree_tensor_networks.md`, and
`solvers.md` were updated to drop their `random_ttn` / `random_mps` calls;
the `@autodocs` listing in `docs/src/reference.md` was trimmed to just
`ITensorNetworks` (no longer pulling in the removed `ModelNetworks` /
`ModelHamiltonians` submodules).
A few imports that were previously available inside `ITensorNetworks` as
a side effect of the deleted files' `using` clauses are now imported
directly by the files that actually use them:
- `ITensors: delta` — `src/formnetworks/bilinearformnetwork.jl`,
`src/caches/abstractbeliefpropagationcache.jl`
Bump to 0.19.0 (breaking, pre-1.0 minor bump) and update pinned
`ITensorNetworks` compat in `test/`, `docs/`, and `examples/` Project.toml.
Also add `SimpleTraits` to `test/Project.toml` so `test/utils.jl` can use
the `@traitfn` macro.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #339 +/- ##
==========================================
+ Coverage 71.07% 72.50% +1.43%
==========================================
Files 70 67 -3
Lines 3360 3179 -181
==========================================
- Hits 2388 2305 -83
+ Misses 972 874 -98
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ctor
Switch the `@setup` / `@example` blocks in `docs/src/computing_properties.md`
and `docs/src/solvers.md` from the function-callback `ITensorNetwork(s; link_space, kwargs...) do v ... end`
form to an explicit construction:
1. build a `Dict{Edge, Index}` of link indices over `edges(g)` (mirrored
under `reverse(e)`),
2. build an `ITensor` for each vertex from the site index plus the link
indices on that vertex's incident edges,
3. wrap with the basic `ITensorNetwork(::Dict{V, ITensor})` constructor.
Mirrors the construction pattern used in the ITensorNetworksNext.jl tests
and avoids leaning on the `do v ... end` higher-level constructor that we
intend to phase out.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ctor
Replace the two base implementations of `random_tensornetwork` (the
`randn`-based one and the `Distribution`-based one) so they use the
explicit construction pattern instead of the higher-level
`ITensorNetwork(s; link_space, kwargs...) do v ... end` callback form.
The new private `_random_tensornetwork(s, build_tensor; link_space)`
helper:
1. builds a `Dict{Edge, Index}` of fresh link indices over `edges(s)`
(mirrored under `reverse(e)`),
2. for each vertex, gathers the site indices from `vertex_data(s)[v]`
(or empty if `v` has no entry — necessary for IndsNetworks built
from a bare graph) plus the link indices on incident edges,
3. lets the caller-supplied `build_tensor` produce the per-vertex
`ITensor`,
4. wraps with the basic `ITensorNetwork(::Dict{V, ITensor})`
constructor.
This is the same pattern used in the docs setup blocks and in the
ITensorNetworksNext.jl tests, and it stops `random_tensornetwork` from
depending on the higher-level `ITensorNetwork(::IndsNetwork; link_space, kwargs...) do v ... end`
constructor we intend to remove. The 12 user-facing
`random_tensornetwork` method specializations and their `IsUnderlyingGraph`
trait wrappers are unchanged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pull non-basic constructors that are only used by tests out of
src/and into a newtest/utils.jl. Each test that needs them doesinclude("utils.jl")inside its gensym module. The file is intentionally namedutils.jlso theITensorPkgSkeleton.runtestsrunner does not auto-pick it up (the runner only globstest_*.jl).What moved to
test/utils.jl:random_tensornetwork(12 method specializations, including theDistribution- andIsUnderlyingGraph-based variants) — moved fromsrc/specialitensornetworks.jl.random_ttnandrandom_mps— moved fromsrc/treetensornetworks/treetensornetwork.jl. These thin wrappers aroundrandom_tensornetworkhad no realsrc/consumers (only docstring examples) and a single test reference.ModelHamiltonians.tight_binding,heisenberg,isingplus the internal helpersto_callable,nth_nearest_neighbors,next_nearest_neighbors— moved fromsrc/lib/ModelHamiltonians/into aModelHamiltonianssubmodule oftest/utils.jl. Test sites continue to call them asModelHamiltonians.ising(...)etc.What was deleted entirely (no consumers):
delta_network(and the rest ofsrc/specialitensornetworks.jl) — only consumer wasModelNetworks.ising_network, which itself had no consumers.ModelHamiltonians.hubbard— no consumers.src/lib/ModelNetworks/(ising_network,ising_network_state) — no consumers; the loneusing ITensorNetworks.ModelNetworks: ModelNetworksintest/test_belief_propagation.jlwas an unused import and was dropped.random_ttn/random_mpsjldoctest examples insrc/normalize.jl,src/expect.jl,src/treetensornetworks/abstracttreetensornetwork.jl, plus[ref]links inSee also:lists. Consistent with not having doc examples that depend on functions being removed.Construction pattern
The
random_tensornetworkhelpers intest/utils.jlare factored through a private_random_tensornetwork(s::IndsNetwork, build_tensor; link_space)that uses the explicit Dict-of-ITensor pattern: build aDict{Edge, Index}of fresh link indices overedges(s)(mirrored underreverse(e)); for each vertex, gather the site indices fromvertex_data(s)[v](or empty ifvhas no entry) plus the link indices on incident edges; let the caller-suppliedbuild_tensorproduce the per-vertexITensor; wrap with the basicITensorNetwork(::Dict{V, ITensor})constructor. The 12 user-facingrandom_tensornetworkmethod specializations and theirIsUnderlyingGraphtrait wrappers route through this helper.Documentation
docs/src/{computing_properties,solvers}.mdsetup blocks now build a small inlinerandom_state(g, s; link_space)helper using the same Dict-of-ITensor pattern, instead of callingrandom_ttn.link_spaceis required (no default), passed explicitly at the call sites.docs/src/tree_tensor_networks.mddrops therandom_ttn/random_mpsconstructor examples and autodoc entries.docs/src/reference.md's@autodocslisting trimmed to justITensorNetworks(no longer pulling in the removedModelNetworks/ModelHamiltonianssubmodules).Incidental import cleanups
A few imports were previously available inside
ITensorNetworksas a side effect of the deleted files'usingclauses; now imported directly:ITensors: delta—src/formnetworks/bilinearformnetwork.jl,src/caches/abstractbeliefpropagationcache.jlVersion + test deps
0.19.0(pre-1.0 minor bump = breaking, public API removed).ITensorNetworkscompat intest/,docs/,examples/Project.toml.SimpleTraitstotest/Project.tomlsotest/utils.jlcan use@traitfn/IsUnderlyingGraph.