Skip to content

Remove all type piracy and move map_diag to the ITensor layer#2

Merged
mtfishman merged 3 commits into
mainfrom
mf/review-fixes
Jul 8, 2026
Merged

Remove all type piracy and move map_diag to the ITensor layer#2
mtfishman merged 3 commits into
mainfrom
mf/review-fixes

Conversation

@mtfishman

@mtfishman mtfishman commented Jul 7, 2026

Copy link
Copy Markdown
Member

Summary

Removes all type piracy from the compatibility layer. The pirated Base.exp(::AbstractITensor) is replaced by an owned exp (moved from SiteTypes to itensor.jl) that forwards operator ITensors to ITensorBase's matricization Base.exp(a, codomain, domain) and everything else to Base.exp. The remaining pirated methods that extended ITensorBase and Adapt types with legacy behavior (element-type adapt, the ITensor(::Number) and tagged Index constructors) are removed, to be reprovided without piracy in follow-ups.

Also splits map_diag / map_diag!: the generic functions stay in the NDTensors submodule, where the names belong, and their AbstractITensor methods move to the ITensors submodule, which owns the tensor type.

@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

Replaces the pirated `Base.exp(::AbstractITensor)` method with an owned `exp`
in the `ITensors` submodule that forwards operator ITensors to ITensorBase's
matricization `Base.exp(a, codomain, domain)` and every other argument to
`Base.exp`. The method moves from the `SiteTypes` submodule to `itensor.jl`.

Also splits `map_diag` / `map_diag!`: the generic functions stay in the
`NDTensors` submodule, where the names belong, and their `AbstractITensor`
methods move to the `ITensors` submodule, which owns the tensor type.
Removes the `Adapt.adapt_structure` method for `AbstractITensor` that reproduced legacy `adapt(eltype)` element-type conversion. Both the function and the type are foreign to this package, so the method is type piracy, and using `Adapt.adapt_structure` for scalar-type conversion misuses Adapt.jl, which is for storage and device adaptation. The element-type-conversion call sites will be rewritten with a different pattern in a follow-up.
@mtfishman mtfishman changed the title Remove exp type piracy and move map_diag to the ITensor layer Remove type piracy and move map_diag to the ITensor layer Jul 7, 2026
Removes the pirated `ITensorBase.ITensor(::Number)`, `ITensorBase.Index(::Integer, ::AbstractString)`, and `ITensorBase.Index(::Integer, ::AbstractDict)` constructor methods. Each extends an ITensorBase-owned type with only Base-owned argument types, so it is type piracy. None of them have call sites within this package. Reproviding the legacy constructors without piracy is tracked as a follow-up.
@mtfishman mtfishman changed the title Remove type piracy and move map_diag to the ITensor layer Remove all type piracy and move map_diag to the ITensor layer Jul 8, 2026
@mtfishman mtfishman merged commit ac42bb4 into main Jul 8, 2026
15 of 17 checks passed
@mtfishman mtfishman deleted the mf/review-fixes branch July 8, 2026 00:23
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