Default spacetype and sectortype implementations in type domain#248
Default spacetype and sectortype implementations in type domain#248lkdvos merged 3 commits intoQuantumKitHub:masterfrom
spacetype and sectortype implementations in type domain#248Conversation
|
As we discussed, the docs can perhaps be migrated to a centralized location through: @doc """
...
""" spacetypeOtherwise definitely looks like a nice quality of life addition to me, also relevant for MPSKit. |
|
I generalized the doc. Also generalized |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #248 +/- ##
=======================================
Coverage 82.65% 82.66%
=======================================
Files 43 43
Lines 5593 5583 -10
=======================================
- Hits 4623 4615 -8
+ Misses 970 968 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Yes this is indeed much more convenient. The only small comment is that I would streamline: sectortype(::Type{S}) where {S<:Sector} = S
spacetype(S::Type{<:ElementarySpace}) = Sso that they take the same form (both seem to do the job). |
I found there are subtle differences in dispatch behavior between these 2 versions (see https://docs.julialang.org/en/v1/manual/performance-tips/#Be-aware-of-when-Julia-avoids-specializing). I now impose specialization. |
|
This is true, but often not relevant since these functions get inlined and constant folded most of the time, but I fully agree not relying on these implicit compiler details is annoying since it's hard to verify, so might as well be explicit about it |
spacetype and sectortype implementations in type domain
PEPSKit.jl overload
sectortypeandspacetypefor many objects (see QuantumKitHub/PEPSKit.jl@af3f140 or QuantumKitHub/PEPSKit.jl#218). Currently one has to repeat 4 lines of code for every struct in order to dispatch on type and usesectortype(spacetype).This PR proposes to set defaults in
TensorKitsuch that a single lineis sufficient to use
sectortype(x::MyType)andspacetype(x::MyType).I also defined a default for
fieldas it is very similar. I kept the specializations forAbstractTensorMapto conserve easy access to the documentation, I do not know if there is a better way.