Remove all type piracy and move map_diag to the ITensor layer#2
Merged
Conversation
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.
b4d14de to
c93e9b2
Compare
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.
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.
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
Removes all type piracy from the compatibility layer. The pirated
Base.exp(::AbstractITensor)is replaced by an ownedexp(moved fromSiteTypestoitensor.jl) that forwards operator ITensors to ITensorBase's matricizationBase.exp(a, codomain, domain)and everything else toBase.exp. The remaining pirated methods that extended ITensorBase and Adapt types with legacy behavior (element-typeadapt, theITensor(::Number)and taggedIndexconstructors) are removed, to be reprovided without piracy in follow-ups.Also splits
map_diag/map_diag!: the generic functions stay in theNDTensorssubmodule, where the names belong, and theirAbstractITensormethods move to theITensorssubmodule, which owns the tensor type.