Skip to content

Conversation

@borisdevos
Copy link
Member

@borisdevos borisdevos commented Sep 25, 2025

This PR introduces the renamings concerning units of sectors, as well as replacing conj of sectors with dual. Additionally, Base.oneunit now falls back to unitspace. I also took the liberty of defining zerospace, to which Base.zero falls back. This is a breaking change.

A follow-up PR will then actually use UnitStyle etc to generalise a couple of functions to deal with multifusion categories.

Something I can still do is update the documentation related to sectors, but I know @Jutho just started on a documentation overhaul, so I haven't done so yet.

This requires QuantumKitHub/TensorKitSectors.jl#25 to be released.

@borisdevos borisdevos changed the title Renamings based on QuantumKitHub/TensorKitSectors.jl#25 Renamings based on TensorKitSectors.jl#25 Sep 25, 2025
@borisdevos
Copy link
Member Author

I added some changes I made in #263 which are unrelated to multifusion categories or the factorisation tests, the former coming soon in a future PR and the latter because I've been told because of a MatrixAlgebraKit overhaul that the tests may be updated.

@lkdvos lkdvos changed the title Renamings based on TensorKitSectors.jl#25 Changes for TensorKitSectors v0.3 Oct 14, 2025
@codecov
Copy link

codecov bot commented Oct 14, 2025

Codecov Report

❌ Patch coverage is 84.00000% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/fusiontrees/manipulations.jl 90.47% 2 Missing ⚠️
src/spaces/generalspace.jl 0.00% 2 Missing ⚠️
src/spaces/productspace.jl 66.66% 2 Missing ⚠️
src/spaces/vectorspaces.jl 66.66% 2 Missing ⚠️
src/tensors/tensor.jl 0.00% 2 Missing ⚠️
src/fusiontrees/iterator.jl 66.66% 1 Missing ⚠️
src/spaces/homspace.jl 0.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/TensorKit.jl 22.72% <ø> (ø)
src/fusiontrees/fusiontrees.jl 90.32% <100.00%> (ø)
src/spaces/cartesianspace.jl 75.67% <100.00%> (ø)
src/spaces/complexspace.jl 87.50% <100.00%> (ø)
src/spaces/deligne.jl 87.50% <100.00%> (ø)
src/spaces/gradedspace.jl 95.10% <100.00%> (ø)
src/tensors/braidingtensor.jl 71.06% <ø> (ø)
src/tensors/linalg.jl 82.69% <100.00%> (-0.30%) ⬇️
src/fusiontrees/iterator.jl 94.11% <66.66%> (ø)
src/spaces/homspace.jl 94.54% <0.00%> (ø)
... and 5 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Base.zero(V::ElementarySpace) = zero(typeof(V))
zerospace(V::ElementarySpace) = zerospace(typeof(V))
Base.zero(V::ElementarySpace) = zerospace(V)
Base.zero(::Type{V}) where {V <: ElementarySpace} = zerospace(V)
Copy link
Member

Choose a reason for hiding this comment

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

I am actually wondering whether this was also considered type piracy. In the same way as overloading Base.show(::Type{MyType}) is not a good idea, this has the same issue, that it is overloading a base method for Type{MyType}, and I don't know if a package is considered to be the owner of Type{MyType} just because it owns MyType. Though I don't see how packages implementing new numerical types could do without something like this.

Copy link
Member

Choose a reason for hiding this comment

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

Also, this is a non-blocking philosophical question. No action for this PR required.

Copy link
Member

Choose a reason for hiding this comment

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

Just to share some of my ideas on the topic: I've also been going back and forth on this issue...
I think one way of answering this (definitely not the only way) is to think about who owns something like Vector{MyType} and then claim that actually Type{MyType} might be the same?
For practical reasons, I think it's probably reasonable to "take ownership" of Vector{MyType} for your own number type if you have a specialized implementation for eg. +, but by that logic you should also be allowed to implement show(::Vector{MyType}), and therefore also show(::Type{MyType}).

I think that really, there's two points to type piracy. On the one hand, there is the issue with composing it across packages, you don't want to have multiple people trying to overwrite the same method. On the other hand, there's the issue with composing it in functionality, where you need the behavior of the method to remain the same as what the function intended, as otherwise you might get errors, or even silently wrong results.

The first point is clearly not an issue for things like Vector{MyType} or Type{MyType}, since you own the type so you are "the first" to be able to define a method. The second point is a bit more subtle I think, since I would argue that for +(::Vector{MyType}, ::Vector{MyType}), it is clear what the method should and shouldn't do, while show is just one of those functions where the API is really badly specified, which makes it a lot more dangerous to touch. I think that if the observable behavior of show would be clearly defined, we should be allowed to overload that.

@Jutho
Copy link
Member

Jutho commented Oct 15, 2025

This looks good to me. I've slightly reorganized the export section of "src/TensorKit.jl". Let's hope I didn't mess it up. Then I think that can be merged.

@lkdvos lkdvos merged commit ea6bff6 into main Oct 15, 2025
8 of 11 checks passed
@lkdvos lkdvos deleted the bd/renaming branch October 15, 2025 19:54
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